Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

colvarmodule::matrix2d< T, outer_length, inner_length > Class Template Reference

Arbitrary size array (two dimensions) suitable for linear algebra operations (i.e. for floating point numbers it can be used with library functions). More...

#include <colvartypes.h>

List of all members.

Public Member Functions

void alloc ()
 Allocation routine, used by all constructors.
void reset ()
 Set all elements to zero.
 matrix2d ()
 Default constructor.
 matrix2d (T const **m)
 Constructor from a 2-d C array.
 matrix2d (matrix2d< T, outer_length, inner_length > const &m)
 Copy constructor.
matrix2d< T, outer_length,
inner_length > & 
operator= (matrix2d< T, outer_length, inner_length > const &m)
 Assignment.
 ~matrix2d ()
 Destructor.
T ** c_array ()
 Return the 2-d C array.
 operator T ** ()
 Return the 2-d C array.

Protected Attributes

T ** array
 Underlying C array.

Friends

std::ostream & operator<< (std::ostream &os, matrix2d< T, outer_length, inner_length > const &m)
 Formatted output.


Detailed Description

template<class T, size_t const outer_length, size_t const inner_length>
class colvarmodule::matrix2d< T, outer_length, inner_length >

Arbitrary size array (two dimensions) suitable for linear algebra operations (i.e. for floating point numbers it can be used with library functions).

Definition at line 277 of file colvartypes.h.


Constructor & Destructor Documentation

template<class T, size_t const outer_length, size_t const inner_length>
colvarmodule::matrix2d< T, outer_length, inner_length >::matrix2d  )  [inline]
 

Default constructor.

Definition at line 305 of file colvartypes.h.

00306   {
00307     this->alloc();
00308     reset();
00309   }

template<class T, size_t const outer_length, size_t const inner_length>
colvarmodule::matrix2d< T, outer_length, inner_length >::matrix2d T const **  m  )  [inline]
 

Constructor from a 2-d C array.

Definition at line 312 of file colvartypes.h.

00313   {
00314     this->alloc();
00315     for (size_t i = 0; i < outer_length; i++) {
00316       for (size_t j = 0; j < inner_length; j++)
00317         array[i][j] = m[i][j];
00318     }
00319   }

template<class T, size_t const outer_length, size_t const inner_length>
colvarmodule::matrix2d< T, outer_length, inner_length >::matrix2d matrix2d< T, outer_length, inner_length > const &  m  )  [inline]
 

Copy constructor.

Definition at line 322 of file colvartypes.h.

00323   {
00324     this->alloc();
00325     for (size_t i = 0; i < outer_length; i++) {
00326       for (size_t j = 0; j < inner_length; j++)
00327         this->array[i][j] = m.array[i][j];
00328     }
00329   }

template<class T, size_t const outer_length, size_t const inner_length>
colvarmodule::matrix2d< T, outer_length, inner_length >::~matrix2d  )  [inline]
 

Destructor.

Definition at line 343 of file colvartypes.h.

00343                      {
00344     for (size_t i = 0; i < outer_length; i++) {
00345       delete [] array[i];
00346     }
00347     delete [] array;
00348   }


Member Function Documentation

template<class T, size_t const outer_length, size_t const inner_length>
void colvarmodule::matrix2d< T, outer_length, inner_length >::alloc  )  [inline]
 

Allocation routine, used by all constructors.

Definition at line 287 of file colvartypes.h.

00287                       {
00288     array = new T * [outer_length];
00289     for (size_t i = 0; i < outer_length; i++) {
00290       array[i] = new T [inner_length];
00291     }
00292   }

template<class T, size_t const outer_length, size_t const inner_length>
T** colvarmodule::matrix2d< T, outer_length, inner_length >::c_array  )  [inline]
 

Return the 2-d C array.

Definition at line 351 of file colvartypes.h.

00351 { return array; }

template<class T, size_t const outer_length, size_t const inner_length>
colvarmodule::matrix2d< T, outer_length, inner_length >::operator T **  )  [inline]
 

Return the 2-d C array.

Definition at line 354 of file colvartypes.h.

00354 { return array; }

template<class T, size_t const outer_length, size_t const inner_length>
matrix2d<T, outer_length, inner_length>& colvarmodule::matrix2d< T, outer_length, inner_length >::operator= matrix2d< T, outer_length, inner_length > const &  m  )  [inline]
 

Assignment.

Definition at line 333 of file colvartypes.h.

00334   {
00335     for (size_t i = 0; i < outer_length; i++) {
00336       for (size_t j = 0; j < inner_length; j++)
00337         this->array[i][j] = m.array[i][j];
00338     }
00339     return *this;
00340   }

template<class T, size_t const outer_length, size_t const inner_length>
void colvarmodule::matrix2d< T, outer_length, inner_length >::reset  )  [inline]
 

Set all elements to zero.

Definition at line 295 of file colvartypes.h.

00296   {
00297     for (size_t i = 0; i < outer_length; i++) {
00298       for (size_t j = 0; j < inner_length; j++) {
00299         array[i][j] = T (0.0);
00300       }
00301     }
00302   }


Friends And Related Function Documentation

template<class T, size_t const outer_length, size_t const inner_length>
std::ostream& operator<< std::ostream &  os,
matrix2d< T, outer_length, inner_length > const &  m
[friend]
 

Formatted output.

Definition at line 381 of file colvartypes.h.

00383   {
00384     std::streamsize const w = os.width();
00385     std::streamsize const p = os.precision();
00386 
00387     os << "(";
00388     for (size_t i = 0; i < outer_length; i++) {
00389       os << " ( ";
00390       for (size_t j = 0; j < inner_length-1; j++) {
00391         os.width (w);
00392         os.precision (p);
00393         os << m.array[i][j] << " , ";
00394       }
00395       os.width (w);
00396       os.precision (p);
00397       os << m.array[i][inner_length-1] << " )";
00398     }
00399 
00400     os << " )";
00401     return os;
00402   }


Member Data Documentation

template<class T, size_t const outer_length, size_t const inner_length>
T** colvarmodule::matrix2d< T, outer_length, inner_length >::array [protected]
 

Underlying C array.

Definition at line 282 of file colvartypes.h.

Referenced by colvarmodule::matrix2d< colvarmodule::real, 3, 3 >::matrix2d(), and colvarmodule::matrix2d< colvarmodule::real, 3, 3 >::operator=().


The documentation for this class was generated from the following file:
Generated on Tue Nov 24 04:07:48 2009 for NAMD by  doxygen 1.3.9.1