MFEM v2.0
Public Member Functions | Protected Attributes | Friends
Vector Class Reference

Vector data type. More...

#include <vector.hpp>

Inheritance diagram for Vector:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Vector ()
 Default constructor for Vector. Sets size = 0 and data = NULL.
 Vector (const Vector &)
 Copy constructor.
 Vector (int s)
 Creates vector of size s.
 Vector (double *_data, int _size)
void Load (istream **in, int np, int *dim)
 Reads a vector from multpile files.
void Load (istream &in, int Size)
 Load a vector from an input stream.
void Load (istream &in)
 Load a vector from an input stream.
void SetSize (int s)
 Resizes the vector if the new size is different.
void SetData (double *d)
void SetDataAndSize (double *d, int s)
void MakeDataOwner ()
void Destroy ()
 Destroy a vector.
int Size () const
 Returns the size of the vector.
double * GetData () const
 operator double * ()
 operator const double * () const
void StealData (double **p)
 Changes the ownership of the the data.
double & Elem (int i)
 Sets value in vector. Index i = 0 .. size-1.
const double & Elem (int i) const
 Sets value in vector. Index i = 0 .. size-1.
double & operator() (int i)
 Sets value in vector. Index i = 0 .. size-1.
const double & operator() (int i) const
 Sets value in vector. Index i = 0 .. size-1.
double operator* (const double *) const
double operator* (const Vector &v) const
 Return the inner-product.
Vectoroperator= (const Vector &v)
 Redefine '=' for vector = vector.
Vectoroperator= (double value)
 Redefine '=' for vector = constant.
Vectoroperator*= (double c)
Vectoroperator/= (double c)
Vectoroperator-= (double c)
Vectoroperator-= (const Vector &v)
Vectoroperator+= (const Vector &v)
VectorAdd (const double a, const Vector &Va)
 (*this) += a * Va
VectorSet (const double a, const Vector &x)
 (*this) = a * x
void SetVector (const Vector &v, int offset)
void Neg ()
 (*this) = -(*this)
void GetSubVector (const Array< int > &dofs, Vector &elemvect) const
void GetSubVector (const Array< int > &dofs, double *elem_data) const
void SetSubVector (const Array< int > &dofs, const Vector &elemvect)
void SetSubVector (const Array< int > &dofs, double *elem_data)
void AddElementVector (const Array< int > &dofs, const Vector &elemvect)
 Add (element) subvector to the vector.
void AddElementVector (const Array< int > &dofs, double *elem_data)
void AddElementVector (const Array< int > &dofs, const double a, const Vector &elemvect)
void Print (ostream &out=cout, int width=8) const
 Prints vector to stream out.
void Print_HYPRE (ostream &out) const
 Prints vector to stream out in HYPRE_Vector format.
void Randomize (int seed=0)
 Set random values in the vector.
double Norml2 ()
 Returns the l2 norm of the vector.
double Normlinf ()
 Returns the l_infinity norm of the vector.
double Norml1 ()
 Returns the l_1 norm of the vector.
double Max ()
 Returns the maximal element of the vector.
double Min ()
 Returns the minimal element of the vector.
double DistanceTo (const double *p) const
 Compute the Euclidian distance to another vector.
 ~Vector ()
 Destroys vector.

Protected Attributes

int size
int allocsize
double * data

Friends

void swap (Vector *v1, Vector *v2)
 Swap v1 and v2.
void add (const Vector &v1, const Vector &v2, Vector &v)
 Do v = v1 + v2.
void add (const Vector &v1, double alpha, const Vector &v2, Vector &v)
 Do v = v1 + alpha * v2.
void add (const double a, const Vector &x, const Vector &y, Vector &z)
 z = a * (x + y)
void add (const double a, const Vector &x, const double b, const Vector &y, Vector &z)
 z = a * x + b * y
void subtract (const Vector &v1, const Vector &v2, Vector &v)
 Do v = v1 - v2.
void subtract (const double a, const Vector &x, const Vector &y, Vector &z)
 z = a * (x - y)

Detailed Description

Vector data type.

Definition at line 21 of file vector.hpp.


Constructor & Destructor Documentation

Vector::Vector ( ) [inline]

Default constructor for Vector. Sets size = 0 and data = NULL.

Definition at line 31 of file vector.hpp.

References allocsize, data, and size.

Vector::Vector ( const Vector v)

Copy constructor.

Definition at line 22 of file vector.cpp.

References allocsize, data, size, and Size().

