Structured3DVector< T > Class Template Reference

#include <Structured3DVector.hpp>

Inheritance diagram for Structured3DVector< T >:

Inheritance graph
[legend]
Collaboration diagram for Structured3DVector< T >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef T ValueType
 T ValueType Used to be able to access to T using typename.

Public Member Functions

size_t nx () const
size_t ny () const
size_t nz () const
const Array3DShapeshape () const
const T & operator() (const size_t &i, const size_t &j, const size_t &k) const
T & operator() (const size_t &i, const size_t &j, const size_t &k)
Structured3DVector< T > & operator= (const T &t)
Structured3DVector< T > & operator= (const Structured3DVector< T > &v)
const Structured3DVector< T > & operator= (const Vector< T > &v)
void resize (const Array3DShape &shape)
 Structured3DVector (const size_t &nx, const size_t &ny, const size_t &nz)
 Structured3DVector (const Array3DShape &shape)
 Structured3DVector (const Structured3DVector &v)
 ~Structured3DVector ()
const size_t & size () const
 Read-only access to the size of the vector.
size_t number (T const &e) const
 Finds the number of an element of the vector.
const T & operator[] (const size_t &i) const
 Read-only access to the ith __values of the vector.
T & operator[] (const size_t &i)
 Access to the ith element of the vector.
const T & operator() (const size_t &i) const
T & operator() (const size_t &i)
void resize (const size_t &newSize)
Vector< T > operator* (const T &t) const
real_t operator* (const Vector< T > &V) const
 operator* overloading. Scalar product.
template<class T2>
const Vector< T > & operator*= (const T2 &t)
 operator*= overloading. The vector is multiplied by t.
Vector< T > operator+ (const Vector< T > &V) const
Vector< T > operator- (const Vector< T > &V) const
const Vector< T > & operator+= (const Vector< T > &V)
 operator+= overloading. Addes V to the vector.
const Vector< T > & operator+= (const T &t)
 operator+= overloading. Addes V to the vector.
const Vector< T > & operator-= (const Vector< T > &V)
 operator-= overloading. Substractes V to the vector.

Protected Attributes

size_t __size
 The number of elements of the vector.
T *__restrict __values
 The elements of the vector.

Private Member Functions

void __buildView ()
void __clean ()

Private Attributes

T *** __structured3dView
 allows access to the data using the structured organization.
Array3DShape __shape
 The vector shape.

Friends

std::ostream & operator<< (std::ostream &os, const Vector< T > &V)
 writes a vector in a stream.
Vector< T > operator* (const T &t, const Vector< T > &V)
real_t Norm (const Vector< T > &v)


Detailed Description

template<typename T>
class Structured3DVector< T >

Definition at line 37 of file Structured3DVector.hpp.


Member Typedef Documentation

template<typename T>
typedef T Vector< T >::ValueType [inherited]

T ValueType Used to be able to access to T using typename.

Definition at line 51 of file Vector.hpp.


Constructor & Destructor Documentation

template<typename T>
Structured3DVector< T >::Structured3DVector ( const size_t &  nx,
const size_t &  ny,
const size_t &  nz 
) [inline]

Constructor

Parameters:
nx number of elements in x direction
ny number of elements in y direction
nz number of elements in z direction

Definition at line 198 of file Structured3DVector.hpp.

00199     : Vector<T>(nx*ny*nz),
00200       __shape(nx,ny,nz)
00201   {
00202     this->__buildView();
00203   }

template<typename T>
Structured3DVector< T >::Structured3DVector ( const Array3DShape shape  )  [inline]

Constructor

Parameters:
shape given shape of the Structured3DVector

Definition at line 210 of file Structured3DVector.hpp.

00211     : Vector<T>(shape.size()),
00212       __shape(shape)
00213   {
00214     this->__buildView();
00215   }

template<typename T>
Structured3DVector< T >::Structured3DVector ( const Structured3DVector< T > &  v  )  [inline]

Copy constructor

Parameters:
v given Structured3DVector

Definition at line 222 of file Structured3DVector.hpp.

