| 1 | /*
 | 
|---|
| 2 |  * $Id: matrix.cc,v 1.1.1.1 1999-11-26 16:37:03 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.1.1.1  1999/04/09  17:59:00  ansari
 | 
|---|
| 10 | // Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
 | 
|---|
| 11 | //
 | 
|---|
| 12 |  * Revision 1.4  1998/03/14 00:04:47  tveldhui
 | 
|---|
| 13 |  * 0.2-alpha-05
 | 
|---|
| 14 |  *
 | 
|---|
| 15 |  * Revision 1.3  1997/07/16 14:51:20  tveldhui
 | 
|---|
| 16 |  * Update: Alpha release 0.2 (Arrays)
 | 
|---|
| 17 |  *
 | 
|---|
| 18 |  * Revision 1.2  1997/01/24 14:42:00  tveldhui
 | 
|---|
| 19 |  * Periodic RCS update
 | 
|---|
| 20 |  *
 | 
|---|
| 21 |  */
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #ifndef BZ_MATRIX_CC
 | 
|---|
| 24 | #define BZ_MATRIX_CC
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #ifndef BZ_MATRIX_H
 | 
|---|
| 27 |  #include <blitz/matrix.h>
 | 
|---|
| 28 | #endif
 | 
|---|
| 29 | 
 | 
|---|
| 30 | BZ_NAMESPACE(blitz)
 | 
|---|
| 31 | 
 | 
|---|
| 32 | // Matrix expression operand
 | 
|---|
| 33 | template<class P_numtype, class P_structure> template<class P_expr>
 | 
|---|
| 34 | Matrix<P_numtype, P_structure>& 
 | 
|---|
| 35 | Matrix<P_numtype, P_structure>::operator=(_bz_MatExpr<P_expr> expr)
 | 
|---|
| 36 | {
 | 
|---|
| 37 |     // Check for compatible structures.
 | 
|---|
| 38 | 
 | 
|---|
| 39 |     // Fast evaluation (compatible structures)
 | 
|---|
| 40 |     // (not implemented)
 | 
|---|
| 41 | 
 | 
|---|
| 42 |     // Slow evaluation
 | 
|---|
| 43 |     _bz_typename P_structure::T_iterator iter(rows(), cols());
 | 
|---|
| 44 |     while (iter)
 | 
|---|
| 45 |     {
 | 
|---|
| 46 |         data_[iter.offset()] = expr(iter.row(), iter.col());
 | 
|---|
| 47 |         ++iter;
 | 
|---|
| 48 |     }
 | 
|---|
| 49 | 
 | 
|---|
| 50 |     return *this;
 | 
|---|
| 51 | }
 | 
|---|
| 52 | 
 | 
|---|
| 53 | template<class P_numtype, class P_structure>
 | 
|---|
| 54 | ostream& operator<<(ostream& os, const Matrix<P_numtype, P_structure>& matrix)
 | 
|---|
| 55 | {
 | 
|---|
| 56 |     os << "[ ";
 | 
|---|
| 57 |     for (int i=0; i < matrix.rows(); ++i)
 | 
|---|
| 58 |     {
 | 
|---|
| 59 |         for (int j=0; j < matrix.columns(); ++j)
 | 
|---|
| 60 |         {
 | 
|---|
| 61 |             os << setw(10) << matrix(i,j);
 | 
|---|
| 62 |             if ((!((j+1)%7)) && (j < matrix.cols()-1))
 | 
|---|
| 63 |                 os << endl << "         ...";
 | 
|---|
| 64 |         }
 | 
|---|
| 65 |         if (i != matrix.rows() - 1)
 | 
|---|
| 66 |             os << endl  << "  ";
 | 
|---|
| 67 |     }
 | 
|---|
| 68 |     os << " ]";
 | 
|---|
| 69 |     return os;
 | 
|---|
| 70 | }
 | 
|---|
| 71 | 
 | 
|---|
| 72 | BZ_NAMESPACE_END
 | 
|---|
| 73 | 
 | 
|---|
| 74 | #endif // BZ_MATRIX_CC
 | 
|---|