QuOc

 

Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Attributes

aol::MultiVector< _DataType > Class Template Reference

#include <multiVector.h>

Inheritance diagram for aol::MultiVector< _DataType >:
aol::MultiVectorWithConcatData< _DataType >

List of all members.

Classes

struct  vec_entry

Public Types

typedef _DataType DataType

Public Member Functions

 MultiVector ()
 Standard constructor creating an empty MultiVector.
 MultiVector (const int Num, const int Size)
 MultiVector (const Vector< int > &Size)
 This constructor creates a MultiVector with several size.size() components, component i has size Size[i].
 MultiVector (const Vector< DataType > &data, const Vector< int > &size)
 Split one long vector to MultiVector with shorter components of specified size, making deep copy.
 MultiVector (const MultiVector &rhs, CopyFlag copyFlag=DEEP_COPY)
 MultiVector (const qc::GridStructure &Grid)
 Constructor creating a MultiVector from qc::GridDefinition, using Dimension components of size Number of Nodes.
 ~MultiVector ()
void copySplitFrom (const Vector< DataType > &singleVector)
void copySplitFrom (const Vector< DataType > &singleVector, const Vector< int > &sizes)
void copySplitTransposeFrom (const Vector< DataType > &singleVector)
 only works if all component vectors have same length!
ostream & print (ostream &out) const
void appendReference (const Vector< DataType > &Vec, bool deleteFlag=false)
 if deleteFlag==true, it will be deleted when the multivector is destroyed
void appendReference (const MultiVector< DataType > &MultiVec, bool deleteFlag=false)
 calls appendReference on each component of MultiVec
void reallocate (const int NumComponents, const int SizeOfComponents)
 change size, deleting old contents
void resize (const int NumComponents, const int SizeOfComponents)
 change size, preserving old contents to the extent possible
void reserve (const int NumComponents, const int SizeOfComponents)
void reallocate (const Vector< int > &size)
 change size of MultiVector and its components to values given by Vector<int> size. Old contents are deleted.
void reallocate (const MultiVector< DataType > &other)
void reallocate (const qc::GridStructure &grid)
Vector< DataType > & operator[] (int Index)
const Vector< DataType > & operator[] (int Index) const
bool compareDim (const MultiVector< DataType > &mv) const
bool allDimsEqual () const
bool allDimsEqual (const int dim) const
int getEqualComponentSize () const
 return size of one component if all components have the same length
const Vector< int > & getSizes () const
int getTotalSize () const
int numComponents () const
void eraseComponent (const int Index)
MultiVector< DataType > & operator+= (const MultiVector< DataType > &Vec)
bool operator== (const MultiVector< DataType > &Vec) const
bool operator!= (const MultiVector< DataType > &Vec) const
MultiVector< DataType > & operator-= (const MultiVector< DataType > &Vec)
MultiVector< DataType > & addMultiple (const MultiVector< DataType > &Vec, DataType Factor)
 Adds multiple of Vec to this MultiVector.
MultiVector< DataType > & addToAll (const DataType Scalar)
 Adds scalar value to all entries.
DataType operator* (const MultiVector< DataType > &Vec) const
 Dot product.
DataType dotProduct (const MultiVector< DataType > &Vec) const
 Dot product.
DataType normSqr () const
RealType norm () const
RealType lpNorm (RealType p) const
DataType getMaxValue () const
DataType getMaxAbsValue () const
DataType getMinValue () const
bool checkForNANsAndINFs () const
MultiVector< DataType > & operator= (const MultiVector< DataType > &Vec)
MultiVector< DataType > & operator*= (const DataType Scalar)
MultiVector< DataType > & operator/= (const DataType Scalar)
void setZero ()
void setAll (const DataType value)
 Set all components of all vectors in MultiVector to same value.
template<int N>
void getTo (const int I, aol::Vec< N, DataType > &vals) const
 get values at position I in all components, avoiding temporary object
template<int N>
void set (const int I, const aol::Vec< N, DataType > &vals)
 set values at position I in all components
Vec2< intsetIthComponent (const int I, const RealType Value)
 set value at position I, 0 <= I <= getTotalSize()-1 ( needed by aol::DerivativeValidatorBase<> )
void clamp (const DataType Min, const DataType Max)
 Clamps all entries of all vectors in MultiVector into [Min,Max].
void threshold (const DataType ThresholdValue, const DataType A, const DataType B)
 All entries of all vectors bigger then ThresholdValue are set to B, all others are set to A.
void setAll (const aol::Vector< DataType > &vecValue)
void setVectorRef (int Index, Vector< DataType > &Vec, bool deleteFlag=false)

Static Public Attributes

static const int Depth = 2

Protected Types

typedef aol::RealTrait
< _DataType >::RealType 
RealType

Protected Attributes

vector< vec_entryvecs

Detailed Description

template<typename _DataType>
class aol::MultiVector< _DataType >

Definition at line 20 of file multiVector.h.


Member Typedef Documentation

template<typename _DataType>
typedef _DataType aol::MultiVector< _DataType >::DataType

Reimplemented in aol::MultiVectorWithConcatData< _DataType >.

Definition at line 22 of file multiVector.h.

template<typename _DataType>
typedef aol::RealTrait<_DataType>::RealType aol::MultiVector< _DataType >::RealType [protected]

Definition at line 26 of file multiVector.h.


Constructor & Destructor Documentation

