QuOc

 

Public Member Functions | Private Member Functions

nb::SubGridSparseMatrix< DataType, ConfigType > Class Template Reference

#include <subGridSparseMatrix.h>

Inheritance diagram for nb::SubGridSparseMatrix< DataType, ConfigType >:
aol::GenSparseMatrix< DataType > aol::Matrix< DataType > aol::MatrixAbstractBase< DataType > aol::GenSparseOp< DataType > aol::Op< aol::Vector< DataType > >

List of all members.

Public Member Functions

 SubGridSparseMatrix (const ConfigType &config)
 SubGridSparseMatrix (const typename ConfigType::InitType &grid)
 SubGridSparseMatrix (int numGlobalDofs)
 SubGridSparseMatrix (const SubGridSparseMatrix &mat, aol::CopyFlag copyFlag=aol::DEEP_COPY)
virtual ~SubGridSparseMatrix ()
virtual aol::SparseRow
< DataType > * 
newDefaultRow () const
void rebuild (const ConfigType &config)
template<class T >
void addMatrixProduct (const aol::Matrix< T > &M1, const aol::Matrix< T > &M2)
void makeRowEntries (vector< typename aol::Row< DataType >::RowEntry > &vec, const int RowNum) const
 Return vector of row entries. Entries need not be sorted with respect to column index and zeros may be contained.
bool isRowSet (int r) const
int writeIndexTranslationSmallToLargeTo (aol::Vector< int > &translation) const
SubGridSparseMatrix< DataType,
ConfigType > & 
operator= (const SubGridSparseMatrix< DataType, ConfigType > &rhs)

Private Member Functions

void destroy ()

Detailed Description

template<typename DataType, typename ConfigType>
class nb::SubGridSparseMatrix< DataType, ConfigType >

a general, unstructured sparse matrix

Definition at line 36 of file subGridSparseMatrix.h.


Constructor & Destructor Documentation

template<typename DataType , typename ConfigType >
nb::SubGridSparseMatrix< DataType, ConfigType >::SubGridSparseMatrix ( const ConfigType &  config  ) 

Definition at line 163 of file subGridSparseMatrix.h.

References nb::SubGridSparseMatrix< DataType, ConfigType >::rebuild().

  : aol::GenSparseMatrix<DataType> ( config.getNumGlobalDofs(),
                                     config.getNumGlobalDofs() ) {
  rebuild ( config );
}

template<typename DataType , typename ConfigType >
nb::SubGridSparseMatrix< DataType, ConfigType >::SubGridSparseMatrix ( const typename ConfigType::InitType &  grid  ) 

Definition at line 173 of file subGridSparseMatrix.h.

References nb::SubGridSparseMatrix< DataType, ConfigType >::rebuild().

  : aol::GenSparseMatrix<DataType> ( qc::GridSize<ConfigType::DomDim> ( grid ) ) {
  rebuild ( ConfigType ( grid ) );
}

template<typename DataType , typename ConfigType >
nb::SubGridSparseMatrix< DataType, ConfigType >::SubGridSparseMatrix ( int  numGlobalDofs  ) 

Definition at line 182 of file subGridSparseMatrix.h.

  : aol::GenSparseMatrix<DataType> ( numGlobalDofs, numGlobalDofs ) {}

template<typename DataType , typename ConfigType >
nb::SubGridSparseMatrix< DataType, ConfigType >::SubGridSparseMatrix ( const SubGridSparseMatrix< DataType, ConfigType > &  mat,
aol::CopyFlag  copyFlag = aol::DEEP_COPY 
)

Definition at line 189 of file subGridSparseMatrix.h.

References aol::DEEP_COPY, aol::Matrix< _DataType >::format, aol::Matrix< DataType >::format, aol::GenSparseOp< DataType >::getNumRows(), aol::Matrix< _DataType >::prettyFormat, aol::Matrix< DataType >::prettyFormat, aol::GenSparseMatrix< DataType >::rows, and aol::STRUCT_COPY.

    : aol::GenSparseMatrix<DataType> ( mat.getNumRows(), mat.getNumCols() ) {
  // copy Matrix members other than M, N separately
  this->format = mat.format;
  this->prettyFormat = mat.prettyFormat;  
  
  switch ( copyFlag ) {
    case aol::STRUCT_COPY: {
      for ( int i = 0; i < this->getNumRows(); ++i )
      if ( mat.rows[i] )
        this->rows[i] = new aol::SparseRow<DataType>;
    }
    break;
    case aol::DEEP_COPY: {
      for ( int i = 0; i < this->getNumRows(); ++i )
      if ( mat.rows[i] )
        this->rows[i] = new aol::SparseRow<DataType> ( static_cast<const aol::SparseRow<DataType> & > ( * ( mat.rows[i] ) ) );  
    }
    break;
    default: {
    throw aol::UnimplementedCodeException ( "This CopyFlag is not implemented yet.", __FILE__, __LINE__ );
    }
    break;
  }
}

template<typename DataType , typename ConfigType >
nb::SubGridSparseMatrix< DataType, ConfigType >::~SubGridSparseMatrix (  )  [virtual]

Member Function Documentation

template<typename DataType , typename ConfigType >
template<class T >
void nb::SubGridSparseMatrix< DataType, ConfigType >::addMatrixProduct ( const aol::Matrix< T > &  M1,
const aol::Matrix< T > &  M2 
)

Definition at line 254 of file subGridSparseMatrix.h.

