Atlfast::Matrix Class Reference

#include <Matrix.h>

List of all members.

Public Member Functions

 Matrix (size_t x, size_t y)
 Matrix (size_t x, size_t y, double init)
 Matrix (const Matrix &)
Matrixoperator= (const Matrix &)
 ~Matrix ()
size_t size () const
size_t dim1 () const
size_t dim2 () const
Slice_iter< double > row (size_t i)
Cslice_iter< double > row (size_t i) const
Slice_iter< double > column (size_t i)
Cslice_iter< double > column (size_t i) const
double & operator() (size_t x, size_t y)
double operator() (size_t x, size_t y) const
Slice_iter< double > operator() (size_t i)
Cslice_iter< double > operator() (size_t i) const
Slice_iter< double > operator[] (size_t i)
Cslice_iter< double > operator[] (size_t i) const
Matrixoperator *= (double)
valarray< double > & array ()
Matrix sub (size_t minRow, size_t maxRow, size_t minCol, size_t maxCol) const
void sub (size_t minRow, size_t minCol, Matrix &dest) const

Private Attributes

valarray< double > * m_v
size_t m_d1
size_t m_d2


Detailed Description

Definition at line 23 of file Matrix.h.


Constructor & Destructor Documentation

Atlfast::Matrix::Matrix ( size_t  x,
size_t  y 
)

Definition at line 7 of file Matrix.cxx.

00007                                   {
00008     m_d1=x;
00009     m_d2=y;
00010     m_v=new valarray<double>(x*y);
00011   }

Atlfast::Matrix::Matrix ( size_t  x,
size_t  y,
double  init 
)

Definition at line 13 of file Matrix.cxx.

00013                                                {
00014     m_d1=x;
00015     m_d2=y;
00016     m_v=new valarray<double>(x*y);
00017     for(size_t i=0; i<m_d1*m_d2; ++i)  m_v[i]=init;
00018   }

Atlfast::Matrix::Matrix ( const Matrix  ) 

Definition at line 6 of file Matrix.cxx.

00006 : m_v(m.m_v), m_d1(m.m_d1), m_d2(m.m_d2){}

Atlfast::Matrix::~Matrix (  ) 

Definition at line 5 of file Matrix.cxx.

00005 {}


Member Function Documentation

Matrix& Atlfast::Matrix::operator= ( const Matrix  ) 

size_t Atlfast::Matrix::size (  )  const [inline]

Definition at line 34 of file Matrix.h.

00034 {return m_d1*m_d2;}

size_t Atlfast::Matrix::dim1 (  )  const [inline]

Definition at line 35 of file Matrix.h.

00035 {return m_d1;}

size_t Atlfast::Matrix::dim2 (  )  const [inline]

Definition at line 36 of file Matrix.h.

00036 {return m_d2;}

Slice_iter< double > Atlfast::Matrix::row ( size_t  i  )  [inline]

Definition at line 61 of file Matrix.h.

00061                                                {
00062     return Slice_iter<double>(m_v, slice(i,m_d1,m_d2));
00063   }

Cslice_iter< double > Atlfast::Matrix::row ( size_t  i  )  const [inline]

Definition at line 65 of file Matrix.h.

00065                                                        {
00066     return Cslice_iter<double>(m_v, slice(i,m_d1,m_d2));
00067   }

Slice_iter< double > Atlfast::Matrix::column ( size_t  i  )  [inline]

Definition at line 69 of file Matrix.h.

00069                                                   {
00070     return Slice_iter<double>(m_v, slice(i*m_d2,m_d2,1));
00071   }

Cslice_iter< double > Atlfast::Matrix::column ( size_t  i  )  const [inline]

Definition at line 73 of file Matrix.h.

00073                                                           {
00074     return Cslice_iter<double>(m_v, slice(i*m_d2,m_d2,1));
00075   }

double & Atlfast::Matrix::operator() ( size_t  x,
size_t  y 
)

Definition at line 20 of file Matrix.cxx.

00020                                               {
00021     return column(x)[y];
00022   }

double Atlfast::Matrix::operator() ( size_t  x,
size_t  y 
) const

Slice_iter<double> Atlfast::Matrix::operator() ( size_t  i  )  [inline]

Definition at line 47 of file Matrix.h.

00047 {return column(i);}

Cslice_iter<double> Atlfast::Matrix::operator() ( size_t  i  )  const [inline]

Definition at line 48 of file Matrix.h.

00048 {return column(i);}

Slice_iter<double> Atlfast::Matrix::operator[] ( size_t  i  )  [inline]

Definition at line 50 of file Matrix.h.

00050 {return column(i);}

Cslice_iter<double> Atlfast::Matrix::operator[] ( size_t  i  )  const [inline]

Definition at line 51 of file Matrix.h.

00051 {return column(i);}

Matrix & Atlfast::Matrix::operator *= ( double   ) 

Definition at line 37 of file Matrix.cxx.

00037                                     {
00038     (*m_v) *= d;
00039     return *this;
00040   }

valarray<double>& Atlfast::Matrix::array (  )  [inline]

Definition at line 55 of file Matrix.h.

00055 {return *m_v;}

Matrix Atlfast::Matrix::sub ( size_t  minRow,
size_t  maxRow,
size_t  minCol,
size_t  maxCol 
) const

Definition at line 41 of file Matrix.cxx.

00042                                                         {
00043     size_t endRow=maxRow+1;
00044     size_t endCol=maxCol+1;
00045 
00046     assert(endRow<=m_d1);
00047     assert(endCol<=m_d2);
00048     assert(endRow>minRow);
00049     assert(endCol>minCol);
00050 
00051     size_t nRow=endRow-minRow;
00052     
00053     size_t nCol=endCol-minCol;
00054 
00055     Matrix m(nRow, nCol);
00056     size_t ii=0;
00057     size_t jj;
00058     for(size_t i = minRow; i<endRow; ++i){
00059       jj=0;
00060       for(size_t j = minCol; j<endCol; ++j) m[ii][jj++]=(*this)[i][j];
00061       ++ii;
00062     }
00063     assert(ii == endRow);
00064     assert(jj == endCol);
00065     return m;
00066   }

void Atlfast::Matrix::sub ( size_t  minRow,
size_t  minCol,
Matrix dest 
) const

Definition at line 67 of file Matrix.cxx.

00067                                                                {
00068     size_t endRow=minRow+m.m_d1;
00069     size_t endCol=minCol+m.m_d2;
00070 
00071     assert(endRow<=m_d1);
00072     assert(endCol<=m_d2);
00073     assert(endRow>minRow);
00074     assert(endCol>minCol);
00075 
00076     size_t ii=0;
00077     size_t jj;
00078     for(size_t i = minRow; i<endRow; ++i){
00079       jj=0;
00080       for(size_t j = minCol; j<endCol; ++j) m[ii][jj++]=(*this)[i][j];
00081       ++ii;
00082     }
00083     assert(ii == endRow);
00084     assert(jj == endCol);
00085     return;
00086   }


Member Data Documentation

valarray<double>* Atlfast::Matrix::m_v [private]

Definition at line 25 of file Matrix.h.

size_t Atlfast::Matrix::m_d1 [private]

Definition at line 26 of file Matrix.h.

size_t Atlfast::Matrix::m_d2 [private]

Definition at line 26 of file Matrix.h.


The documentation for this class was generated from the following files:
Generated on Fri Sep 21 13:20:56 2007 for AtlfastUtils by  doxygen 1.5.1