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);
112 Vector(
const double &,
const double &,
const double &);
114 Vector(
double *data,
int size);
115 explicit Vector(
const boost::python::list &);
118 iterator
begin(
void);
121 int setData(
double *newData,
int size);
126 double Norm2(
void)
const;
127 double Norm(
void)
const;
128 double pNorm(
int p)
const;
130 int Size(
void)
const;
134 bool isnan(
void)
const;
135 int reset(
const int &newSize);
143 int addMatrixTransposeVector(
double factThis,
const Matrix &m,
const Vector &v,
double factOther);
147 virtual double &
at(
const size_t &f);
149 virtual const double &
at(
const size_t &f)
const;
161 template <
class TNSR>
183 double dot(
const Vector &)
const;
187 int Extract(
const Vector &V,
int init_row,
double fact = 1.0);
193 void write(std::ofstream &);
194 void read(std::ifstream &);
195 friend std::ostream &operator<<(std::ostream &,
const Vector &);
196 friend std::string to_string(
const Vector &);
197 inline std::string toString(
void)
const 198 {
return to_string(*
this); }
200 boost::python::list
getPyList(
void)
const;
201 void setPyList(
const boost::python::list &);
202 boost::python::dict
getPyDict(
void)
const;
203 void setPyDict(
const boost::python::dict &);
230 std::ostream &operator<<(std::ostream &,
const Vector &);
231 std::string to_string(
const Vector &);
240 {
return Size()*
sizeof(double); }
255 {
return theData + sz; }
259 {
return (theData==
nullptr); }
265 for(
int i=0; i<sz; i++)
273 for(
int i=0; i<sz; i++)
274 if(std::isnan(theData[i]))
285 const int retval=
resize(newSize);
301 <<
"; loc " << x <<
" outside range [0, " 302 << sz-1 << std::endl;
303 return VECTOR_NOT_VALID_ENTRY;
318 if (x < 0 || x >= sz)
321 <<
"; loc " << x <<
" outside range [0, " << sz-1
323 return VECTOR_NOT_VALID_ENTRY;
329 template <
class TNSR>
335 std::cerr <<
"XC::Vector::operator=() - BJtensor must be of rank 2\n";
341 std::cerr <<
"XC::Vector::operator=() - BJtensor must have square dimensions\n";
345 if(dim != 2 || dim != 3 || dim != 1)
347 std::cerr <<
"XC::Vector::operator=() - BJtensor must be of dimension 2 or 3\n";
355 std::cerr <<
"Vector::operator=() - Vector size must be 1\n";
364 std::cerr <<
"Vector::operator=() - Vector size must be 3\n";
375 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:1281
Vector normalize(const Vector &)
Returns the normalized vector (euclidean norm).
Definition: Vector.cpp:357
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:819
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:1038
m_double vector_to_m_double(const Vector &)
Convierte el vector en un m_double.
Definition: Vector.cpp:1427
void write(std::ofstream &)
Write vector on a binary file.
Definition: Vector.cpp:1241
Vector & operator/=(double fact)
The /= operator divides each element of the vector by fact, theData[i]= theData[i]/fact.
Definition: Vector.cpp:993
double Norm(void) const
Return the norm of vector.
Definition: Vector.cpp:780
void read(std::ifstream &)
Read vector from a binary file.
Definition: Vector.cpp:1289
int resize(int newSize)
Changes vector size.
Definition: Vector.cpp:237
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:218
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:1010
Vector & operator*=(double fact)
The *= operator multiplies each element by the factor.
Definition: Vector.cpp:980
Vector of integers.
Definition: ID.h:95
void Zero(void)
Zeros out the Vector, i.e.
Definition: Vector.h:263
double operator^(const Vector &V) const
Method to perform (Vector)transposed * vector.
Definition: Vector.cpp:1191
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:1055
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:294
bool isnan(void) const
Return true if one of the component is not a number.
Definition: Vector.h:270
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:372
Vector en dos dimensiones.
Definition: Vector2d.h:40
virtual ~Vector(void)
Destructor, free memory.
Definition: Vector.cpp:209
Vector NormalizedInf(void) const
Returns the normalized vector (infinity norm).
Definition: Vector.cpp:349
Vector & operator+=(double fact)
The += operator adds fact to each element of the vector, data[i]= data[i]+fact.
Definition: Vector.cpp:958
int reset(const int &newSize)
Resize the vector and set all components equal to 0.
Definition: Vector.h:283
int Size(void) const
Returns the size of the Vector.
Definition: Vector.h:235
TCP_SocketNoDelay is a sub-class of channel.
Definition: TCP_SocketNoDelay.h:73
Vector operator-(void) const
Unary minus operator.
Definition: Vector.cpp:1072
int NormalizeInf(void)
Normalize the vector using the infinity norm.
Definition: Vector.cpp:325
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:937
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:251
double Norm2(void) const
Returns the square of the vector modulus.
Definition: Vector.cpp:765
int Normalize(void)
Normalizes the vector using the euclidean norm.
Definition: Vector.cpp:309
int getNumBytes(void) const
Number of bytes occupied by the vector.
Definition: Vector.h:239
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:258
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:1273
double NormInf(void) const
Returns the maximum of the absolute values of the components (infinite norm).
Definition: Vector.cpp:785
iterator end(void)
Iterator that points one past the last vector component.
Definition: Vector.h:254
virtual bool CheckIndice0(const size_t &i) const
Check the index being passed as parameter.
Definition: Vector.cpp:845
Message between processes.
Definition: Message.h:77
boost::python::list getPyList(void) const
Return the vector values in a Python list.
Definition: Vector.cpp:1252
void setPyList(const boost::python::list &)
Populate the vector with the values of the given list.
Definition: Vector.cpp:1262
std::vector< double > vector_to_std_vector(const Vector &)
Convierte el vector en un std::vector<double>.
Definition: Vector.cpp:1417
Vector getComponents(const ID &) const
Returns a vector with the specified subset of components.
Definition: Vector.cpp:1388
Vector Normalized(void) const
Returns the normalized vector (euclidean norm).
Definition: Vector.cpp:341
Matrix prod_tensor(const Vector &, const Vector &)
Producto tensorial de dos tensores de primer orden.
Definition: Vector.cpp:1305
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:879
const double * getDataPtr(void) const
Return a pointer to the float date.
Definition: Vector.h:243
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:1408
void putComponents(const Vector &, const ID &)
Assigns the specified values to the specified set of vector's components.
Definition: Vector.cpp:1399
Vector normalize_inf(const Vector &)
Returns the normalized vector (infinity norm).
Definition: Vector.cpp:361
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:470
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:971
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:278