Vector::Vector ( int  s) [inline, explicit]

Creates vector of size s.

Definition at line 184 of file vector.hpp.

References allocsize, data, and size.

Vector::Vector ( double *  _data,
int  _size 
) [inline]

Definition at line 39 of file vector.hpp.

References allocsize, data, and size.

Vector::~Vector ( ) [inline]

Destroys vector.

Definition at line 241 of file vector.hpp.

References allocsize, and data.


Member Function Documentation

Vector & Vector::Add ( const double  a,
const Vector Va 
)

(*this) += a * Va

Definition at line 157 of file vector.cpp.

References data, mfem_error(), and size.

Referenced by BiCGSTAB(), GridFunction::ProjectBdrCoefficientNormal(), and Update().

void Vector::AddElementVector ( const Array< int > &  dofs,
const Vector elemvect 
)

Add (element) subvector to the vector.

Definition at line 425 of file vector.cpp.

References data, and Array< T >::Size().

Referenced by LinearForm::Assemble(), and ComputeFlux().

void Vector::AddElementVector ( const Array< int > &  dofs,
double *  elem_data 
)

Definition at line 436 of file vector.cpp.

References data, and Array< T >::Size().

void Vector::AddElementVector ( const Array< int > &  dofs,
const double  a,
const Vector elemvect 
)

Definition at line 447 of file vector.cpp.

References data, and Array< T >::Size().

void Vector::Destroy ( ) [inline]

Destroy a vector.

Definition at line 213 of file vector.hpp.

References allocsize, data, and size.

Referenced by Mesh::Load().

double Vector::DistanceTo ( const double *  p) const

Compute the Euclidian distance to another vector.

Definition at line 553 of file vector.cpp.

References data, Distance(), and size.

double & Vector::Elem ( int  i)

Sets value in vector. Index i = 0 .. size-1.

Definition at line 63 of file vector.cpp.

References operator()().

const double & Vector::Elem ( int  i) const

Sets value in vector. Index i = 0 .. size-1.

Definition at line 68 of file vector.cpp.

References operator()().

double* Vector::GetData ( ) const [inline]
void Vector::GetSubVector ( const Array< int > &  dofs,
double *  elem_data 
) const

Definition at line 392 of file vector.cpp.

References data, and Array< T >::Size().

void Vector::GetSubVector ( const Array< int > &  dofs,
Vector elemvect 
) const
void Vector::Load ( istream &  in,
int  Size 
)

Load a vector from an input stream.

Definition at line 55 of file vector.cpp.

References data, SetSize(), and size.

void Vector::Load ( istream **  in,
int  np,
int *  dim 
)

Reads a vector from multpile files.

Definition at line 39 of file vector.cpp.

References data, and SetSize().

Referenced by GridFunction::GridFunction(), KnotVector::KnotVector(), and NURBSExtension::NURBSExtension().

void Vector::Load ( istream &  in) [inline]

Load a vector from an input stream.

Definition at line 49 of file vector.hpp.

References Load().

Referenced by Load().

void Vector::MakeDataOwner ( ) [inline]

Definition at line 59 of file vector.hpp.

References allocsize.

double Vector::Max ( )

Returns the maximal element of the vector.

Definition at line 531 of file vector.cpp.

References data, and size.

double Vector::Min ( )

Returns the minimal element of the vector.

Definition at line 542 of file vector.cpp.

References data, and size.

void Vector::Neg ( )

(*this) = -(*this)

Definition at line 196 of file vector.cpp.

References data, and size.

double Vector::Norml1 ( )

Returns the l_1 norm of the vector.

Definition at line 521 of file vector.cpp.

References data, and size.

Referenced by GridFunction::ComputeW11Error().

double Vector::Norml2 ( )

Returns the l2 norm of the vector.

Definition at line 505 of file vector.cpp.

double Vector::Normlinf ( )

Returns the l_infinity norm of the vector.

Definition at line 510 of file vector.cpp.

References data, and size.

Referenced by GridFunction::ComputeMaxError().

Vector::operator const double * ( ) const [inline]

Definition at line 73 of file vector.hpp.

References data.

Vector::operator double * ( ) [inline]

Definition at line 71 of file vector.hpp.

References data.

double & Vector::operator() ( int  i) [inline]

Sets value in vector. Index i = 0 .. size-1.

Definition at line 221 of file vector.hpp.

References data, mfem_error(), and size.

Referenced by Elem().

const double & Vector::operator() ( int  i) const [inline]

