66 #include "xc_utils/src/nucleo/EntCmd.h" 67 #include "xc_basic/src/matrices/m_double.h" 85 static double VECTOR_NOT_VALID_ENTRY;
90 void alloc(
const size_t &sz);
94 explicit Vector(
const int &,
const double &valor= 0.0);
95 explicit Vector(
const std::vector<double> &v);
96 explicit Vector(
const Vector2d &v);
97 explicit Vector(
const Vector3d &v);
98 Vector(
const double &,
const double &,
const double &);
100 Vector(
double *data,
int size);
101 Vector(
const boost::python::list &);
105 int setData(
double *newData,
int size);
106 const double *getDataPtr(
void)
const;
107 double *getDataPtr(
void);
108 bool Nulo(
void)
const;
110 double Norm2(
void)
const;
111 double Norm(
void)
const;
112 double pNorm(
int p)
const;
114 int Size(
void)
const;
115 int getNumBytes(
void)
const;
118 bool isnan(
void)
const;
119 int reset(
const int &newSize);
125 int addVector(
double factThis,
const Vector &other,
double factOther);
126 int addMatrixVector(
double factThis,
const Matrix &m,
const Vector &v,
double factOther);
127 int addMatrixTransposeVector(
double factThis,
const Matrix &m,
const Vector &v,
double factOther);
131 virtual double &
at(
const size_t &f);
133 virtual const double &
at(
const size_t &f)
const;
138 const double &operator()(
int x)
const;
139 double &operator()(
int x);
140 const double &operator[](
int x)
const;
141 double &operator[](
int x);
142 Vector operator()(
const ID &rows)
const;
145 template <
class TNSR>
166 double dot(
const Vector &)
const;
170 int Extract(
const Vector &V,
int init_row,
double fact = 1.0);
176 void write(std::ofstream &);
177 void read(std::ifstream &);
178 friend std::ostream &operator<<(std::ostream &s,
const Vector &);
179 friend std::string to_string(
const Vector &);
180 inline std::string toString(
void)
const 181 {
return to_string(*
this); }
207 inline int Vector::Size(
void)
const 210 inline int Vector::getNumBytes(
void)
const 211 {
return Size()*
sizeof(double); }
213 inline const double *Vector::getDataPtr(
void)
const 216 inline double *Vector::getDataPtr(
void)
219 inline bool Vector::Nulo(
void)
const 220 {
return (theData==
nullptr); }
222 inline void Vector::Zero(
void)
224 for(
register int i=0; i<sz; i++)
228 inline bool Vector::isnan(
void)
const 231 for(
register int i=0; i<sz; i++)
232 if(std::isnan(theData[i]))
240 inline int Vector::reset(
const int &newSize)
242 const int retval=
resize(newSize);
247 inline const double &Vector::operator()(
int x)
const 253 std::cerr <<
"XC::Vector::(loc) - loc " << x <<
" outside range [0, " << sz-1 << endln;
254 return VECTOR_NOT_VALID_ENTRY;
261 inline double &Vector::operator()(
int x)
265 if (x < 0 || x >= sz)
267 std::cerr <<
"XC::Vector::(loc) - loc " << x <<
" outside range [0, " << sz-1 << std::endln;
268 return VECTOR_NOT_VALID_ENTRY;
274 template <
class TNSR>
280 std::cerr <<
"XC::Vector::operator=() - BJtensor must be of rank 2\n";
286 std::cerr <<
"XC::Vector::operator=() - BJtensor must have square dimensions\n";
290 if(dim != 2 || dim != 3 || dim != 1)
292 std::cerr <<
"XC::Vector::operator=() - BJtensor must be of dimension 2 or 3\n";
300 std::cerr <<
"Vector::operator=() - Vector size must be 1\n";
303 theData[0]= V.cval(1,1);
309 std::cerr <<
"Vector::operator=() - Vector size must be 3\n";
312 theData[0]= V.cval(1,1);
313 theData[1]= V.cval(2,2);
314 theData[2]= V.cval(1,2);
320 std::cerr <<
"Vector::operator=() - Vector size must be 6\n";
323 theData[0]= V.cval(1,1);
324 theData[1]= V.cval(2,2);
325 theData[2]= V.cval(3,3);
326 theData[3]= V.cval(1,2);
327 theData[4]= V.cval(1,3);
328 theData[5]= V.cval(2,3);
Vector & operator+=(double fact)
The += operator adds fact to each element of the vector, data[i]= data[i]+fact.
Definition: Vector.cpp:855
int Normalize(void)
Normalizes the vector with the euclidean norm.
Definition: Vector.cpp:270
Vector normalize_inf(const Vector &)
Returns the normalized vector (infinite norm).
Definition: Vector.cpp:322
virtual ~Vector(void)
destructor, deletes the [] data
Definition: Vector.cpp:192
Vector & operator*=(double fact)
The *= operator multiplies each element by the factor.
Definition: Vector.cpp:878
Vector NormalizedInf(void) const
Returns the normalized vector con la norma_infinito.
Definition: Vector.cpp:310
Vector operator+(double fact) const
The + operator returns a XC::Vector of the same size as current, whose components are return(i)= theD...
Definition: Vector.cpp:912
virtual bool CheckIndice0(const size_t &i) const
Check the index being passed as parameter.
Definition: Vector.cpp:766
virtual double & at(const size_t &f)
Returns the element at the row being passed as parameter.
Definition: Vector.cpp:750
double NormInf(void) const
Returns the máximo de los valores absolutos de las componentes del vector (norma_infinito).
Definition: Vector.cpp:716
Vector getComponents(const ID &) const
Returns a vector with the specified subset of components.
Definition: Vector.cpp:1208
void putComponents(const Vector &, const ID &)
Assigns the specified values to the specified set of vecto's components.
Definition: Vector.cpp:1218
Vector & operator-=(double fact)
The -= operator subtracts fact from each element of the vector, data[i]= data[i]-fact.
Definition: Vector.cpp:867
Matrix operator&(const Vector &u, const Vector &v)
tensor product.
Definition: Vector.cpp:1140
m_double vector_to_m_double(const Vector &)
Convierte el vector en un m_double.
Definition: Vector.cpp:1245
void write(std::ofstream &)
Escribe el vector en un archivo binario.
Definition: Vector.cpp:1101
Vector operator*(double fact) const
The + operator returns a XC::Vector of the same size as current, whose components are return(i)= theD...
Definition: Vector.cpp:939
MPI_Channel is a sub-class of channel. It is implemented with Berkeley stream sockets using the TCP p...
Definition: MPI_Channel.h:69
DP_Socket is a sub-class of channel. It is implemented with Berkeley datagram sockets using the UDP p...
Definition: UDP_Socket.h:76
TCP_Socket is a sub-class of channel. It is implemented with Berkeley stream sockets using the TCP pr...
Definition: TCP_Socket.h:71
Vector operator-(double fact) const
The + operator returns a XC::Vector of the same size as current, whose components are return(i)= theD...
Definition: Vector.cpp:925
System of equations base class.
Definition: SystemOfEqn.h:84
Vector(void)
Standard constructor, sets size= 0;.
Definition: Vector.cpp:110
int Assemble(const Vector &V, const ID &l, double fact=1.0)
Method to assemble into object the XC::Vector V using the XC::ID l. If XC::ID(x) does not exist progr...
Definition: Vector.cpp:245
Vector Normalized(void) const
Returns the normalized vector con la norma euclidea.
Definition: Vector.cpp:302
Vector & operator=(const Vector &V)
the assignment operator, This is assigned to be a copy of V. if sizes are not compatable this...
Definition: Vector.cpp:835
double Norm(void) const
Method to return the norm of vector.
Definition: Vector.cpp:712
double Norm2(void) const
Returns the cuadrado del módulo del vector.
Definition: Vector.cpp:700
void read(std::ifstream &)
Lee el vector de un archivo binario.
Definition: Vector.cpp:1112
Vector normalize(const Vector &)
Returns the normalized vector (euclidean norm).
Definition: Vector.cpp:318
Vector & operator/=(double fact)
The /= operator divides each element of the vector by fact, theData[i]= theData[i]/fact. Program exits if divide-by-zero would occur with warning message.
Definition: Vector.cpp:891
std::vector< double > vector_to_std_vector(const Vector &)
Convierte el vector en un std::vector<double>.
Definition: Vector.cpp:1235
TCP_SocketNoDelay is a sub-class of channel. It is implemented with Berkeley stream sockets using the...
Definition: TCP_SocketNoDelay.h:72
int resize(int newSize)
Changes vector size.
Definition: Vector.cpp:212
Message between processes.
Definition: Message.h:67
void addComponents(const Vector &, const ID &)
Sums the specified values to the specified set of vecto's components.
Definition: Vector.cpp:1226
int NormalizeInf(void)
Normaliza el vector con la norma_infinito.
Definition: Vector.cpp:286
================================================================================
Definition: ContinuaReprComponent.h:34
double operator^(const Vector &V) const
Method to perform (Vector)transposed * vector.
Definition: Vector.cpp:1058
Matrix prod_tensor(const Vector &, const Vector &)
Producto tensorial de dos tensores de primer orden.
Definition: Vector.cpp:1128
Vector operator/(double fact) const
The + operator returns a XC::Vector of the same size as current, whose components are return(i)= theD...
Definition: Vector.cpp:952