Line | |
---|
1 | /* |
---|
2 | * Copyright (C) 1997 Todd Veldhuizen <tveldhui@oonumerics.org> |
---|
3 | * All rights reserved. Please see <blitz/blitz.h> for terms and |
---|
4 | * conditions of use. |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef BZ_MATRIX_CC |
---|
9 | #define BZ_MATRIX_CC |
---|
10 | |
---|
11 | #ifndef BZ_MATRIX_H |
---|
12 | #include <blitz/matrix.h> |
---|
13 | #endif |
---|
14 | |
---|
15 | BZ_NAMESPACE(blitz) |
---|
16 | |
---|
17 | // Matrix expression operand |
---|
18 | template<typename P_numtype, typename P_structure> template<typename P_expr> |
---|
19 | Matrix<P_numtype, P_structure>& |
---|
20 | Matrix<P_numtype, P_structure>::operator=(_bz_MatExpr<P_expr> expr) |
---|
21 | { |
---|
22 | // Check for compatible structures. |
---|
23 | |
---|
24 | // Fast evaluation (compatible structures) |
---|
25 | // (not implemented) |
---|
26 | |
---|
27 | // Slow evaluation |
---|
28 | _bz_typename P_structure::T_iterator iter(rows(), cols()); |
---|
29 | while (iter) |
---|
30 | { |
---|
31 | data_[iter.offset()] = expr(iter.row(), iter.col()); |
---|
32 | ++iter; |
---|
33 | } |
---|
34 | |
---|
35 | return *this; |
---|
36 | } |
---|
37 | |
---|
38 | template<typename P_numtype, typename P_structure> |
---|
39 | ostream& operator<<(ostream& os, const Matrix<P_numtype, P_structure>& matrix) |
---|
40 | { |
---|
41 | os << "[ "; |
---|
42 | for (int i=0; i < matrix.rows(); ++i) |
---|
43 | { |
---|
44 | for (int j=0; j < matrix.columns(); ++j) |
---|
45 | { |
---|
46 | os << setw(10) << matrix(i,j); |
---|
47 | if ((!((j+1)%7)) && (j < matrix.cols()-1)) |
---|
48 | os << endl << " ..."; |
---|
49 | } |
---|
50 | if (i != matrix.rows() - 1) |
---|
51 | os << endl << " "; |
---|
52 | } |
---|
53 | os << " ]"; |
---|
54 | return os; |
---|
55 | } |
---|
56 | |
---|
57 | BZ_NAMESPACE_END |
---|
58 | |
---|
59 | #endif // BZ_MATRIX_CC |
---|
Note: See
TracBrowser
for help on using the repository browser.