source: XMLIO_V2/external/include/blitz/array/zip.h @ 80

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

ajout lib externe

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// -*- C++ -*-
2/***************************************************************************
3 * blitz/array/zip.h  "zip" scalar arrays into a multicomponent array expr
4 *
5 * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * Suggestions:          blitz-dev@oonumerics.org
18 * Bugs:                 blitz-bugs@oonumerics.org
19 *
20 * For more information, please see the Blitz++ Home Page:
21 *    http://oonumerics.org/blitz/
22 *
23 ****************************************************************************/
24#ifndef BZ_ARRAYZIP_H
25#define BZ_ARRAYZIP_H
26
27#ifndef BZ_ARRAY_H
28 #error <blitz/array/zip.h> must be included via <blitz/array.h>
29#endif
30
31BZ_NAMESPACE(blitz)
32
33template<typename P_component, typename T1, typename T2>
34struct Zip2 {
35    typedef P_component T_numtype;
36
37    static inline T_numtype apply(T1 a, T2 b)
38    { return T_numtype(a,b); }
39
40    template<typename T_left, typename T_right>
41    static inline void prettyPrint(BZ_STD_SCOPE(string) &str,
42        prettyPrintFormat& format, const T_left& t1,
43        const T_right& t2)
44    {
45        str += "zip(";
46        t1.prettyPrint(str, format);
47        str += ",";
48        t2.prettyPrint(str, format);
49        str += ")";
50    }
51};
52
53template<typename T_component, typename T1, typename T2>
54inline _bz_ArrayExpr<_bz_ArrayExprBinaryOp<
55    _bz_typename asExpr<T1>::T_expr, 
56    _bz_typename asExpr<T2>::T_expr, 
57    Zip2<T_component, 
58         _bz_typename asExpr<T1>::T_expr::T_numtype,
59         _bz_typename asExpr<T2>::T_expr::T_numtype> > >
60zip(const T1& a, const T2& b, T_component)
61{
62    return _bz_ArrayExpr<_bz_ArrayExprBinaryOp<
63        _bz_typename asExpr<T1>::T_expr,
64        _bz_typename asExpr<T2>::T_expr, 
65        Zip2<T_component, 
66             _bz_typename asExpr<T1>::T_expr::T_numtype,
67             _bz_typename asExpr<T2>::T_expr::T_numtype> > >(a,b);
68}
69
70BZ_NAMESPACE_END
71
72#endif // BZ_ARRAYZIP_H
73
Note: See TracBrowser for help on using the repository browser.