~ubuntu-branches/ubuntu/utopic/blitz++/utopic

« back to all changes in this revision

Viewing changes to blitz/meta/sum.h

  • Committer: Package Import Robot
  • Author(s): Christophe Trophime
  • Date: 2012-07-06 09:15:30 UTC
  • mfrom: (11.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20120706091530-vzrb8zf0vpbf8tp9
Tags: 1:0.10-1
* New upstream release
  Closes: #679407
* debian/rules:
  - update for new release
  - add override_dh_auto_test target
  - regenerate configure and Makefile.am
* debian/control:
  - add libtool, automake to BuildDepends
* debian/libblitz-doc.install
  - modify path for html files
* remove uneeded patches
* add examples.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/***************************************************************************
3
3
 * blitz/meta/sum.h      TinyVector sum metaprogram
4
4
 *
5
 
 * $Id: sum.h,v 1.6 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
 
5
 * $Id$
 
6
 *
 
7
 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
 
8
 *
 
9
 * This file is a part of Blitz.
 
10
 *
 
11
 * Blitz is free software: you can redistribute it and/or modify 
 
12
 * it under the terms of the GNU Lesser General Public License
 
13
 * as published by the Free Software Foundation, either version 3
12
14
 * of the License, or (at your option) any later version.
13
15
 *
14
 
 * This program is distributed in the hope that it will be useful,
 
16
 * Blitz is distributed in the hope that it will be useful,
15
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
 
19
 * GNU Lesser General Public License for more details.
18
20
 *
19
 
 * Suggestions:          blitz-dev@oonumerics.org
20
 
 * Bugs:                 blitz-bugs@oonumerics.org
 
21
 * You should have received a copy of the GNU Lesser General Public 
 
22
 * License along with Blitz.  If not, see <http://www.gnu.org/licenses/>.
 
23
 * 
 
24
 * Suggestions:          blitz-devel@lists.sourceforge.net
 
25
 * Bugs:                 blitz-support@lists.sourceforge.net    
21
26
 *
22
27
 * For more information, please see the Blitz++ Home Page:
23
 
 *    http://oonumerics.org/blitz/
 
28
 *    https://sourceforge.net/projects/blitz/
24
29
 *
25
30
 ***************************************************************************/
26
31
 
39
44
    static const int loopFlag = (I < N-1) ? 1 : 0;
40
45
 
41
46
    template<typename T_expr1>
42
 
    static inline _bz_typename T_expr1::T_numtype
 
47
    static inline BZ_SUMTYPE(_bz_typename T_expr1::T_numtype)
43
48
    f(const T_expr1& a)
44
49
    {
45
50
        return a[I] +
56
61
 
57
62
};
58
63
 
 
64
template<int N, int I, typename T_ret>
 
65
class _bz_meta_vectorSumRet {
 
66
public:
 
67
    static const int loopFlag = (I < N-1) ? 1 : 0;
 
68
 
 
69
    template<typename T_expr1>
 
70
    static inline T_ret
 
71
    f(const T_expr1& a)
 
72
    {
 
73
      return static_cast<T_ret>(a[I]) +
 
74
        _bz_meta_vectorSumRet<loopFlag * N, loopFlag * (I+1), T_ret>::f(a);
 
75
    }
 
76
};
 
77
 
 
78
template<typename T_ret>
 
79
class _bz_meta_vectorSumRet<0,0, T_ret> {
 
80
public:
 
81
    template<typename T_expr1>
 
82
    static inline _bz_meta_nullOperand f(const T_expr1&)
 
83
    { return _bz_meta_nullOperand(); }
 
84
 
 
85
};
 
86
 
59
87
BZ_NAMESPACE_END
60
88
 
61
89
#endif // BZ_META_SUM_H