Sets value in vector. Index i = 0 .. size-1.

Definition at line 231 of file vector.hpp.

References data, mfem_error(), and size.

double Vector::operator* ( const double *  v) const

Definition at line 73 of file vector.cpp.

References data, and size.

double Vector::operator* ( const Vector v) const

Return the inner-product.

Definition at line 86 of file vector.cpp.

References data, mfem_error(), operator*(), and size.

Referenced by operator*().

Vector & Vector::operator*= ( double  c)

Definition at line 113 of file vector.cpp.

References data, and size.

Vector & Vector::operator+= ( const Vector v)

Definition at line 146 of file vector.cpp.

References data, mfem_error(), and size.

Vector & Vector::operator-= ( double  c)

Definition at line 128 of file vector.cpp.

References data, and size.

Vector & Vector::operator-= ( const Vector v)

Definition at line 135 of file vector.cpp.

References data, mfem_error(), and size.

Vector & Vector::operator/= ( double  c)

Definition at line 120 of file vector.cpp.

References data, and size.

Vector & Vector::operator= ( const Vector v)

Redefine '=' for vector = vector.

Reimplemented in GridFunction, and ParGridFunction.

Definition at line 96 of file vector.cpp.

References data, SetSize(), size, and Size().

Referenced by LinearForm::Assemble().

Vector & Vector::operator= ( double  value)

Redefine '=' for vector = constant.

Reimplemented in GridFunction, ParGridFunction, and HypreParVector.

Definition at line 104 of file vector.cpp.

References data, and size.

void Vector::Print ( ostream &  out = cout,
int  width = 8 
) const

Prints vector to stream out.

Definition at line 459 of file vector.cpp.

References data, and size.

Referenced by PCG(), NURBSExtension::Print(), KnotVector::Print(), and GridFunction::Save().

void Vector::Print_HYPRE ( ostream &  out) const

Prints vector to stream out in HYPRE_Vector format.

Definition at line 475 of file vector.cpp.

References data, and size.

void Vector::Randomize ( int  seed = 0)

Set random values in the vector.

Reimplemented in HypreParVector.

Definition at line 490 of file vector.cpp.

References data, and size.

Vector & Vector::Set ( const double  a,
const Vector x 
)

(*this) = a * x

Definition at line 171 of file vector.cpp.

References data, mfem_error(), and size.

Referenced by add().

void Vector::SetData ( double *  d) [inline]
void Vector::SetDataAndSize ( double *  d,
int  s 
) [inline]
void Vector::SetSize ( int  s) [inline]

Resizes the vector if the new size is different.

Definition at line 198 of file vector.hpp.

References allocsize, data, and size.

