source: XMLIO_V2/external/include/blitz/meta/dot.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: 3.4 KB
Line 
1// -*- C++ -*-
2/***************************************************************************
3 * blitz/meta/dot.h      Tiny vector dot product metaprogram
4 *
5 * $Id: dot.h,v 1.5 2005/05/07 04:17:57 julianc Exp $
6 *
7 * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * Suggestions:          blitz-dev@oonumerics.org
20 * Bugs:                 blitz-bugs@oonumerics.org
21 *
22 * For more information, please see the Blitz++ Home Page:
23 *    http://oonumerics.org/blitz/
24 *
25 ***************************************************************************/
26
27#ifndef BZ_META_DOT_H
28#define BZ_META_DOT_H
29
30#ifndef BZ_PROMOTE_H
31 #include <blitz/promote.h>
32#endif
33
34#ifndef BZ_METAPROG_H
35 #include <blitz/meta/metaprog.h>
36#endif
37
38BZ_NAMESPACE(blitz)
39
40template<int N, int I>
41class _bz_meta_vectorDot {
42public:
43    static const int loopFlag = (I < N-1) ? 1 : 0;
44
45    template<typename T_expr1, typename T_expr2>
46    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
47        _bz_typename T_expr2::T_numtype)
48    f(const T_expr1& a, const T_expr2& b)
49    {
50        return a[I] * b[I]
51            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::f(a,b);
52    }
53
54    template<typename T_expr1, typename T_expr2>
55    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
56        _bz_typename T_expr2::T_numtype)
57    f_value_ref(T_expr1 a, const T_expr2& b)
58    {
59        return a[I] * b[I]
60            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::f(a,b);
61    }
62
63    template<typename T_expr1, typename T_expr2>
64    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
65        _bz_typename T_expr2::T_numtype)
66    f_ref_value(const T_expr1& a, T_expr2 b)
67    {
68        return a[I] * b[I]
69            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::f(a,b);
70    }
71
72    template<typename T_expr1, typename P_numtype2>
73    static inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype,
74        P_numtype2)
75    dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0,
76        P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0,
77        P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0)
78    {
79        return a[I] * i1 
80            + _bz_meta_vectorDot<loopFlag * N, loopFlag * (I+1)>::dotWithArgs
81                 (a, i2, i3, i4, i5, i6, i7, i8, i9);
82    }
83};
84
85template<>
86class _bz_meta_vectorDot<0,0> {
87public:
88    template<typename T_expr1, typename T_expr2>
89    static inline _bz_meta_nullOperand f(const T_expr1&, const T_expr2&)
90    { return _bz_meta_nullOperand(); }
91
92    template<typename T_expr1, typename P_numtype2>
93    static inline _bz_meta_nullOperand
94    dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0,
95        P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0,
96        P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0)
97    {
98        return _bz_meta_nullOperand(); 
99    }
100
101};
102
103BZ_NAMESPACE_END
104
105#endif // BZ_META_DOT_H
Note: See TracBrowser for help on using the repository browser.