template<typename _DataType>
aol::MultiVector< _DataType >::MultiVector (  )  [inline]

Standard constructor creating an empty MultiVector.

Definition at line 42 of file multiVector.h.

                  {
  }

template<typename _DataType>
aol::MultiVector< _DataType >::MultiVector ( const int  Num,
const int  Size 
) [inline]

Constructor creating MultiVector with Num components of size Size. Do NOT implement default behavior or a constructor with one int only -- it is unclear whether the user wants to create one component of size N or N components of size 0.

Definition at line 48 of file multiVector.h.

                                                {
    vecs.reserve ( Num );
    for ( int i = 0; i < Num; ++i ) {
      vecs.push_back ( vec_entry ( new Vector<DataType> ( Size ) ) );
    }
  }

template<typename _DataType>
aol::MultiVector< _DataType >::MultiVector ( const Vector< int > &  Size  )  [inline, explicit]

This constructor creates a MultiVector with several size.size() components, component i has size Size[i].

Definition at line 56 of file multiVector.h.

                                                   {
    vecs.reserve ( Size.size () );
    for ( int i = 0; i < Size.size (); ++i )
      vecs.push_back ( vec_entry ( new Vector<DataType> ( Size [i] ) ) );
  }

template<typename _DataType>
aol::MultiVector< _DataType >::MultiVector ( const Vector< DataType > &  data,
const Vector< int > &  size 
) [inline]

Split one long vector to MultiVector with shorter components of specified size, making deep copy.

Definition at line 75 of file multiVector.h.

                                                                        {
    int k = 0;
    vecs.reserve ( size.size () );
    for ( int i = 0; i < size.size (); ++i ) {
      vecs.push_back ( vec_entry ( new Vector<DataType> ( size [i] ) ) );
      for ( int j = 0; j < size [i]; ++j, ++k )
        ( *vecs [i].ptr ) [j] = data [k];
    }
    int rest = data.size () - k;
    if ( rest > 0 ) {
      Vector<DataType>* temp = new Vector<DataType> ( rest );
      for ( int i = 0; i < rest; ++i, ++k )
        ( *temp ) [i] = data [k];
      appendReference ( *temp );
    }
  }

template<typename _DataType>
aol::MultiVector< _DataType >::MultiVector ( const MultiVector< _DataType > &  rhs,
CopyFlag  copyFlag = DEEP_COPY 
) [inline]

Copy constuctor

for copyFlag DEEP_COPY, create deep copy of every vector contained in rhs, for FLAT_COPY only append references to the vectors that are contained in rhs.

Definition at line 97 of file multiVector.h.

                                                                        {
    if (copyFlag == DEEP_COPY || copyFlag == STRUCT_COPY) {
      vecs.reserve ( rhs.numComponents() );
      for ( int i = 0; i < rhs.numComponents(); ++i )
        vecs.push_back ( vec_entry ( new Vector<DataType> ( rhs[i], copyFlag ), /* delete this = */ true ) );
    }
    else
      for ( int i = 0; i < rhs.numComponents(); ++i )
        appendReference ( rhs[i] );
  }

template<typename _DataType >
aol::MultiVector< _DataType >::MultiVector ( const qc::GridStructure Grid  )  [explicit]

Constructor creating a MultiVector from qc::GridDefinition, using Dimension components of size Number of Nodes.

Definition at line 15 of file multiVector.cpp.

References qc::GridStructure::getDimOfWorld(), qc::GridStructure::getNumberOfNodes(), and aol::MultiVector< _DataType >::vecs.

                                                                       {
  vecs.reserve ( Grid.getDimOfWorld() );
  for ( int i = 0; i < Grid.getDimOfWorld(); ++i ) {
    vecs.push_back ( vec_entry ( new Vector<DataType> ( Grid.getNumberOfNodes() ) ) );
  }
}

template<typename _DataType>
aol::MultiVector< _DataType >::~MultiVector (  )  [inline]

Definition at line 111 of file multiVector.h.

                 {
    while ( vecs.size() ) {
      if ( vecs.back().deleteFlag ) {
        delete vecs.back().ptr;
      }
      vecs.pop_back();
    }
  }


Member Function Documentation

template<typename _DataType>
MultiVector<DataType>& aol::MultiVector< _DataType >::addMultiple ( const MultiVector< DataType > &  Vec,
DataType  Factor 
) [inline]

Adds multiple of Vec to this MultiVector.

Definition at line 374 of file multiVector.h.

Referenced by aol::TrustRegionMethod< _RealType, _VectorType, _SecondDerivativeType, _PrecondType, SubMatrixType >::solveSubProblemLanczos().

                                                                                           {
    if ( !Vec.compareDim ( *this ) ) {
      throw Exception ( "MultiVector<DataType>::add dimensions don't match.", __FILE__, __LINE__ );
    }
    int i = 0;
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      it->ptr->addMultiple ( Vec[ i ], Factor );
    }
    return *this;
  }

template<typename _DataType>
MultiVector<DataType>& aol::MultiVector< _DataType >::addToAll ( const DataType  Scalar  )  [inline]
template<typename _DataType>
bool aol::MultiVector< _DataType >::allDimsEqual ( const int  dim  )  const [inline]

Definition at line 281 of file multiVector.h.

                                            {
    for ( int i = 0; i < numComponents (); ++i )
      if ( ( *this ) [i].size () != dim ) return false;
    return true;
  }