Referenced by ElasticityIntegrator::AssembleElementMatrix(), DivDivIntegrator::AssembleElementMatrix(), ConvectionIntegrator::AssembleElementMatrix(), VectorDivergenceIntegrator::AssembleElementMatrix2(), VectorFEMassIntegrator::AssembleElementMatrix2(), DerivativeIntegrator::AssembleElementMatrix2(), VectorFEDivergenceIntegrator::AssembleElementMatrix2(), MassIntegrator::AssembleElementMatrix2(), VectorFEBoundaryFluxLFIntegrator::AssembleRHSElementVect(), VectorBoundaryFluxLFIntegrator::AssembleRHSElementVect(), VectorFEDomainLFIntegrator::AssembleRHSElementVect(), VectorBoundaryLFIntegrator::AssembleRHSElementVect(), VectorDomainLFIntegrator::AssembleRHSElementVect(), BoundaryLFIntegrator::AssembleRHSElementVect(), DomainLFIntegrator::AssembleRHSElementVect(), Poly_1D::Basis::Basis(), DiffusionIntegrator::ComputeElementFlux(), GridFunction::ComputeH1Error(), GridFunction::ComputeL1Error(), GridFunction::ComputeL2Error(), GridFunction::ComputeMaxError(), GridFunction::ComputeW11Error(), DenseMatrixEigensystem::DenseMatrixEigensystem(), DetOfLinComb(), KnotVector::Difference(), dsyev_Eigensystem(), dsyevr_Eigensystem(), VectorRestrictedCoefficient::Eval(), VectorArrayCoefficient::Eval(), VectorFunctionCoefficient::Eval(), GridFunction::GetBdrValuesFrom(), DenseMatrix::GetColumn(), GridFunction::GetDerivative(), GridFunction::GetElementAverages(), GridFunction::GetNodalValues(), GetSubVector(), GridFunction::GetValues(), GridFunction::GetValuesFrom(), GridFunction::GetVectorFieldNodalValues(), GridFunction::GetVectorValue(), Mesh::GetVertices(), GridFunction::GridFunction(), H1_HexahedronElement::H1_HexahedronElement(), H1_QuadrilateralElement::H1_QuadrilateralElement(), H1_SegmentElement::H1_SegmentElement(), H1_TetrahedronElement::H1_TetrahedronElement(), H1_TriangleElement::H1_TriangleElement(), FiniteElementSpace::H2L_GlobalRestrictionMatrix(), DenseMatrixSVD::Init(), KnotVector::KnotVector(), L2_HexahedronElement::L2_HexahedronElement(), L2_QuadrilateralElement::L2_QuadrilateralElement(), L2_SegmentElement::L2_SegmentElement(), L2_TetrahedronElement::L2_TetrahedronElement(), L2_TriangleElement::L2_TriangleElement(), Lagrange1DFiniteElement::Lagrange1DFiniteElement(), LagrangeHexFiniteElement::LagrangeHexFiniteElement(), Load(), Mesh::Load(), ND_HexahedronElement::ND_HexahedronElement(), ND_QuadrilateralElement::ND_QuadrilateralElement(), ND_TetrahedronElement::ND_TetrahedronElement(), ND_TriangleElement::ND_TriangleElement(), NURBSExtension::NURBSExtension(), NURBSFiniteElement::NURBSFiniteElement(), operator=(), Mesh::PrintCharacteristics(), GridFunction::ProjectBdrCoefficientNormal(), GridFunction::ProjectBdrCoefficientTangent(), GridFunction::ProjectCoefficient(), PWConstCoefficient::PWConstCoefficient(), PWConstCoefficient::Read(), RT_HexahedronElement::RT_HexahedronElement(), RT_QuadrilateralElement::RT_QuadrilateralElement(), RT_TetrahedronElement::RT_TetrahedronElement(), RT_TriangleElement::RT_TriangleElement(), NURBSExtension::Set2DSolutionVector(), NURBSExtension::Set3DSolutionVector(), DenseMatrix::SingularValues(), IsoparametricTransformation::Transform(), KnotVector::UniformRefinement(), LinearForm::Update(), GridFunction::Update(), and ZZErrorEstimator().

void Vector::SetSubVector ( const Array< int > &  dofs,
const Vector elemvect 
)
void Vector::SetSubVector ( const Array< int > &  dofs,
double *  elem_data 
)

Definition at line 414 of file vector.cpp.

References data, and Array< T >::Size().

void Vector::SetVector ( const Vector v,
int  offset 
)

Definition at line 182 of file vector.cpp.

References data, mfem_error(), size, and Size().

int Vector::Size ( ) const [inline]
void Vector::StealData ( double **  p) [inline]

Changes the ownership of the the data.

Definition at line 76 of file vector.hpp.

References data, and size.


Friends And Related Function Documentation

void add ( const Vector v1,
const Vector v2,
Vector v 
) [friend]

Do v = v1 + v2.

Definition at line 216 of file vector.cpp.

void add ( const double  a,
const Vector x,
const Vector y,
Vector z 
) [friend]

z = a * (x + y)

Definition at line 257 of file vector.cpp.

void add ( const double  a,
const Vector x,
const double  b,
const Vector y,
Vector z 
) [friend]

z = a * x + b * y

Definition at line 287 of file vector.cpp.

void add ( const Vector v1,
double  alpha,
const Vector v2,
Vector v 
) [friend]

Do v = v1 + alpha * v2.

Definition at line 230 of file vector.cpp.

void subtract ( const Vector v1,
const Vector v2,
Vector v 
) [friend]

Do v = v1 - v2.

Definition at line 330 of file vector.cpp.

void subtract ( const double  a,
const Vector x,
const Vector y,
Vector z 
) [friend]

z = a * (x - y)

Definition at line 348 of file vector.cpp.

void swap ( Vector v1,
Vector v2 
) [friend]

Swap v1 and v2.

Definition at line 202 of file vector.cpp.


Member Data Documentation

int Vector::allocsize [protected]

Definition at line 25 of file vector.hpp.

Referenced by Destroy(), MakeDataOwner(), SetDataAndSize(), SetSize(), swap(), Vector(), and ~Vector().

double* Vector::data [protected]
int Vector::size [protected]

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines