Generated on Mon Jun 23 16:24:56 2008 for BIU-1.7.0 by doxygen 1.5.1

src/biu/SquareMatrix.hh

Go to the documentation of this file.
00001 #ifndef SQUAREMATRIX_HH_
00002 #define SQUAREMATRIX_HH_
00003 
00004 
00005 #include "Matrix.hh"
00006 
00007 namespace biu
00008 {
00009 
00013     template <class T, size_t matrixDim>
00014     class SquareMatrix : public Matrix<T>
00015     {
00016     public:
00018         SquareMatrix();
00020         SquareMatrix(const SquareMatrix& m);
00022         SquareMatrix(const Matrix<T>& m);
00023     
00025         SquareMatrix(const T m[matrixDim][matrixDim]);
00026     
00027     
00028         ~SquareMatrix();
00029         
00030         static SquareMatrix<T,matrixDim> createSquareMatrix(const T  data[matrixDim][matrixDim]);
00031         
00032     };
00033     
00034     
00035     /* IMPLEMENTIERUNG */
00036     
00037     //construction
00038     template <class T, size_t matrixDim> inline 
00039     SquareMatrix<T,matrixDim>::SquareMatrix() :
00040         Matrix<T>(matrixDim, matrixDim)
00041     {
00042     }
00043     
00045     template <class T, size_t matrixDim> inline 
00046     SquareMatrix<T,matrixDim>::SquareMatrix(const T m[matrixDim][matrixDim])
00047     {
00048         *this = createSquareMatrix(m);
00049     }
00050     
00052     template <class T, size_t matrixDim> inline
00053     SquareMatrix<T,matrixDim>::SquareMatrix(const SquareMatrix& m) :
00054         Matrix<T>(m)
00055     {
00056     }
00057     
00058     template <class T, size_t matrixDim> inline
00059     SquareMatrix<T,matrixDim>::SquareMatrix(const Matrix<T>& m) :
00060         Matrix<T>(m)
00061     {
00062         // m has to be a square matrix of the correct size
00063         assert(m.numRows() == matrixDim && m.numColumns() == matrixDim);    
00064     }
00065     
00066     
00067     
00068     // destruction
00069     template <class T, size_t matrixDim> inline
00070     SquareMatrix<T,matrixDim>::~SquareMatrix ()
00071     {
00072     }
00073     
00074     // construct and fill
00075     #include <iostream>
00076     template <class T, size_t matrixDim> inline 
00077     SquareMatrix<T,matrixDim>
00078     SquareMatrix<T,matrixDim>::createSquareMatrix(const T  data[matrixDim][matrixDim]) 
00079     {
00080         SquareMatrix<T,matrixDim> matrix;
00081         for (size_t row=0; row < matrixDim; row++)
00082         {
00083             for (size_t col=0; col<matrixDim; col++) {
00084                 matrix[row][col] = data[row][col];
00085             }
00086         }
00087         return matrix;
00088     }
00089     
00090     
00091 
00092 } // namespace biu
00093 
00094 #endif /*SQUAREMATRIX_HH_*/