References aol::GenSparseMatrix< DataType >::add(), aol::GenSparseOp< _DataType >::getNumCols(), aol::GenSparseOp< DataType >::getNumCols(), aol::GenSparseOp< _DataType >::getNumRows(), aol::GenSparseOp< DataType >::getNumRows(), aol::MatrixAbstractBase< _DataType >::makeRowEntries(), and aol::GenSparseMatrix< DataType >::rows.

                                                                    {
  // cerr << "calling SubGridSparseMatrix::addMatrixProduct()\n";
  if (    this->getNumRows( ) != M1.getNumRows()
          || this->getNumCols( ) != M2.getNumCols( )
          || M1.getNumCols() != M2.getNumRows() )
    throw aol::Exception ( "aol::Matrix::addMatrixProduct(): incompatible "
                           "matrix sizes.\n", __FILE__, __LINE__ );

  vector<typename aol::Row<T>::RowEntry > vec1, vec2;

  for ( int i = 0; i < this->getNumRows(); i++ )
    if ( this->rows[i] ) {
      M1.makeRowEntries ( vec1, i );
      typename vector<typename aol::Row<T>::RowEntry >::iterator it1;
      for ( it1 = vec1.begin(); it1 != vec1.end(); ++it1 ) {
        M2.makeRowEntries ( vec2, it1->col );
        typename vector<typename aol::Row<T>::RowEntry >::iterator it2;
        for ( it2 = vec2.begin(); it2 != vec2.end(); ++it2 ) {
          if ( !this->rows[i] )
            cerr << it1->value * it2->value << " ";
          else
            add ( i, it2->col, this->getUnsetRowsDiagEntry() * it1->value * it2->value );
        }
      }
    }
}

template<typename DataType , typename ConfigType >
void nb::SubGridSparseMatrix< DataType, ConfigType >::destroy (  )  [private]

Definition at line 357 of file subGridSparseMatrix.h.

References aol::GenSparseMatrix< DataType >::rows.

Referenced by nb::SubGridSparseMatrix< DataType, ConfigType >::~SubGridSparseMatrix().

          {
  for ( unsigned int i = 0; i < this->rows.size(); i++ ) {
    delete this->rows[ i ];
  }
}

template<typename DataType , typename ConfigType >
bool nb::SubGridSparseMatrix< DataType, ConfigType >::isRowSet ( int  r  )  const
template<typename DataType , typename ConfigType >
void nb::SubGridSparseMatrix< DataType, ConfigType >::makeRowEntries ( vector< typename aol::Row< DataType >::RowEntry > &  vec,
const int  RowNum 
) const [virtual]

Return vector of row entries. Entries need not be sorted with respect to column index and zeros may be contained.

Reimplemented from aol::GenSparseMatrix< DataType >.

Definition at line 285 of file subGridSparseMatrix.h.

References aol::GenSparseMatrix< DataType >::getUnsetRowsDiagEntry(), and aol::GenSparseMatrix< DataType >::rows.

                                                                                           {
  if ( this->rows[RowNum] ) {
    static_cast<aol::SparseRow<DataType>* > ( this->rows[RowNum] )->makeRowEntries ( vec, RowNum );
  } else {
    // nothing saved: return row from identity matrix.
    vec.resize ( 1 );
    vec[0].col = RowNum;
    vec[0].value = this->getUnsetRowsDiagEntry();
  }
}

template<typename DataType , typename ConfigType >
aol::SparseRow< DataType > * nb::SubGridSparseMatrix< DataType, ConfigType >::newDefaultRow (  )  const [virtual]
template<typename DataType, typename ConfigType>
SubGridSparseMatrix<DataType, ConfigType>& nb::SubGridSparseMatrix< DataType, ConfigType >::operator= ( const SubGridSparseMatrix< DataType, ConfigType > &  rhs  ) 
template<typename DataType , typename ConfigType >
void nb::SubGridSparseMatrix< DataType, ConfigType >::rebuild ( const ConfigType &  config  ) 

Definition at line 235 of file subGridSparseMatrix.h.

References aol::GenSparseOp< DataType >::getNumRows(), nb::SubGridSparseMatrix< DataType, ConfigType >::newDefaultRow(), and aol::GenSparseMatrix< DataType >::rows.

Referenced by nb::SubGridSparseMatrix< DataType, ConfigType >::SubGridSparseMatrix().

                                     {
  for ( int i = 0; i < this->getNumRows(); i++ ) {
    if ( this->rows[i] ) {
      delete this->rows[i];
      this->rows[i] = NULL;
    }
  }
  typename ConfigType::MaskType nodeExistMask ( qc::GridSize<ConfigType::Dim> ( config.getInitializer() ) );
  config.writeNodeExistMaskTo ( nodeExistMask );
  for (int i = 0; i < nodeExistMask.size(); ++i)
    if ( nodeExistMask[i] && !this->rows[i] )
      this->rows[i] = newDefaultRow();
}

template<typename DataType , typename ConfigType >
int nb::SubGridSparseMatrix< DataType, ConfigType >::writeIndexTranslationSmallToLargeTo ( aol::Vector< int > &  translation  )  const

Definition at line 308 of file subGridSparseMatrix.h.

References aol::GenSparseOp< DataType >::getNumRows(), nb::SubGridSparseMatrix< DataType, ConfigType >::isRowSet(), and aol::Vector< _DataType >::resize().

                                                                           {
  translation.resize ( this->getNumRows() );
  int index = 0;
  for ( int i = 0; i < this->getNumRows(); ++i )
    if ( isRowSet ( i ) )
      translation[index++] = i;
  translation.resize ( index );
  return index;
}


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

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