template<typename _DataType>
bool aol::MultiVector< _DataType >::allDimsEqual (  )  const [inline]

Definition at line 274 of file multiVector.h.

Referenced by aol::MeshWithData< MeshType >::addData(), fillVectorDataFunction3d(), aol::MultiVector< DataType >::getEqualComponentSize(), and om::TriMeshWithGeomProps< RealType, Imp >::writePrincipalCurvaturesTo().

                             {
    int dim = ( *this ) [0].size ();
    for ( int i = 1; i < numComponents (); ++i )
      if ( ( *this ) [i].size () != dim ) return false;
    return true;
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::appendReference ( const Vector< DataType > &  Vec,
bool  deleteFlag = false 
) [inline]
template<typename _DataType>
void aol::MultiVector< _DataType >::appendReference ( const MultiVector< DataType > &  MultiVec,
bool  deleteFlag = false 
) [inline]

calls appendReference on each component of MultiVec

Definition at line 173 of file multiVector.h.

                                                                                          {
    for( int i = 0; i < MultiVec.numComponents(); ++i )
      appendReference( MultiVec[i], deleteFlag );
  }

template<typename _DataType>
bool aol::MultiVector< _DataType >::checkForNANsAndINFs (  )  const [inline]

Definition at line 468 of file multiVector.h.

                                   {
    bool nans = false;
    typename vector<vec_entry>::iterator it = vecs.begin();
    for ( ; it != vecs.end(); ++it ) {
      if ( it->ptr->checkForNANsAndINFs() )
        nans = true;
    }
    return nans;
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::clamp ( const DataType  Min,
const DataType  Max 
) [inline]

Clamps all entries of all vectors in MultiVector into [Min,Max].

Definition at line 551 of file multiVector.h.

Referenced by qc::ChanVeseGradientDescent< ConfiguratorType, HeavisideFunctionType, NumberOfLevelsetFunctions >::postProcess().

                                                        {
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it ) {
      if ( !it->ptr ) {
        throw Exception ( "MultiVector::clamp ( const DataType Min, const DataType Max ): it->ptr == NULL !", __FILE__, __LINE__ );
      }
      it->ptr->clamp( Min, Max );
    }
  }

template<typename _DataType>
bool aol::MultiVector< _DataType >::compareDim ( const MultiVector< DataType > &  mv  )  const [inline]
template<typename _DataType>
void aol::MultiVector< _DataType >::copySplitFrom ( const Vector< DataType > &  singleVector  )  [inline]

Definition at line 120 of file multiVector.h.

                                                               {
    QUOC_ASSERT ( singleVector.size() == getTotalSize() );
    Vector<int> sizes ( getSizes() );
    int index = 0;
    for (int i = 0; i < sizes.size(); ++i)
      for (int j = 0; j < sizes[i]; ++j, ++index)
        (*this)[i][j] = singleVector[index];
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::copySplitFrom ( const Vector< DataType > &  singleVector,
const Vector< int > &  sizes 
) [inline]

Definition at line 129 of file multiVector.h.

                                                                                          {
    int k = 0;
    reallocate ( sizes );
    for ( int i = 0; i < sizes.size (); ++i ) {
      vecs.push_back ( vec_entry ( new Vector<DataType> ( sizes [i] ) ) );
      for ( int j = 0; j < sizes [i]; ++j, ++k )
        (*this) [i][j] = singleVector [k];
    }
    int rest = singleVector.size() - k;
    if ( rest > 0 ) {
      Vector<DataType>* temp = new Vector<DataType> ( rest );
      for ( int i = 0; i < rest; ++i, ++k )
        ( *temp ) [i] = singleVector [k];
      appendReference ( *temp );
    }
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::copySplitTransposeFrom ( const Vector< DataType > &  singleVector  )  [inline]

only works if all component vectors have same length!

Definition at line 147 of file multiVector.h.

                                                                        {
    QUOC_ASSERT ( singleVector.size() == getTotalSize() );
    Vector<int> sizes ( getSizes() );
    if (sizes.getMinValue() != sizes.getMaxValue())
      throw aol::Exception ( "aol::MultiVector::copySplitTransposeFrom only works for component vectors of equal length.", __FILE__, __LINE__ );
    int index = 0;
    for (int i = 0; i < sizes[0]; ++i)
      for (int j = 0; j < sizes.size(); ++j, ++index)
        (*this)[j][i] = singleVector[index];
  }

template<typename _DataType>
DataType aol::MultiVector< _DataType >::dotProduct ( const MultiVector< DataType > &  Vec  )  const [inline]

Dot product.

Definition at line 415 of file multiVector.h.

Referenced by aol::DeflationEigenvectorOp< MatrixType >::apply().

                                                                {
    return this->operator*( Vec );
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::eraseComponent ( const int  Index  )  [inline]

Definition at line 317 of file multiVector.h.

                                          {
    if ( vecs[Index].deleteFlag ) {
      delete vecs[Index].ptr;
    }
    vecs.erase (vecs.begin()+Index);
  }

template<typename _DataType>
int aol::MultiVector< _DataType >::getEqualComponentSize (  )  const [inline]

return size of one component if all components have the same length

Definition at line 288 of file multiVector.h.

                                      {
    if ( allDimsEqual() == false ) {
      cerr << this->getSizes() << endl;
      throw ( aol::Exception ( "Sizes of components differ.", __FILE__, __LINE__ ) );
      return ( -1 );
    }
    return ( ( *this ) [0].size () );
  }

template<typename _DataType>
DataType aol::MultiVector< _DataType >::getMaxAbsValue (  )  const [inline]

Definition at line 450 of file multiVector.h.

Referenced by qc::PiecewiseConstantTwoPhaseMSSegmentor< ConfiguratorType, ImageDimension, BaseClass >::updateGrayValues().

                                  {
    typename vector<vec_entry>::iterator it = vecs.begin();
    DataType maxabs = it++->ptr->getMaxAbsValue();
    for ( ; it != vecs.end(); ++it ) {
      maxabs = aol::Max ( it->ptr->getMaxAbsValue(), maxabs );
    }
    return maxabs;
  }

template<typename _DataType>
DataType aol::MultiVector< _DataType >::getMaxValue (  )  const [inline]
template<typename _DataType>
DataType aol::MultiVector< _DataType >::getMinValue (  )  const [inline]

Definition at line 459 of file multiVector.h.

Referenced by aol::TriangMesh< DataType >::computeBoundingBox(), and qc::ChanVeseGradientDescent< ConfiguratorType, HeavisideFunctionType, NumberOfLevelsetFunctions >::postProcess().

                               {
    typename vector<vec_entry>::iterator it = vecs.begin();
    DataType min = it++->ptr->getMinValue();
    for ( ; it != vecs.end(); ++it ) {
      min = aol::Min ( it->ptr->getMinValue(), min );
    }
    return min;
  }

template<typename _DataType>
const Vector<int>& aol::MultiVector< _DataType >::getSizes (  )  const [inline]
template<typename _DataType>
template<int N>
void aol::MultiVector< _DataType >::getTo ( const int  I,
aol::Vec< N, DataType > &  vals 
) const [inline]

get values at position I in all components, avoiding temporary object

Definition at line 525 of file multiVector.h.

                                                              {
    if ( N != numComponents() )
      throw aol::Exception ( "aol::MultiVector<DataType>::getTo ( int, aol::Vec ): size of Vec does not match", __FILE__, __LINE__ );
    for ( int j = 0; j < N; ++j )
      vals[j] = (*this)[j][I];
  }

template<typename _DataType >
aol::MultiVector< _DataType >::RealType aol::MultiVector< _DataType >::lpNorm ( RealType  p  )  const

Returns lp norm of MultiVector interpreted as Vector

Author:
Preusser

Definition at line 28 of file multiVector.cpp.

References aol::MultiVector< _DataType >::getTotalSize(), aol::Vector< _DataType >::lpNormPowP(), aol::MultiVector< _DataType >::numComponents(), and aol::MultiVector< _DataType >::operator[]().

                                                                                                {
  RealType ret = aol::NumberTrait<RealType>::zero;
  for ( int c = 0; c < this->numComponents(); ++c ) {
    ret += this->operator[]( c ).lpNormPowP ( p );
  }

  if ( p == aol::ZOTrait<RealType>::zero ) {
    return static_cast<RealType> ( this->getTotalSize() );
  } else if ( p == aol::ZOTrait<RealType>::one ) {
    return static_cast<RealType> ( ret );
  } else if ( p == static_cast<RealType> ( 2 ) ) {
    return static_cast<RealType> ( sqrt ( ret ) );
  } else                     {
    return static_cast<RealType> ( pow ( ret, static_cast<RealType> ( 1.0 / p ) ) );
  }
}

template<typename _DataType>
RealType aol::MultiVector< _DataType >::norm (  )  const [inline]
template<typename _DataType>
DataType aol::MultiVector< _DataType >::normSqr (  )  const [inline]

Definition at line 419 of file multiVector.h.

Referenced by qc::RegularizedLinCombDescentDirOp< RealType, aol::MultiVector< RealType > >::applyAdd(), aol::MultiVector< DataType >::norm(), and om::CompTriMesh< RealType, TriMeshWithNormalType >::normSqr().

                           {
    DataType s = 0;
    int i = 0;
#ifdef __INTEL_COMPILER
#pragma ivdep
#endif
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      s += static_cast<RealType>(it->ptr->normSqr());
    }
    return s;
  }

template<typename _DataType>
int aol::MultiVector< _DataType >::numComponents (  )  const [inline]

Definition at line 313 of file multiVector.h.

Referenced by aol::MultiVector< DataType >::addToAll(), aol::MultiVector< DataType >::allDimsEqual(), aol::MultiVector< DataType >::appendReference(), aol::MultiRestrOp< DataType >::apply(), aol::VecToMVecOp< RealType >::apply(), aol::BiOpBase< Vector< RealType > >::apply(), aol::CholeskyBlockInverseOp< RealType, aol::SparseMatrix< RealType > >::apply(), qc::FENonlinLevelsetIntegrationVectorInterface< ConfiguratorType, qc::QC_3D, NumCompArg, Imp >::applyAdd(), qc::FENonlinLevelsetIntegrationVectorInterface< ConfiguratorType, qc::QC_2D, NumCompArg, Imp >::applyAdd(), qc::FENonlinLevelsetVectorDiffOpInterface< ConfiguratorType, qc::QC_3D, NumCompArg, NumCompDest, Imp >::applyAdd(), qc::FENonlinLevelsetVectorDiffOpInterface< ConfiguratorType, qc::QC_2D, NumCompArg, NumCompDest, Imp >::applyAdd(), qc::FENonlinLevelsetVectorOpInterface< ConfiguratorType, qc::QC_3D, NumCompArg, NumCompDest, Imp >::applyAdd(), qc::FENonlinLevelsetVectorOpInterface< ConfiguratorType, qc::QC_2D, NumCompArg, NumCompDest, Imp >::applyAdd(), qc::RegularizedLinCombDescentDirOp< RealType, aol::MultiVector< RealType > >::applyAdd(), qc::TransformFunction< RealType, qc::QC_3D >::applyAdd(), qc::TransformFunction< RealType, qc::QC_2D >::applyAdd(), om::VariationOpInterface< TriMeshConfType, Imp >::applyAdd(), aol::VecToMVecOp< RealType >::applyAdd(), aol::ScalarVecToScalarMVecOp< RealType >::applyAdd(), aol::BlockOpBase< aol::DiagonalMatrix< RealType >::DataType, aol::DiagonalMatrix< RealType > >::applyAdd(), aol::BiOpBase< Vector< RealType > >::applyAdd(), aol::DiagonalBlockOp< RealType >::applyAdd(), aol::FENonlinIntegrationVectorGeneralInterface< ConfiguratorType, GammaIntegrationOp< ConfiguratorType, AnisoType > >::applyAdd(), aol::NonlinearCombinedDiffVectorOpInterface< ConfiguratorType, NumCompArg, NumCompDest, Imp >::applyAdd(), aol::FENonlinVectorDiffOpInterface< ConfiguratorType, ConfiguratorType::Dim, ConfiguratorType::Dim, HyperelasticGradient< ConfiguratorType, HyperelasticEnergyDensityType > >::applyAdd(), aol::FENonlinVectorOpInterface< ConfiguratorType, ConfiguratorType::Dim, 3, DeformationGradientInvariants< ConfiguratorType > >::applyAdd(), aol::DQEnergyDerivativeOp< DataType, IndexType >::applyAdd(), aol::CDQEnergyDerivativeOp< DataType, IndexType >::applyAdd(), aol::BiOpBase< Vector< RealType > >::applyAddSingle(), aol::BiOpBase< Vector< RealType > >::applySingle(), aol::checkMultiChanVeseStructure(), qc::PeriodicityHandlerBase< CFEGrid< RealType, CFE_TPOS >, CFEGrid< RealType, CFE_TPOS >::RealType, qc::QC_3D >::collapsePeriodicBC(), aol::MultiVector< DataType >::compareDim(), qc::ConcatAndSmoothlyExtendDeformations(), qc::ConsistencyEnergyOp< ConfiguratorType >::ConsistencyEnergyOp(), qc::DeformAndSmoothlyExtendImage(), qc::deformImageWithCoarseDeformation(), depthOfMultiVector(), depthOfMultiVector3d(), aol::DiscreteVectorFunction< ConfType, DiscreteFunctionDefault< ConfType >, DimRange >::DiscreteVectorFunction(), tpcfe::CFEGridBase< _RealType, CFE_CDWI_TPOS, _RealType >::doRestrictToDomain(), aol::HeavisideProductFENonlinIntegrationVectorInterface< ConfiguratorType, HeavisideFunctionType, TargetOpType >::evaluateIntegrand(), qc::PeriodicityHandlerBase< CFEGrid< RealType, CFE_TPOS >, CFEGrid< RealType, CFE_TPOS >::RealType, qc::QC_3D >::extendPeriodicBC(), fillVectorDataFunction(), om::TriMesh< _RealType >::fromVector(), qc::DataGenerator< ConfiguratorType >::generateChanVeseInitialization(), aol::PlotDataFileHandler< RealType >::generateIsolineData(), qc::DataGenerator< ConfiguratorType >::generateMaskFromLevelsetfunctions(), qc::DataGenerator< ConfiguratorType >::generatePiecewiseAffineFlowField(), qc::DataGenerator< ConfiguratorType >::generatePiecewiseConstantFlowField(), qc::TVStiffOp< ConfiguratorType >::getCoeff(), aol::DifferentialQuotientTest< RealType, aol::MultiVector< RealType > >::getDerivativeWRTIthDOF(), aol::PCAOp< RealType, SampleType >::getDiagOfCovariance(), aol::TriangMesh< DataType >::getNumTriangDataVectors(), aol::TriangMesh< DataType >::getNumVertexDataVectors(), aol::PowerSetIterator::getPositionNumberFromLevelsetFunctions(), aol::PCAOp< RealType, SampleType >::getRowOfCovariance(), aol::MultiVector< DataType >::getSizes(), qc::SliceExtractor< ConfiguratorType >::getSlice(), aol::QuasiNewtonIterationComponentWiseTimestepControlled< RealType >::getTauAndUpdateDescentDir(), aol::GradientDescentComponentWiseTimestepControlled< ConfiguratorType >::getTauAndUpdateDescentDir(), aol::MultiVector< DataType >::getTo(), aol::MultiVector< DataType >::getTotalSize(), aol::HeavisideProductFENonlinIntegrationVectorInterface< ConfiguratorType, HeavisideFunctionType, TargetOpType >::HeavisideProductFENonlinIntegrationVectorInterface(), aol::MultiVector< _DataType >::lpNorm(), qc::MultiArray< RealType, qc::QC_3D >::MultiArray(), aol::MultiVector< DataType >::MultiVector(), aol::MultiVector< DataType >::operator*(), aol::EigenvectorOp< BandMatrixType >::orderEigenvaluesAndCopyEigenvectors(), qc::QuocTimestepSaver< ConfiguratorType >::plotVectorFieldSegmented(), qc::ClassicalChanVeseGradientDescent< ConfiguratorType, HeavisideFunctionType, NumberOfLevelsetFunctions, ImageDimension >::postProcess(), aol::MultiVector< DataType >::print(), aol::MultiVector< DataType >::reallocate(), tpcfe::CFEGridBase< _RealType, CFE_CDWI_TPOS, _RealType >::restrictDirichletNodes(), qc::PeriodicityHandlerBase< CFEGrid< RealType, CFE_TPOS >, CFEGrid< RealType, CFE_TPOS >::RealType, qc::QC_3D >::restrictPeriodicBC(), tpcfe::CFEGridBase< _RealType, CFE_CDWI_TPOS, _RealType >::restrictToDofs(), tpcfe::CFEPeriodicityHandlerBase< CFEGrid< RealType, CFE_TPOS > >::restrictToPresentDOFs(), qc::QuocTimestepSaver< ConfiguratorType >::savePiecewiseConstantColorImageSegmented(), qc::QuocTimestepSaver< ConfiguratorType >::savePiecewiseConstantImageSegmented(), aol::TimestepSaver< MatrixType::DataType >::saveTimestepBZ2(), aol::MultiVector< DataType >::set(), aol::MultiVector< DataType >::setAll(), aol::DifferentialQuotientTest< RealType, aol::MultiVector< RealType > >::shiftIthDOFByEpsilon(), aol::L2GradientDescentDirichletBCs< ConfiguratorType, VectorType >::smoothDirection(), aol::GradientDescent< ConfiguratorType, aol::MultiVector< typename ConfiguratorType::RealType > >::smoothDirection(), qc::SmoothlyExtendImage(), aol::testFirstDerivativeMultiVectorAllDirections(), aol::testSecondDerivativeMultiVectorAllDirections(), qc::TransformFunction< RealType, qc::QC_3D >::transform(), qc::TransformFunction< RealType, qc::QC_2D >::transform(), qc::TransformFunction< RealType, qc::QC_2D >::transformMultiLin(), aol::ClassicalChanVeseMeanValueUpdater< ConfiguratorType, HeavisideFunctionType, NumberOfLevelsetFunctions, ImageDimension >::update(), aol::Vector< _DataType >::Vector(), vector_function(), qc::writeImage(), aol::TimestepSaver< MatrixType::DataType >::writeMultiVectorToTextFile(), and om::TriMeshWithGeomProps< RealType, Imp >::writePrincipalCurvaturesTo().

                            {
    return static_cast<int>(vecs.size());
  }

template<typename _DataType>
bool aol::MultiVector< _DataType >::operator!= ( const MultiVector< DataType > &  Vec  )  const [inline]

Definition at line 349 of file multiVector.h.

                                                             {
    if ( !Vec.compareDim ( *this ) ) {
      throw Exception ( "MultiVector<DataType>::operator!= : dimensions don't match.", __FILE__, __LINE__ );
    }
    int i = 0;
    for ( typename vector<vec_entry>::const_iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      if ( * ( it->ptr ) == Vec[ i ] ) {
        return false;
      }
    }
    return true;
  }

template<typename _DataType>
DataType aol::MultiVector< _DataType >::operator* ( const MultiVector< DataType > &  Vec  )  const [inline]

Dot product.

Definition at line 393 of file multiVector.h.

Referenced by aol::MultiVector< DataType >::dotProduct().

                                                                {
    if ( !Vec.compareDim ( *this ) ) {
      cerr << this->numComponents() << " " << Vec.numComponents() << endl;
      if ( this->numComponents() == Vec.numComponents() )
        for ( int i = 0; i < this->numComponents(); ++i )
          cerr << (*this)[i].size() << " " << Vec[i].size() << "    ";
      cerr << endl;
      
      throw Exception ( "MultiVector<DataType>::operator* : dimensions don't match.", __FILE__, __LINE__ );
    }
    DataType dot = 0;
    int i = 0;
#ifdef __INTEL_COMPILER
#pragma ivdep
#endif
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      dot += * ( it->ptr ) * Vec[ i ];
    }
    return dot;
  }

template<typename _DataType>
MultiVector<DataType>& aol::MultiVector< _DataType >::operator*= ( const DataType  Scalar  )  [inline]

Definition at line 490 of file multiVector.h.

                                                              {
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it ) {
      * ( it->ptr ) *= Scalar;
    }
    return *this;
  }

template<typename _DataType>
MultiVector<DataType>& aol::MultiVector< _DataType >::operator+= ( const MultiVector< DataType > &  Vec  )  [inline]

Definition at line 324 of file multiVector.h.

                                                                         {
    if ( !Vec.compareDim ( *this ) ) {
      throw Exception ( "MultiVector<DataType>::operator+= : dimensions don't match.", __FILE__, __LINE__ );
    }
    int i = 0;
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      * ( it->ptr ) += Vec[ i ];
    }

    return *this;
  }

