/*************************************************************************** * blitz/tinymat.h Declaration of TinyMatrix * * $Id: tinymat.h,v 1.1.1.1 1999-04-09 17:59:01 ansari Exp $ * * Copyright (C) 1997,1998 Todd Veldhuizen * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Suggestions: blitz-suggest@cybervision.com * Bugs: blitz-bugs@cybervision.com * * For more information, please see the Blitz++ Home Page: * http://seurat.uwaterloo.ca/blitz/ * *************************************************************************** * $Log: not supported by cvs2svn $ * Revision 1.2 1998/03/14 00:04:47 tveldhui * 0.2-alpha-05 * * Revision 1.1 1997/07/16 14:51:20 tveldhui * Update: Alpha release 0.2 (Arrays) * */ #ifndef BZ_TINYMAT_H #define BZ_TINYMAT_H #ifndef BZ_BLITZ_H #include #endif #ifndef BZ_TINYVEC_H #include #endif #ifndef BZ_LISTINIT_H #include #endif #include #include BZ_NAMESPACE(blitz) // Forward declarations template class _bz_tinyMatExpr; template class _bz_tinyMatrixRef { public: _bz_tinyMatrixRef(T_numtype* _bz_restrict const data) : data_(data) { } T_numtype * _bz_restrict data() { return (T_numtype * _bz_restrict)data_; } T_numtype& _bz_restrict operator()(int i, int j) { return data_[i * N_rowStride + j * N_colStride]; } T_numtype operator()(int i, int j) const { return data_[i * N_rowStride + j * N_colStride]; } protected: T_numtype * _bz_restrict const data_; }; template class TinyMatrix { public: typedef P_numtype T_numtype; typedef _bz_tinyMatrixRef T_reference; typedef TinyMatrix T_matrix; TinyMatrix() { } T_numtype* _bz_restrict data() { return data_; } const T_numtype* _bz_restrict data() const { return data_; } T_numtype* _bz_restrict dataFirst() { return data_; } const T_numtype* _bz_restrict dataFirst() const { return data_; } // NEEDS_WORK -- precondition checks T_numtype& _bz_restrict operator()(int i, int j) { return data_[i*N_columns + j]; } T_numtype operator()(int i, int j) const { return data_[i*N_columns + j]; } T_reference getRef() { return T_reference((T_numtype*)data_); } const T_reference getRef() const { return T_reference((T_numtype*)data_); } // Scalar operand ListInitializationSwitch operator=(T_numtype x) { return ListInitializationSwitch(*this, x); } template TinyMatrix& operator=(_bz_tinyMatExpr expr) { _bz_meta_matAssign::f(*this, expr, _bz_update()); return *this; } // NEEDS_WORK -- not implemented void initialize(T_numtype x) { BZ_NOT_IMPLEMENTED(); } T_numtype* _bz_restrict getInitializationIterator() { return dataFirst(); } protected: T_numtype data_[N_rows * N_columns]; }; BZ_NAMESPACE_END #include // Matrix-vector product metaprogram #include // Matrix-matrix products #endif // BZ_TINYMAT_H