Rev | Line | |
---|
[73] | 1 | /* |
---|
| 2 | * $Id: tinyvecio.cc,v 1.3 2003/12/11 03:44:22 julianc Exp $ |
---|
| 3 | * |
---|
| 4 | * Copyright (C) 1997 Todd Veldhuizen <tveldhui@oonumerics.org> |
---|
| 5 | * All rights reserved. Please see <blitz/blitz.h> for terms and |
---|
| 6 | * conditions of use. |
---|
| 7 | * |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #ifndef BZ_TINYVECIO_CC |
---|
| 11 | #define BZ_TINYVECIO_CC |
---|
| 12 | |
---|
| 13 | #ifndef BZ_TINYVEC_H |
---|
| 14 | #include <blitz/tinyvec.h> |
---|
| 15 | #endif |
---|
| 16 | |
---|
| 17 | BZ_NAMESPACE(blitz) |
---|
| 18 | |
---|
| 19 | // NEEDS_WORK |
---|
| 20 | |
---|
| 21 | template<typename P_numtype, int N_length> |
---|
| 22 | ostream& operator<<(ostream& os, const TinyVector<P_numtype, N_length>& x) |
---|
| 23 | { |
---|
| 24 | os << N_length << " [ "; |
---|
| 25 | for (int i=0; i < N_length; ++i) |
---|
| 26 | { |
---|
| 27 | os << setw(10) << x[i]; |
---|
| 28 | if (!((i+1)%7)) |
---|
| 29 | os << endl << " "; |
---|
| 30 | } |
---|
| 31 | os << " ]"; |
---|
| 32 | return os; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | // Input of tinyvec contribute by Adam Levar <adaml@mcneilhouse.com> |
---|
| 36 | template <typename T_numtype, int N_length> |
---|
| 37 | istream& operator>>(istream& is, TinyVector<T_numtype, N_length>& x) |
---|
| 38 | { |
---|
| 39 | int length; |
---|
| 40 | char sep; |
---|
| 41 | |
---|
| 42 | is >> length; |
---|
| 43 | is >> sep; |
---|
| 44 | BZPRECHECK(sep == '[', "Format error while scanning input array" |
---|
| 45 | << endl << " (expected '[' before beginning of array data)"); |
---|
| 46 | |
---|
| 47 | BZPRECHECK(length == N_length, "Size mismatch"); |
---|
| 48 | for (int i = 0; i < N_length; ++i) |
---|
| 49 | { |
---|
| 50 | BZPRECHECK(!is.bad(), "Premature end of input while scanning array"); |
---|
| 51 | is >> x(i); |
---|
| 52 | } |
---|
| 53 | is >> sep; |
---|
| 54 | BZPRECHECK(sep == ']', "Format error while scanning input array" |
---|
| 55 | << endl << " (expected ']' after end of array data)"); |
---|
| 56 | |
---|
| 57 | return is; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | BZ_NAMESPACE_END |
---|
| 61 | |
---|
| 62 | #endif // BZ_TINYVECIO_CC |
---|
Note: See
TracBrowser
for help on using the repository browser.