source: XMLIO_V2/external/include/blitz/tinyvecio.cc @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

File size: 1.5 KB
Line 
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
17BZ_NAMESPACE(blitz)
18
19// NEEDS_WORK
20
21template<typename P_numtype, int N_length>
22ostream& 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>
36template <typename T_numtype, int N_length>
37istream& 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
60BZ_NAMESPACE_END
61
62#endif // BZ_TINYVECIO_CC
Note: See TracBrowser for help on using the repository browser.