00223     : Vector<T>(v),
00224       __shape(v.__shape)
00225   {
00226     this->__buildView();
00227   }

template<typename T>
Structured3DVector< T >::~Structured3DVector (  )  [inline]

Destructor

Definition at line 233 of file Structured3DVector.hpp.

00234   {
00235     this->__clean();
00236   }


Member Function Documentation

template<typename T>
void Structured3DVector< T >::__buildView (  )  [inline, private]

Constructs the structured view

Definition at line 51 of file Structured3DVector.hpp.

Referenced by Structured3DVector< bool >::resize(), and Structured3DVector< bool >::Structured3DVector().

00052   {
00053     __structured3dView = new T**[__shape.nx()];
00054     for (size_t i=0; i < __shape.nx(); ++i) {
00055       __structured3dView[i] = new T* [__shape.ny()];
00056       for (size_t j=0; j < __shape.ny(); ++j) {
00057         __structured3dView[i][j]
00058           = &Vector<T>::__values[i*__shape.ny()*__shape.nz() + j*__shape.nz()];
00059       }
00060     }
00061   }

template<typename T>
void Structured3DVector< T >::__clean (  )  [inline, private]

Cleans structured view

Definition at line 67 of file Structured3DVector.hpp.

Referenced by Structured3DVector< bool >::resize(), and Structured3DVector< bool >::~Structured3DVector().

00068   {
00069     for (size_t i=0; i<__shape.nx(); ++i)
00070       delete[] __structured3dView[i];
00071     delete [] __structured3dView;
00072   }

template<typename T>
size_t Structured3DVector< T >::nx (  )  const [inline]

Number of values in direction x

Returns:
number of x values

Definition at line 80 of file Structured3DVector.hpp.

Referenced by MultiGrid::computeResidu(), MultiGrid::correct(), MultiGrid::FMV(), MultiGrid::multigrid(), MultiGrid::MultiGrid(), and MultiGrid::project().

00081   {
00082     return __shape.nx();
00083   }

template<typename T>
size_t Structured3DVector< T >::ny (  )  const [inline]

Number of values in direction y

Returns:
number of y values

Definition at line 90 of file Structured3DVector.hpp.

Referenced by MultiGrid::computeResidu(), MultiGrid::correct(), MultiGrid::FMV(), MultiGrid::multigrid(), MultiGrid::MultiGrid(), and MultiGrid::project().

00091   {
00092     return __shape.ny();
00093   }

template<typename T>
size_t Structured3DVector< T >::nz (  )  const [inline]

Number of values in direction z

Returns:
number of z values

Definition at line 100 of file Structured3DVector.hpp.

Referenced by MultiGrid::computeResidu(), MultiGrid::correct(), MultiGrid::FMV(), MultiGrid::multigrid(), MultiGrid::MultiGrid(), and MultiGrid::project().

00101   {
00102     return __shape.nz();
00103   }

template<typename T>
const Array3DShape& Structured3DVector< T >::shape (  )  const [inline]

Read only access to the shape of the array

Returns:

Definition at line 110 of file Structured3DVector.hpp.

Referenced by MultiGrid::computeResidu(), MultiGrid::computes(), MultiGrid::FMV(), MultiGrid::multigrid(), MultiGrid::MultiGrid(), and MultiGrid::weightJacobi().

00111   {
00112     return __shape;
00113   }

template<typename T>
const T& Structured3DVector< T >::operator() ( const size_t &  i,
const size_t &  j,
const size_t &  k 
) const [inline]

Read-only access to the $ (i,j,k) $ element of the vector

Returns:
element $ (i,j,k) $

Definition at line 120 of file Structured3DVector.hpp.

00121   {
00122     ASSERT ((i<__shape.nx()) and (j<__shape.ny()) and (k<__shape.nz()));
00123     return __structured3dView[i][j][k];
00124   }

template<typename T>
T& Structured3DVector< T >::operator() ( const size_t &  i,
const size_t &  j,
const size_t &  k 
) [inline]

Access to the $ (i,j,k) $ element of the vector

Returns:
element $ (i,j,k) $

Definition at line 131 of file Structured3DVector.hpp.

