tngmath::MathDynSparseArrayBase< Scalar > Class Template Reference

#include <dynamicsparsematrixbase.hpp>

Inheritance diagram for tngmath::MathDynSparseArrayBase< Scalar >:

Inheritance graph
[legend]
Collaboration diagram for tngmath::MathDynSparseArrayBase< Scalar >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef
Eigen::DynamicSparseMatrix
< Scalar > 
Base
typedef double RealScalar
typedef int TIndex
typedef Scalar TScalar

Public Member Functions

 MathDynSparseArrayBase (const TIndex &nrow, const TIndex &ncol=1)
 constructs a nrow*ncol matrix
 MathDynSparseArrayBase (const Base &x)
 copy constructor from Eigen objects
template<typename OtherDerived>
 MathDynSparseArrayBase (const Eigen::SparseMatrixBase< OtherDerived > &x)
 copy constructor from Eigen objects
 MathDynSparseArrayBase (const MathDynSparseArrayBase< TScalar > &ar)
 copy constructor
 MathDynSparseArrayBase ()
 default constructor
MathDynSparseArrayBase< TScalar > & operator= (const Base &other)
 The '=' operator for sparse matrix type Eigen::SparseMatrix.
template<typename OtherDerived>
MathDynSparseArrayBase< TScalar > & operator= (const Eigen::SparseMatrixBase< OtherDerived > &other)
 The '=' operator for Eigen sparse matrix types.
void Swap (MathDynSparseArrayBase< TScalar > &other)
 swaps the data pointers of both objects (fastest way to transfer data)
virtual ~MathDynSparseArrayBase ()


Detailed Description

template<typename Scalar>
class tngmath::MathDynSparseArrayBase< Scalar >

A class that represents storage for sparse linalg objects with random write access.

The storage scheme is column_major (FORTRAN). It basically provides basic features of the Eigen::DynamicSparseMatrix class, i.e. basic operators and assembly methods.

The storage scheme is described in the Eigen doc in detail. It should be noted that one can view any column_major sparse matrix as a set of 'ncols' sparse vectors. The sparse vectors are labeled by the index i ("outer iterator"), the access of the elements within these vectors is labeled by the Eigen::InnerIterator object it ("inner iterator"/ "inner loop").

In comparison to MathSparseArrayBase, MathDynSparseArrayBase requires more storage since the sparse vectors are directly used as storage containers, not only as mappers onto a single data array. As a result, DynMatrix ("dynamic matrix storage") provides more flexible assembly methods. A few math operations are slower, see the Eigen doc for details.

The following methods can be used for storage:

(1) Sorted fill

                                SparseMatrix\<double,ColMajor> m(rows,cols);
                                m.startFill(rows*cols*percent_of_non_zero); // estimate of the number of nonzeros (optional)
                                for (int j=0; j\<cols; ++j)
                                        for (int i=0; i\<rows; ++i)
                                                if (rand()\<percent_of_non_zero)
                                                        m.fill(i,j) = rand();
                                m.endFill();

One has to fill the elements according to their internal index sort order (2) Fill by random inner access Herein one has to fill each outer index in its given sort order, but may fill the items into the currently active sparse vector in random order:

                                SparseMatrix\<double,ColMajor> m(rows,cols);
                                m.startFill(rows*cols*percent_of_non_zero); // estimate of the number of nonzeros (optional)
                                for (int k=0; k\<cols; ++k)
                                for (int i=0; i\<rows*percent_of_non_zero; ++i)
                                        m.fillrand(i,rand(0,cols)) = rand();
                                m.endFill();
(3) Complete random access Using the 'coeff' and 'coeffRef' methods a dynamic matrix can be filled and read like a dense matrix.
                                DynamicSparseMatrix\<float> aux(1000,1000);
                                for (...)
                                for each i
                                        for each j interacting with i
                                        aux.coeffRef(i,j) += foo(o1,o2);
                                SparseMatrix\<float> mat(aux); // convert the DynamicSparseMatrix to a SparseMatrix

Constructor & Destructor Documentation

template<typename Scalar>
virtual tngmath::MathDynSparseArrayBase< Scalar >::~MathDynSparseArrayBase (  )  [inline, virtual]

destructor


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

Generated on Wed Nov 17 17:35:51 2010 for 'tngmath' Module Programming Interface by  doxygen 1.5.6