template<typename _DataType>
MultiVector<DataType>& aol::MultiVector< _DataType >::operator-= ( const MultiVector< DataType > &  Vec  )  [inline]

Definition at line 362 of file multiVector.h.

                                                                         {
    if ( !Vec.compareDim ( *this ) ) {
      throw Exception ( "MultiVector<DataType>::operator-= : dimensions don't match.", __FILE__, __LINE__ );
    }
    int i = 0;
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      * ( it->ptr ) -= Vec[ i ];
    }
    return *this;
  }

template<typename _DataType>
MultiVector<DataType>& aol::MultiVector< _DataType >::operator/= ( const DataType  Scalar  )  [inline]

Definition at line 497 of file multiVector.h.

                                                              {
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it ) {
      * ( it->ptr ) /= Scalar;
    }
    return *this;
  }

template<typename _DataType>
MultiVector<DataType>& aol::MultiVector< _DataType >::operator= ( const MultiVector< DataType > &  Vec  )  [inline]

Definition at line 478 of file multiVector.h.

                                                                        {
    if ( !Vec.compareDim ( *this ) ) {
      throw Exception ( "MultiVector<DataType>::operator= : dimensions don't match.", __FILE__, __LINE__ );
    }
    int i = 0;
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      * ( it->ptr ) = Vec[ i ];
    }

    return *this;
  }