00132   {
00133     ASSERT ((i<__shape.nx()) and (j<__shape.ny()) and (k<__shape.nz()));
00134     return __structured3dView[i][j][k];
00135   }

template<typename T>
Structured3DVector<T>& Structured3DVector< T >::operator= ( const T &  t  )  [inline]

Sets all values of the array to the value t

Parameters:
t given value
Returns:
new vector

Reimplemented from Vector< T >.

Definition at line 144 of file Structured3DVector.hpp.

00145   {
00146     this->Vector<T>::operator=(t);
00147     return *this;
00148   }

template<typename T>
Structured3DVector<T>& Structured3DVector< T >::operator= ( const Structured3DVector< T > &  v  )  [inline]

Copies a structured 3d vector

Parameters:
v given vector
Returns:
new vector

Definition at line 157 of file Structured3DVector.hpp.

00158   {
00159     ASSERT (__shape==v.__shape);
00160     this->Vector<T>::operator=(v);
00161     return *this;
00162   }

template<typename T>
const Structured3DVector<T>& Structured3DVector< T >::operator= ( const Vector< T > &  v  )  [inline]

Copies a vector

Parameters:
v given vector
Returns:
new vector

Reimplemented from Vector< T >.

Definition at line 171 of file Structured3DVector.hpp.

00172   {
00173     ASSERT (this->size() == v.size());
00174     this->Vector<T>::operator=(v);
00175     return *this;
00176   }

template<typename T>
void Structured3DVector< T >::resize ( const Array3DShape shape  )  [inline]

Resizes the vector to a new shape

Parameters:
shape given new shape

Definition at line 183 of file Structured3DVector.hpp.

Referenced by MultiGrid::MultiGrid().

00184   {
00185     this->__clean();
00186     __shape = shape;
00187     this->Vector<T>::resize(shape.size());
00188     this->__buildView();    
00189   }

template<typename T>
const size_t& Vector< T >::size (  )  const [inline, inherited]

Read-only access to the size of the vector.

Definition at line 61 of file Vector.hpp.

Referenced by DegreeOfFreedomSetBuilder::__buildCorrespondance(), SurfaceMesh::__computesFictitiousCells(), SurfaceMeshGenerator::Internals::__constructionFinalMesh(), SurfaceMeshGenerator::Internals::__constructionVerticesList(), WriterVTK::__fillCrossedComponent(), WriterMedit::__fillCrossedComponent(), ScalarFunctionBuilder::Simplifier::__getOperatorF1F2SimplifiedFunction(), SpectralFEMPreconditioner::Internal::__legendreToLagrange(), SpectralFEMPreconditioner::Internal::__legendreToLagrangeTransposed(), WriterMedit::__proceedData(), MeshFormatReader::__readHexahedra(), MeshFormatReader::__readQuadrilaterals(), MeshFormatReader::__readTetrahedra(), MeshReaderAM_FMTFormat::__readTriangles(), MeshFormatReader::__readTriangles(), MeshReaderAM_FMTFormat::__readTrianglesReferences(), OctreeMeshBuilder::buildMesh(), SpectralFEMPreconditioner::Internal::computes(), MultiGrid::computes(), IncompleteCholeskiFactorization::computes(), DiagPrecond::computes(), SpectralFEMPreconditioner::Internal::computesTransposed(), MultiGrid::copyDirichlet(), LagrangeBasis::degree(), DGFunction< MeshType, FiniteElementTraits >::DGFunction(), LagrangeBasis::dimension(), FEMFunction< MeshType, FiniteElementTraits >::FEMFunction(), FGMRES::FGMRES(), LegendreBasis::getDerivativeValues(), ScalarFunctionReaderVTK::getFunction(), LegendreBasis::getSecondDerivativeValues(), LegendreBasis::getValues(), LagrangeBasis::getValues(), GMRES::GMRES(), invertEndianess(), LagrangeBasis::LagrangeBasis(), ScalarDegreeOfFreedomPositionsSet::number(), Structured3DMesh::numberOfCells(), SpectralMesh::numberOfCells(), EdgesSet::numberOfEdges(), FacesSet< Triangle >::numberOfFaces(), GaussLobatto::numberOfPoints(), VerticesSet::numberOfVertices(), MultiGrid::DirichletPositions::operator()(), Structured3DVector< bool >::operator=(), FEMFunctionBase::operator=(), FEMFunction< MeshType, FiniteElementTraits >::operator=(), DGFunctionBase::operator=(), DGFunction< MeshType, FiniteElementTraits >::operator=(), MultiGrid::residuDirichlet(), ScalarFunctionBuilder::setUnaryMinus(), MultiGrid::DirichletPositions::size(), SpectralFunction::SpectralFunction(), SparseMatrix::transposedTimesX(), and MultiGrid::weightJacobi().

