| [221] | 1 | /*
 | 
|---|
 | 2 |  * $Id: matrix.cc,v 1.1.1.1 1999-04-09 17:59:00 ansari Exp $
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  * Copyright (C) 1997 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
 | 
|---|
 | 5 |  * All rights reserved.  Please see <blitz/blitz.h> for terms and
 | 
|---|
 | 6 |  * conditions of use.
 | 
|---|
 | 7 |  *
 | 
|---|
 | 8 |  * $Log: not supported by cvs2svn $
 | 
|---|
 | 9 |  * Revision 1.4  1998/03/14 00:04:47  tveldhui
 | 
|---|
 | 10 |  * 0.2-alpha-05
 | 
|---|
 | 11 |  *
 | 
|---|
 | 12 |  * Revision 1.3  1997/07/16 14:51:20  tveldhui
 | 
|---|
 | 13 |  * Update: Alpha release 0.2 (Arrays)
 | 
|---|
 | 14 |  *
 | 
|---|
 | 15 |  * Revision 1.2  1997/01/24 14:42:00  tveldhui
 | 
|---|
 | 16 |  * Periodic RCS update
 | 
|---|
 | 17 |  *
 | 
|---|
 | 18 |  */
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | #ifndef BZ_MATRIX_CC
 | 
|---|
 | 21 | #define BZ_MATRIX_CC
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | #ifndef BZ_MATRIX_H
 | 
|---|
 | 24 |  #include <blitz/matrix.h>
 | 
|---|
 | 25 | #endif
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | BZ_NAMESPACE(blitz)
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | // Matrix expression operand
 | 
|---|
 | 30 | template<class P_numtype, class P_structure> template<class P_expr>
 | 
|---|
 | 31 | Matrix<P_numtype, P_structure>& 
 | 
|---|
 | 32 | Matrix<P_numtype, P_structure>::operator=(_bz_MatExpr<P_expr> expr)
 | 
|---|
 | 33 | {
 | 
|---|
 | 34 |     // Check for compatible structures.
 | 
|---|
 | 35 | 
 | 
|---|
 | 36 |     // Fast evaluation (compatible structures)
 | 
|---|
 | 37 |     // (not implemented)
 | 
|---|
 | 38 | 
 | 
|---|
 | 39 |     // Slow evaluation
 | 
|---|
 | 40 |     _bz_typename P_structure::T_iterator iter(rows(), cols());
 | 
|---|
 | 41 |     while (iter)
 | 
|---|
 | 42 |     {
 | 
|---|
 | 43 |         data_[iter.offset()] = expr(iter.row(), iter.col());
 | 
|---|
 | 44 |         ++iter;
 | 
|---|
 | 45 |     }
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 |     return *this;
 | 
|---|
 | 48 | }
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | template<class P_numtype, class P_structure>
 | 
|---|
 | 51 | ostream& operator<<(ostream& os, const Matrix<P_numtype, P_structure>& matrix)
 | 
|---|
 | 52 | {
 | 
|---|
 | 53 |     os << "[ ";
 | 
|---|
 | 54 |     for (int i=0; i < matrix.rows(); ++i)
 | 
|---|
 | 55 |     {
 | 
|---|
 | 56 |         for (int j=0; j < matrix.columns(); ++j)
 | 
|---|
 | 57 |         {
 | 
|---|
 | 58 |             os << setw(10) << matrix(i,j);
 | 
|---|
 | 59 |             if ((!((j+1)%7)) && (j < matrix.cols()-1))
 | 
|---|
 | 60 |                 os << endl << "         ...";
 | 
|---|
 | 61 |         }
 | 
|---|
 | 62 |         if (i != matrix.rows() - 1)
 | 
|---|
 | 63 |             os << endl  << "  ";
 | 
|---|
 | 64 |     }
 | 
|---|
 | 65 |     os << " ]";
 | 
|---|
 | 66 |     return os;
 | 
|---|
 | 67 | }
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 | BZ_NAMESPACE_END
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 | #endif // BZ_MATRIX_CC
 | 
|---|