Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef RefMatrix_h
00013 #define RefMatrix_h
00014
00015 #include <cassert>
00016
00017 #include "lkptr.h"
00018 #include "Matrix.h"
00019
00020
00021 namespace std {}
00022
00023
00024 namespace Mx {
00025
00026
00027 template <class E>
00028 class RefMatrix : public Mx::Matrix<E> {
00029 public:
00030 RefMatrix(unsigned m = 1, unsigned n = 1) : Matrix<E>(m,n) { }
00031 RefMatrix(const RefMatrix& o) : Matrix<E>(o) { }
00032 RefMatrix(const E& V) : Matrix<E>(V) { }
00033 ~RefMatrix() {}
00034 public:
00035
00036 RefMatrix<E>* clone() const { return new RefMatrix<E>(*this); }
00037 friend lkptr<RefMatrix> operator + (const lkptr<RefMatrix>& A, const lkptr<RefMatrix>& B)
00038 { lkptr<RefMatrix> Res ( A->clone() ); Res->add(*B); return Res; }
00039 friend lkptr<RefMatrix> operator - (const lkptr<RefMatrix>& A, const lkptr<RefMatrix>& B)
00040 { lkptr<RefMatrix> Res ( A->clone() ); Res->substract(*B); return Res; }
00041 friend lkptr<RefMatrix> operator * (const lkptr<RefMatrix>& A, const lkptr<RefMatrix>& B)
00042 { RefMatrix *Res = new RefMatrix( A->rows(), B->cols() );
00043 Res->multiply(*A, *B); return lkptr<RefMatrix>( Res ); }
00044 #if 0
00045 {
00046 lkptr< RefMatrix<unsigned> > rV ( new RefMatrix<unsigned>(M,N) );
00047 RefMatrix<unsigned>& VV = *rV;
00048
00049 for (i=0; i < rV->rows(); ++i) {
00050 for (j=0; j < rV->cols(); ++j,++k) {
00051 assert( rV->at(i,j) == VV(i,j) );
00052 assert( &rV->at(i,j) == &VV(i,j) );
00053 }
00054 }
00055 }
00056 #else
00057
00058
00059 #endif
00060 };
00061
00062 }
00063
00064 #endif // RefMatrix_h
00065