template<typename _DataType>
bool aol::MultiVector< _DataType >::operator== ( const MultiVector< DataType > &  Vec  )  const [inline]

Definition at line 336 of file multiVector.h.

                                                             {
    if ( !Vec.compareDim ( *this ) ) {
      throw Exception ( "MultiVector<DataType>::operator== : dimensions don't match.", __FILE__, __LINE__ );
    }
    int i = 0;
    for ( typename vector<vec_entry>::const_iterator it = vecs.begin(); it != vecs.end(); ++it, ++i ) {
      if ( * ( it->ptr ) != Vec[ i ] ) {
        return false;
      }
    }
    return true;
  }

template<typename _DataType>
const Vector<DataType>& aol::MultiVector< _DataType >::operator[] ( int  Index  )  const [inline]

Reimplemented in aol::MultiDerivedVector< DerivedType >, qc::MultiArray< DataType, rangedim, imagedim >, qc::MultiArray< RealType, 3 >, and qc::MultiArray< RealType, qc::QC_3D >.

Definition at line 256 of file multiVector.h.

                                                         {
#ifdef BOUNDS_CHECK
    if ( Index < 0 || Index >= static_cast<int>(vecs.size()) ) {
      char error[1024];
      sprintf ( error, "MultiVector<Realtype>::operator[]: index %d out of bounds. N = %d\n", Index, static_cast<int>(vecs.size()) );
      throw OutOfBoundsException ( error, __FILE__, __LINE__ );
    }
#endif
    return * ( vecs[ Index ].ptr );
  }