00062   {
00063     return __size;
00064   }

template<typename T>
size_t Vector< T >::number ( T const &  e  )  const [inline, inherited]

Finds the number of an element of the vector.

Definition at line 67 of file Vector.hpp.

Referenced by DegreeOfFreedomSetBuilder::__buildFEMFictitious(), Structured3DMesh::cellNumber(), SpectralMesh::cellNumber(), DegreeOfFreedomSet::DegreeOfFreedomSet(), VerticesSet::number(), FacesSet< Triangle >::number(), and EdgesSet::number().

00068   {
00069     ASSERT ((&e >= __values)&&(static_cast<size_t>(&e-__values) < __size));
00070     return (&e-__values);
00071   }

template<typename T>
const T& Vector< T >::operator[] ( const size_t &  i  )  const [inline, inherited]

Read-only access to the ith __values of the vector.

Definition at line 83 of file Vector.hpp.

00084   {
00085     ASSERT (i<__size);
00086     return __values[i];
00087   }

template<typename T>
T& Vector< T >::operator[] ( const size_t &  i  )  [inline, inherited]

Access to the ith element of the vector.

Definition at line 90 of file Vector.hpp.

00091   {
00092     ASSERT (i<__size);
00093     return __values[i];
00094   }

template<typename T>
const T& Vector< T >::operator() ( const size_t &  i  )  const [inline, inherited]

Read-only access to the ith element of the vector. Used to provide a Blitz-like interface.

Definition at line 100 of file Vector.hpp.

00101   {
00102     ASSERT (i<__size);
00103     return __values[i];
00104   }

template<typename T>
T& Vector< T >::operator() ( const size_t &  i  )  [inline, inherited]

Access to the ith element of the vector. Used to provide a Blitz-like interface.

Definition at line 110 of file Vector.hpp.

00111   {
00112     ASSERT (i<__size);
00113     return __values[i];
00114   }

template<typename T>
void Vector< T >::resize ( const size_t &  newSize  )  [inline, inherited]

template<typename T>
Vector<T> Vector< T >::operator* ( const T &  t  )  const [inline, inherited]

operator* overloading. Returns t * this.

Warning:
a temporary is created!

Definition at line 158 of file Vector.hpp.

00159   {
00160     Vector<T> prod(*this);
00161     TermToTermProduct<T> tttp;
00162     for (size_t i=0; i<__size; ++i)
00163       prod.__values[i] = tttp(__values[i],t);
00164     return prod;
00165   }

template<typename T>
real_t Vector< T >::operator* ( const Vector< T > &  V  )  const [inline, inherited]

operator* overloading. Scalar product.

Definition at line 255 of file Vector.hpp.

00256   {
00257     ASSERT(__size==V.__size);
00258 
00259     real_t t = 0;
00260     for (size_t i=0; i<__size; ++i)
00261       t += __values[i] * V.__values[i];
00262 
00263     return t;
00264   }

template<typename T>
template<class T2>
const Vector<T>& Vector< T >::operator*= ( const T2 &  t  )  [inline, inherited]

operator*= overloading. The vector is multiplied by t.

Definition at line 185 of file Vector.hpp.

00186   {
00187     TermToTermProduct<T> tttp;
00188     for (size_t i=0; i<__size; ++i)
00189       __values[i] = tttp(__values[i],t);
00190     return *this;
00191   }

