QuOc

 

Public Member Functions | Protected Types

aol::VectorContainer< DataType > Class Template Reference

#include <vectorExtensions.h>

Inheritance diagram for aol::VectorContainer< DataType >:
aol::RandomAccessContainer< DataType >

List of all members.

Public Member Functions

 VectorContainer ()
 VectorContainer (const int Size)
 VectorContainer (const int Size, const DataType &Datum)
 VectorContainer (const VectorContainer< DataType > &other, CopyFlag copyFlag=DEEP_COPY)
void setZero ()
VectorContainer< DataType > & operator+= (const VectorContainer< DataType > &other)
VectorContainer< DataType > & operator*= (const RealType value)
VectorContainer< DataType > & addMultiple (const VectorContainer< DataType > &other, const RealType value)
RealType normSqr () const
RealType norm () const
RealType dotProduct (const VectorContainer< DataType > &other) const
RealType operator* (const VectorContainer< DataType > &other) const

Protected Types

typedef aol::RealTrait
< DataType >::RealType 
RealType

Detailed Description

template<typename DataType>
class aol::VectorContainer< DataType >

A RandomAccessContainer that additionally provides functionalities similar to Vector (and hence can be used just as a Vector).

Author:
Wirth

Definition at line 129 of file vectorExtensions.h.


Member Typedef Documentation

template<typename DataType>
typedef aol::RealTrait<DataType>::RealType aol::VectorContainer< DataType >::RealType [protected]

Definition at line 133 of file vectorExtensions.h.


Constructor & Destructor Documentation

template<typename DataType>
aol::VectorContainer< DataType >::VectorContainer (  )  [inline]

Definition at line 136 of file vectorExtensions.h.

                    :
    RandomAccessContainer<DataType>() {}

template<typename DataType>
aol::VectorContainer< DataType >::VectorContainer ( const int  Size  )  [inline, explicit]

Definition at line 139 of file vectorExtensions.h.

                                             :
    RandomAccessContainer<DataType>( Size ) {}

template<typename DataType>
aol::VectorContainer< DataType >::VectorContainer ( const int  Size,
const DataType Datum 
) [inline]

Definition at line 142 of file vectorExtensions.h.

                                                            :
    RandomAccessContainer<DataType>( Size, Datum ) {}

template<typename DataType>
aol::VectorContainer< DataType >::VectorContainer ( const VectorContainer< DataType > &  other,
CopyFlag  copyFlag = DEEP_COPY 
) [inline]

Definition at line 145 of file vectorExtensions.h.

References aol::RandomAccessContainer< DataType >::_data, aol::DEEP_COPY, aol::RandomAccessContainer< DataType >::size(), and aol::STRUCT_COPY.

                                                                                            :
    RandomAccessContainer<DataType>() {

    // assume that DataType has a copy-constructor wiht copyFlag argument
    if (copyFlag == DEEP_COPY || copyFlag == STRUCT_COPY) {
      this->_data.reserve ( other.size() );
      for ( int i = 0; i < other.size(); ++i )
        this->_data.push_back ( new DataType ( other[i], copyFlag ) );
    }
    else
      throw aol::Exception ( "aol::VectorContainer<DataType>::VectorContainer( VectorContainer& Data, CopyFlag copyFlag ): illegal copy flag", __FILE__, __LINE__ );
  }


Member Function Documentation

template<typename DataType>
VectorContainer<DataType>& aol::VectorContainer< DataType >::addMultiple ( const VectorContainer< DataType > &  other,
const RealType  value 
) [inline]

Definition at line 175 of file vectorExtensions.h.

References aol::RandomAccessContainer< DataType >::size().

Referenced by aol::VectorContainer< DataType >::operator+=().

                                                                                                          {

    if ( this->size() != other.size() )
      throw aol::Exception ( "aol::VectorContainer::addMultiple: sizes don't match", __FILE__, __LINE__ );

    for ( int i = 0; i < this->size(); ++i )
      (*this)[i].addMultiple( other[i], value );
    return *this;
  }

template<typename DataType>
RealType aol::VectorContainer< DataType >::dotProduct ( const VectorContainer< DataType > &  other  )  const [inline]

Definition at line 197 of file vectorExtensions.h.

References aol::VectorContainer< DataType >::operator*().

                                                                        {

    return this->operator*( other );
  }

template<typename DataType>
RealType aol::VectorContainer< DataType >::norm (  )  const [inline]

Definition at line 192 of file vectorExtensions.h.

References aol::VectorContainer< DataType >::normSqr().

                        {
    return sqrt ( normSqr() );
  }

template<typename DataType>
RealType aol::VectorContainer< DataType >::normSqr (  )  const [inline]

Definition at line 185 of file vectorExtensions.h.

References aol::RandomAccessContainer< DataType >::size().

Referenced by aol::VectorContainer< DataType >::norm().

                           {
    RealType s = aol::ZOTrait<RealType>::zero;
    for ( int i = 0; i < this->size(); ++i )
      s += static_cast<RealType>( (*this)[i].normSqr() );
    return s;
  }

template<typename DataType>
RealType aol::VectorContainer< DataType >::operator* ( const VectorContainer< DataType > &  other  )  const [inline]

Definition at line 203 of file vectorExtensions.h.

References aol::RandomAccessContainer< DataType >::size().

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

                                                                          {

    if( this->size() != other.size())
      throw Exception ( "aol::VectorContainer<DataType>::operator* : dimensions don't match.", __FILE__, __LINE__ );

    RealType dot = aol::ZOTrait<RealType>::zero;
    for ( int i = 0; i < this->size(); ++i )
      dot += (*this)[i].dotProduct( other[i] ) ;
    return dot;
  }

template<typename DataType>
VectorContainer<DataType>& aol::VectorContainer< DataType >::operator*= ( const RealType  value  )  [inline]

Definition at line 168 of file vectorExtensions.h.

References aol::RandomAccessContainer< DataType >::size().

                                                                  {

    for ( int i = 0; i < this->size(); ++i )
      (*this)[i] *= value;
    return *this;
  }

template<typename DataType>
VectorContainer<DataType>& aol::VectorContainer< DataType >::operator+= ( const VectorContainer< DataType > &  other  )  [inline]
template<typename DataType>
void aol::VectorContainer< DataType >::setZero (  )  [inline]

Definition at line 159 of file vectorExtensions.h.

References aol::RandomAccessContainer< DataType >::size().

                 {
    for ( int i = 0; i < this->size(); ++i )
      (*this)[i].setZero();
  }


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

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