#include "machdefs.h" #include "pexceptions.h" #include #include "smtx.h" //-------------------------------------------------------- // Test d'expression template sur tableaux // Reza - Avril 2003 //-------------------------------------------------------- // --------------------------------------------------- // ------------- Classe de matrice ------------------- // --------------------------------------------------- template SimpleMatrix::SimpleMatrix() : MtxSize(), JETExpression >(), dbv_(&data_, this), data_p_(NULL) { this->Expression().JETExpMtxSet(&data_, this); } template SimpleMatrix::SimpleMatrix(sa_size_t nr, sa_size_t nc) : MtxSize(nr, nc), JETExpression >(), data_(nr*nc), dbv_(&data_, this), data_p_(data_.Begin()) { this->Expression().JETExpMtxSet(&data_, this); } template SimpleMatrix::SimpleMatrix(const SimpleMatrix & m) : MtxSize(m), JETExpression >(), data_(m.data_), dbv_(&data_, this), data_p_(data_.Begin()) { this->Expression().JETExpMtxSet(&data_, this); } template SimpleMatrix::SimpleMatrix(const SimpleMatrix & m, bool share) : MtxSize(m), JETExpression >(dbv_), data_(m.data_, share), dbv_(&data_, this), data_p_(data_.Begin()) { } template SimpleMatrix::~SimpleMatrix() { } template void SimpleMatrix::ReSize(const MtxSize & a) { if (CompareSize(a)) return; if (this == &a) return; MtxSize::ReSize(a); data_.Realloc(nrow_*ncol_); data_p_=data_.Begin(); return; } template SimpleMatrix& SimpleMatrix::Set(const SimpleMatrix & b) { if (this == &b) return(*this); if ((b.nrow_ == 0) || (b.ncol_ == 0) ) throw RangeCheckError("SimpleMatrix::Set() Size(b) = 0"); if (nrow_ == 0) { nrow_ = b.nrow_; ncol_ = b.ncol_; } else if ((nrow_ > 0) && ((nrow_ != b.nrow_) || (ncol_ != b.ncol_)) ) throw(SzMismatchError("SimpleMatrix::Set() Size(a) != Size(b)")); data_ = b.data_; data_p_=data_.Begin(); return(*this); } template SimpleMatrix& SimpleMatrix::Init(T c) { if ((nrow_ == 0) || (ncol_ == 0)) throw RangeCheckError("SimpleMatrix::Init(T c) Size=0"); data_ = c; return(*this); } template SimpleMatrix& SimpleMatrix::Init(T c, T step) { if ((nrow_ == 0) || (ncol_ == 0)) throw RangeCheckError("SimpleMatrix::Init(T c. T s) Size=0"); for(sa_size_t k=0; k void SimpleMatrix::Print(ostream& os) const { os << " SimpleMatrix(nr=" << nrow_ << ",nc=" << ncol_ << ")" << endl; for(sa_size_t r=0; r SimpleMatrix& SimpleMatrix::AddCst(T c) { if ((nrow_ == 0) || (ncol_ == 0)) throw RangeCheckError("SimpleMatrix::AddCst() Size=0"); data_ += c; return(*this); } template SimpleMatrix& SimpleMatrix::MulCst(T c) { if ((nrow_ == 0) || (ncol_ == 0)) throw RangeCheckError("SimpleMatrix::MulCst() Size=0"); data_ *= c; return(*this); } template SimpleMatrix& SimpleMatrix::AddElt(const SimpleMatrix & b) { if (! CompareSize(b) ) throw(SzMismatchError("SimpleMatrix::AddElt() Size(a) != Size(b)")); data_ += b.data_; return(*this); } template SimpleMatrix& SimpleMatrix::MulElt(const SimpleMatrix & b) { if (! CompareSize(b) ) throw(SzMismatchError("SimpleMatrix::MulElt() Size(a) != Size(b)")); data_ *= b.data_; return(*this); }