template<typename _DataType>
Vector<DataType>& aol::MultiVector< _DataType >::operator[] ( int  Index  )  [inline]

Reimplemented in aol::MultiDerivedVector< DerivedType >, qc::MultiArray< DataType, rangedim, imagedim >, qc::MultiArray< RealType, 3 >, and qc::MultiArray< RealType, qc::QC_3D >.

Definition at line 245 of file multiVector.h.

Referenced by aol::MultiVector< _DataType >::lpNorm().

                                             {
#ifdef BOUNDS_CHECK
    if ( Index < 0 || Index >= static_cast<int>(vecs.size()) ) {
      char error[1024];
      sprintf ( error, "MultiVector<Realtype>::operator[]: index %d out of bounds. N = %d\n", Index, static_cast<int>(vecs.size()) );
      throw OutOfBoundsException ( error, __FILE__, __LINE__ );
    }
#endif
    return * ( vecs[ Index ].ptr );
  }

template<typename _DataType>
ostream& aol::MultiVector< _DataType >::print ( ostream &  out  )  const [inline]

Definition at line 158 of file multiVector.h.

Referenced by aol::operator<<().

                                        {
    for ( int i = 0; i < numComponents(); ++i ) {
      ( *this ) [i].print ( out );
      if ( i < numComponents() - 1 ) cerr << endl;
    }
    return out;
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::reallocate ( const Vector< int > &  size  )  [inline]

change size of MultiVector and its components to values given by Vector<int> size. Old contents are deleted.

Reimplemented in aol::MultiVectorWithConcatData< _DataType >.

Definition at line 222 of file multiVector.h.

                                              {
    while ( vecs.size() ) {
      if ( vecs.back().deleteFlag ) {
        delete vecs.back().ptr;
      }
      vecs.pop_back();
    }
    // A simple vecs.clear(); leads to a memory leak.

    for ( int i = 0; i < size.size (); ++i ) {
      vecs.push_back ( vec_entry ( new Vector<DataType> ( size [i] ) ) ) ;
    }
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::reallocate ( const MultiVector< DataType > &  other  )  [inline]

Definition at line 236 of file multiVector.h.

                                                         {
    Vector<int> sizes ( other.numComponents() );
    for ( int i = 0; i < sizes.size(); ++i )
      sizes[i] = other[i].size();
    this->reallocate ( sizes );
  }

template<typename _DataType >
void aol::MultiVector< _DataType >::reallocate ( const qc::GridStructure grid  ) 
template<typename _DataType>
void aol::MultiVector< _DataType >::reserve ( const int  NumComponents,
const int  SizeOfComponents 
) [inline]

Definition at line 210 of file multiVector.h.

Referenced by aol::TriangMesh< DataType >::reallocateTriangData(), aol::TriangMesh< DataType >::reallocateVertexData(), aol::TriangMesh< DataType >::reserve(), and aol::MultiVector< DataType >::reserve().

                                                                       {
    if ( static_cast<int>( vecs.size() ) != NumComponents )
      throw aol::Exception ( "aol::MultiVector::reserve cannot change the number of components.", __FILE__, __LINE__ );

    for ( int i = 0; i < static_cast<int>( vecs.size() ); ++i ) {
      (vecs[i].ptr)->reserve ( SizeOfComponents );
    }
    
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::resize ( const int  NumComponents,
const int  SizeOfComponents 
) [inline]

change size, preserving old contents to the extent possible

Definition at line 188 of file multiVector.h.

Referenced by aol::MultiVector< DataType >::reallocate(), aol::TriangMesh< DataType >::reallocateTriangData(), aol::TriangMesh< DataType >::reallocateVertexData(), aol::TriangMesh< DataType >::resize(), and aol::MultiVector< DataType >::resize().

                                                                      {
    if ( vecs.size() > static_cast<unsigned int>( NumComponents ) ) {
      for ( int i = static_cast<int>( vecs.size() ); i > NumComponents; --i ) {
        if ( vecs.back().deleteFlag ) {
          delete vecs.back().ptr;
        }
        vecs.pop_back();
      }
    }

    vecs.reserve ( NumComponents );
    if ( static_cast<int>( vecs.size() ) < NumComponents ) {    
      for ( int i = static_cast<int>( vecs.size() ); i < NumComponents; ++i) {      
        vecs.push_back ( vec_entry ( new Vector<DataType> ( SizeOfComponents ) ) ) ;
      }
    }

    for ( int i = 0; i < NumComponents; ++i ) {
      (vecs[i].ptr)->resize ( SizeOfComponents );
    }
  }

template<typename _DataType>
template<int N>
void aol::MultiVector< _DataType >::set ( const int  I,
const aol::Vec< N, DataType > &  vals 
) [inline]

set values at position I in all components

Definition at line 534 of file multiVector.h.

                                                            {
    if ( N != numComponents() )
      throw aol::Exception ( "aol::MultiVector<DataType>::set ( int, aol::Vec ): size of Vec does not match", __FILE__, __LINE__ );
    for ( int j = 0; j < N; ++j )
      (*this)[j][I] = vals[j];
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::setAll ( const aol::Vector< DataType > &  vecValue  )  [inline]

Definition at line 570 of file multiVector.h.

                                                      {
    for ( int i = 0; i < numComponents(); ++i )
      (*this)[i] = vecValue;
      //*( vecs[ i ].ptr ) = vecValue;
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::setAll ( const DataType  value  )  [inline]

Set all components of all vectors in MultiVector to same value.

Definition at line 514 of file multiVector.h.

Referenced by aol::testFirstDerivativeMultiVectorAllDirections(), and aol::testFirstDerivativeMultiVectorSingleComponentAllDirections().

                                       {
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it ) {
      if ( !it->ptr ) {
        throw Exception ( "MultiVector::setAll( const DataType value ): it->ptr == NULL !", __FILE__, __LINE__ );
      }
      it->ptr->setAll ( value );
    }
  }

template<typename _DataType>
Vec2<int> aol::MultiVector< _DataType >::setIthComponent ( const int  I,
const RealType  Value 
) [inline]

set value at position I, 0 <= I <= getTotalSize()-1 ( needed by aol::DerivativeValidatorBase<> )

Definition at line 542 of file multiVector.h.

                                                                  {
    int i, j;
    for (i = 0, j = I; j >= (*this)[i].size(); j -= (*this)[i++].size()) ;
    (*this)[i][j] = Value;
    Vec2<int> res(i,j);
    return res;
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::setVectorRef ( int  Index,
Vector< DataType > &  Vec,
bool  deleteFlag = false 
) [inline]

Definition at line 575 of file multiVector.h.

                                                                                  {
    if ( Index >= static_cast<int> ( vecs.size() ) ) {
      throw Exception ( "MultiVector::setVectorRef: index out of bounds.\n", __FILE__, __LINE__ );
    }
    if ( vecs[ Index ].ptr && vecs[ Index ].deleteFlag ) {
      delete vecs[ Index ].ptr;
    }
    vecs[ Index ].ptr = &Vec;
    vecs[ Index ].deleteFlag = deleteFlag;
  }

template<typename _DataType>
void aol::MultiVector< _DataType >::setZero (  )  [inline]
template<typename _DataType>
void aol::MultiVector< _DataType >::threshold ( const DataType  ThresholdValue,
const DataType  A,
const DataType  B 
) [inline]

All entries of all vectors bigger then ThresholdValue are set to B, all others are set to A.

Definition at line 561 of file multiVector.h.

                                                                                       {
    for ( typename vector<vec_entry>::iterator it = vecs.begin(); it != vecs.end(); ++it ) {
      if ( !it->ptr ) {
        throw Exception ( "MultiVector::threshold ( const DataType ThresholdValue, const DataType A, const DataType B ): it->ptr == NULL !", __FILE__, __LINE__ );
      }
      it->ptr->threshold( ThresholdValue, A, B );
    }
  }


Member Data Documentation

template<typename _DataType>
const int aol::MultiVector< _DataType >::Depth = 2 [static]

Definition at line 23 of file multiVector.h.

template<typename _DataType>
vector<vec_entry> aol::MultiVector< _DataType >::vecs [mutable, protected]

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

Generated on Fri Sep 9 2011 21:09:10 for QuocMesh by doxygen 1.7.1