17 #include "../general/array.hpp"
26 inline int CheckFinite(
const double *v,
const int n);
51 void Load (std::istream ** in,
int np,
int * dim);
54 void Load(std::istream &in,
int Size);
57 void Load(std::istream &in) {
int s; in >> s;
Load (in, s); }
82 inline operator double *() {
return data; }
84 inline operator const double *()
const {
return data; }
96 double &
Elem (
int i);
99 const double &
Elem (
int i)
const;
105 inline const double &
operator() (
int i)
const;
154 friend void add (
const double a,
const Vector &x,
180 void Print(std::ostream & out = std::cout,
int width = 8)
const;
194 double Normlp(
double p)
const;
220 for (
int i = 0; i < n; i++)
225 if (!std::isfinite(v[i]))
239 data =
new double[s];
260 data =
new double[s];
274 if (
data == 0 || i < 0 || i >=
size)
284 if (
data == 0 || i < 0 || i >=
size)
297 inline double Distance(
const double *x,
const double *y,
const int n)
302 for (
int i = 0; i < n; i++)
303 d += (x[i]-y[i])*(x[i]-y[i]);
void SetVector(const Vector &v, int offset)
int CheckFinite(const double *v, const int n)
Vector()
Default constructor for Vector. Sets size = 0 and data = NULL.
friend void swap(Vector *v1, Vector *v2)
Swap v1 and v2.
void NewDataAndSize(double *d, int s)
double & Elem(int i)
Sets value in vector. Index i = 0 .. size-1.
void Print(std::ostream &out=std::cout, int width=8) const
Prints vector to stream out.
void SetSize(int s)
Resizes the vector if the new size is different.
friend void subtract(const Vector &v1, const Vector &v2, Vector &v)
Do v = v1 - v2.
double Norml2() const
Returns the l2 norm of the vector.
double & operator()(int i)
Sets value in vector. Index i = 0 .. size-1.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
void StealData(double **p)
Changes the ownership of the data; after the call the Vector is empty.
int Size() const
Returns the size of the vector.
double Normlinf() const
Returns the l_infinity norm of the vector.
void Randomize(int seed=0)
Set random values in the vector.
double operator*(const double *) const
Vector & operator=(const double *v)
void Load(std::istream **in, int np, int *dim)
Reads a vector from multiple files.
double Normlp(double p) const
Returns the l_p norm of the vector.
void median(const Vector &lo, const Vector &hi)
v = median(v,lo,hi) entrywise. Implementation assumes lo <= hi.
void Load(std::istream &in)
Load a vector from an input stream.
double * StealData()
Changes the ownership of the data; after the call the Vector is empty.
void AddElementVector(const Array< int > &dofs, const Vector &elemvect)
Add (element) subvector to the vector.
Vector & operator/=(double c)
double DistanceTo(const double *p) const
Compute the Euclidian distance to another vector.
Vector(double *_data, int _size)
Vector & operator*=(double c)
double Min() const
Returns the minimal element of the vector.
double Norml1() const
Returns the l_1 norm of the vector.
double Distance(const double *x, const double *y, const int n)
void mfem_error(const char *msg)
void SetSubVector(const Array< int > &dofs, const Vector &elemvect)
void Print_HYPRE(std::ostream &out) const
Prints vector to stream out in HYPRE_Vector format.
void SetDataAndSize(double *d, int s)
Vector & Set(const double a, const Vector &x)
(*this) = a * x
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
double Max() const
Returns the maximal element of the vector.
void Destroy()
Destroy a vector.
Vector & operator-=(double c)
friend void add(const Vector &v1, const Vector &v2, Vector &v)
Do v = v1 + v2.
Vector & operator+=(const Vector &v)
double Sum() const
Return the sum of the vector entries.
~Vector()
Destroys vector.
void Neg()
(*this) = -(*this)