template<typename T>
Vector<T> Vector< T >::operator+ ( const Vector< T > &  V  )  const [inline, inherited]

operator+ overloading. Computes sum with V.

Warning:
a temporary is created!

Definition at line 197 of file Vector.hpp.

00198   {
00199     ASSERT(__size==V.__size);
00200     Vector<T> W(__size);
00201     for (size_t i=0; i<__size; ++i)
00202       W.__values[i] = __values[i] + V.__values[i];
00203     return W;
00204   }

template<typename T>
Vector<T> Vector< T >::operator- ( const Vector< T > &  V  )  const [inline, inherited]

operator- overloading. Computes difference with V.

Warning:
a temporary is created!

Definition at line 210 of file Vector.hpp.

00211   {
00212     ASSERT(__size==V.__size);
00213 
00214     Vector<T> W(__size);
00215     for (size_t i=0; i<__size; ++i) {
00216       W.__values[i] = __values[i] - V.__values[i];
00217     }
00218 
00219     return W;
00220   }

template<typename T>
const Vector<T>& Vector< T >::operator+= ( const Vector< T > &  V  )  [inline, inherited]

operator+= overloading. Addes V to the vector.

Definition at line 224 of file Vector.hpp.

00225   {
00226     ASSERT(__size==V.__size);
00227 
00228     for (size_t i=0; i<__size; ++i)
00229       __values[i] += V.__values[i];
00230 
00231     return *this;
00232   }

template<typename T>
const Vector<T>& Vector< T >::operator+= ( const T &  t  )  [inline, inherited]

operator+= overloading. Addes V to the vector.

Definition at line 235 of file Vector.hpp.

00236   {
00237     for (size_t i=0; i<__size; ++i)
00238       __values[i] += t;
00239 
00240     return *this;
00241   }

template<typename T>
const Vector<T>& Vector< T >::operator-= ( const Vector< T > &  V  )  [inline, inherited]

operator-= overloading. Substractes V to the vector.

Definition at line 244 of file Vector.hpp.

00245   {
00246     ASSERT(__size==V.__size);
00247 
00248     for (size_t i=0; i<__size; ++i)
00249       __values[i] -= V.__values[i];
00250 
00251     return (*this);
00252   }


Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const Vector< T > &  V 
) [friend, inherited]

writes a vector in a stream.

Definition at line 74 of file Vector.hpp.

00075   {
00076     for (size_t i=0; i<V.size(); ++i) {
00077       os << V[i] << '\n';
00078     }
00079     return os;
00080   }

template<typename T>
Vector<T> operator* ( const T &  t,
const Vector< T > &  V 
) [friend, inherited]

operator* overloading (friend version). Returns t * this.

Warning:
a temporary is created!

Definition at line 172 of file Vector.hpp.

00173   {
00174     Vector<T> sum(V.__size);
00175     TermToTermProduct<T> tttp;
00176     for (size_t i=0; i<V.__size; ++i)
00177       sum.__values[i] = tttp(V.__values[i],t);
00178 
00179     return sum;
00180   }

template<typename T>
real_t Norm ( const Vector< T > &  v  )  [friend, inherited]

Computes the « norm » of a given vector v. The result is a T! If T is of scalar type it returns the usual norm.

Warning:
only works if the template type T allows scalar product.
Todo:
Name might be change?

Definition at line 272 of file Vector.hpp.

00273   {
00274     return sqrt(v*v);
00275   }


Member Data Documentation

template<typename T>
T*** Structured3DVector< T >::__structured3dView [private]

allows access to the data using the structured organization.

Definition at line 42 of file Structured3DVector.hpp.

Referenced by Structured3DVector< bool >::__buildView(), Structured3DVector< bool >::__clean(), and Structured3DVector< bool >::operator()().

template<typename T>
Array3DShape Structured3DVector< T >::__shape [private]

template<typename T>
size_t Vector< T >::__size [protected, inherited]

template<typename T>
T* __restrict Vector< T >::__values [protected, inherited]


The documentation for this class was generated from the following file:

Generated on Wed Nov 19 00:15:31 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6