67 #include "utility/kernel/CommandEntity.h" 68 #include "utility/matrices/m_double.h" 97 static double VECTOR_NOT_VALID_ENTRY;
102 void alloc(
const size_t &sz);
104 typedef double* iterator;
108 explicit Vector(
const int &,
const double &value= 0.0);
109 explicit Vector(
const std::vector<double> &v);
110 explicit Vector(
const std::initializer_list<double> &);
113 Vector(
const double &,
const double &,
const double &);
115 Vector(
double *data,
int size);
116 explicit Vector(
const boost::python::list &);
119 iterator
begin(
void);
122 int setData(
double *newData,
int size);
127 double Norm2(
void)
const;
128 double Norm(
void)
const;
129 double pNorm(
int p)
const;
135 int Size(
void)
const;
139 bool isnan(
void)
const;
140 int reset(
const int &newSize);
148 int addMatrixTransposeVector(
double factThis,
const Matrix &m,
const Vector &v,
double factOther);
152 virtual double &
at(
const size_t &f);
154 virtual const double &
at(
const size_t &f)
const;
166 template <
class TNSR>
188 double dot(
const Vector &)
const;
192 int Extract(
const Vector &V,
int init_row,
double fact = 1.0);
198 void write(std::ofstream &);
199 void read(std::ifstream &);
200 friend std::ostream &operator<<(std::ostream &,
const Vector &);
201 friend std::string to_string(
const Vector &);
202 inline std::string toString(
void)
const 203 {
return to_string(*
this); }
205 boost::python::list
getPyList(
void)
const;
206 void setPyList(
const boost::python::list &);
207 boost::python::dict
getPyDict(
void)
const;
208 void setPyDict(
const boost::python::dict &);
235 std::ostream &operator<<(std::ostream &,
const Vector &);
236 std::string to_string(
const Vector &);
245 {
return Size()*
sizeof(double); }
260 {
return theData + sz; }
264 {
return (theData==
nullptr); }
270 for(
int i=0; i<sz; i++)
278 for(
int i=0; i<sz; i++)
279 if(std::isnan(theData[i]))
290 const int retval=
resize(newSize);
306 <<
"; loc " << x <<
" outside range [0, " 307 << sz-1 << std::endl;
308 return VECTOR_NOT_VALID_ENTRY;
323 if (x < 0 || x >= sz)
326 <<
"; loc " << x <<
" outside range [0, " << sz-1
328 return VECTOR_NOT_VALID_ENTRY;
334 template <
class TNSR>
340 std::cerr <<
"XC::Vector::operator=() - BJtensor must be of rank 2\n";
346 std::cerr <<
"XC::Vector::operator=() - BJtensor must have square dimensions\n";
350 if(dim != 2 || dim != 3 || dim != 1)
352 std::cerr <<
"XC::Vector::operator=() - BJtensor must be of dimension 2 or 3\n";
360 std::cerr <<
"Vector::operator=() - Vector size must be 1\n";
369 std::cerr <<
"Vector::operator=() - Vector size must be 3\n";
380 std::cerr <<
"Vector::operator=() - Vector size must be 6\n";
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: Vector.cpp:1379
Vector normalize(const Vector &)
Returns the normalized vector (euclidean norm).
Definition: Vector.cpp:367
Float vector abstraction.
Definition: Vector.h:94
virtual double & at(const size_t &f)
Returns the element at the row being passed as parameter.
Definition: Vector.cpp:917
Vector operator*(double fact) const
The + operator returns a vector of the same size as current, whose components are: return(i)= theData...
Definition: Vector.cpp:1136
m_double vector_to_m_double(const Vector &)
Convierte el vector en un m_double.
Definition: Vector.cpp:1525
void write(std::ofstream &)
Write vector on a binary file.
Definition: Vector.cpp:1339
Vector & operator/=(double fact)
The /= operator divides each element of the vector by fact, theData[i]= theData[i]/fact.
Definition: Vector.cpp:1091
double Norm(void) const
Return the norm of vector.
Definition: Vector.cpp:790
void read(std::ifstream &)
Read vector from a binary file.
Definition: Vector.cpp:1387
int resize(int newSize)
Changes vector size.
Definition: Vector.cpp:247
int setData(double *newData, int size)
Help to construct a Vector of order size whose data will be stored in the array pointed to by data...
Definition: Vector.cpp:228
int getIndexMaxValue(void) const
Returns the index of the maximum of the values of the components.
Definition: Vector.cpp:805
Vector operator+(double fact) const
The + operator returns a Vector of the same size as current, whose components are: return(i)= theData...
Definition: Vector.cpp:1108
Vector & operator*=(double fact)
The *= operator multiplies each element by the factor.
Definition: Vector.cpp:1078
Vector of integers.
Definition: ID.h:95
void Zero(void)
Zeros out the Vector, i.e.
Definition: Vector.h:268
double operator^(const Vector &V) const
Method to perform (Vector)transposed * vector.
Definition: Vector.cpp:1289
Vector operator/(double fact) const
The + operator returns a vector of the same size as current, whose components are return(i)= theData[...
Definition: Vector.cpp:1153
TCP_Socket is a sub-class of channel.
Definition: TCP_Socket.h:71
const double & operator()(int x) const
Returns the data at location x in the Vector.
Definition: Vector.h:299
bool isnan(void) const
Return true if one of the component is not a number.
Definition: Vector.h:275
int addVector(double factThis, const Vector &other, double factOther)
To add a factor fact times the Vector other to the current Vector.
Definition: Vector.cpp:382
Vector en dos dimensiones.
Definition: Vector2d.h:41
virtual ~Vector(void)
Destructor, free memory.
Definition: Vector.cpp:219
Vector NormalizedInf(void) const
Returns the normalized vector (infinity norm).
Definition: Vector.cpp:359
Vector & operator+=(double fact)
The += operator adds fact to each element of the vector, data[i]= data[i]+fact.
Definition: Vector.cpp:1056
int getIndexMaxAbsValue(void) const
Returns the index of the maximum of the values of the components.
Definition: Vector.cpp:849
int reset(const int &newSize)
Resize the vector and set all components equal to 0.
Definition: Vector.h:288
int Size(void) const
Returns the size of the Vector.
Definition: Vector.h:240
TCP_SocketNoDelay is a sub-class of channel.
Definition: TCP_SocketNoDelay.h:73
int getIndexMinValue(void) const
Returns the index of the maximum of the values of the components.
Definition: Vector.cpp:827
Vector operator-(void) const
Unary minus operator.
Definition: Vector.cpp:1170
int NormalizeInf(void)
Normalize the vector using the infinity norm.
Definition: Vector.cpp:335
System of equations base class.
Definition: SystemOfEqn.h:90
Vector & operator=(const Vector &V)
the assignment operator, This is assigned to be a copy of V.
Definition: Vector.cpp:1035
virtual std::string getClassName(void) const
Returns demangled class name.
Definition: EntityWithOwner.cc:90
iterator begin(void)
Iterator that points to the first vector component.
Definition: Vector.h:256
double Norm2(void) const
Returns the square of the vector modulus.
Definition: Vector.cpp:775
int Normalize(void)
Normalizes the vector using the euclidean norm.
Definition: Vector.cpp:319
int getNumBytes(void) const
Number of bytes occupied by the vector.
Definition: Vector.h:244
Objet that can execute python scripts.
Definition: CommandEntity.h:40
bool isEmpty(void) const
Return true if the vector has no data.
Definition: Vector.h:263
Vector(void)
Default constructor, sets size= 0;.
Definition: Vector.cpp:117
MPI_Channel is a sub-class of channel.
Definition: MPI_Channel.h:70
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: Vector.cpp:1371
double NormInf(void) const
Returns the maximum of the absolute values of the components (infinite norm).
Definition: Vector.cpp:795
iterator end(void)
Iterator that points one past the last vector component.
Definition: Vector.h:259
virtual bool CheckIndice0(const size_t &i) const
Check the index being passed as parameter.
Definition: Vector.cpp:943
Message between processes.
Definition: Message.h:77
boost::python::list getPyList(void) const
Return the vector values in a Python list.
Definition: Vector.cpp:1350
void setPyList(const boost::python::list &)
Populate the vector with the values of the given list.
Definition: Vector.cpp:1360
std::vector< double > vector_to_std_vector(const Vector &)
Convierte el vector en un std::vector<double>.
Definition: Vector.cpp:1515
Vector getComponents(const ID &) const
Returns a vector with the specified subset of components.
Definition: Vector.cpp:1486
int getIndexMinAbsValue(void) const
Returns the index of the maximum of the values of the components.
Definition: Vector.cpp:871
Vector Normalized(void) const
Returns the normalized vector (euclidean norm).
Definition: Vector.cpp:351
Matrix prod_tensor(const Vector &, const Vector &)
Producto tensorial de dos tensores de primer orden.
Definition: Vector.cpp:1403
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
const double & operator[](int x) const
If debug flag is on, safely get the data at location x in the Vector.
Definition: Vector.cpp:977
const double * getDataPtr(void) const
Return a pointer to the float date.
Definition: Vector.h:248
Matrix of floats.
Definition: Matrix.h:111
void addComponents(const Vector &, const ID &)
Sums the specified values to the specified set of vector's components.
Definition: Vector.cpp:1506
void putComponents(const Vector &, const ID &)
Assigns the specified values to the specified set of vector's components.
Definition: Vector.cpp:1497
Vector normalize_inf(const Vector &)
Returns the normalized vector (infinity norm).
Definition: Vector.cpp:371
int addMatrixVector(double factThis, const Matrix &m, const Vector &v, double factOther)
To add a factor fact times the Vector formed by the product of the matrix m and the Vector v to the c...
Definition: Vector.cpp:480
DP_Socket is a sub-class of channel.
Definition: UDP_Socket.h:76
Vector & operator-=(double fact)
The -= operator subtracts fact from each element of the vector, data[i]= data[i]-fact.
Definition: Vector.cpp:1069
Vector en tres dimensiones.
Definition: Vector3d.h:39
int Assemble(const Vector &V, const ID &l, double fact=1.0)
Method to assemble into this vector the Vector V using the ID l.
Definition: Vector.cpp:288