source: XIOS/dev/dev_olga/src/extern/blitz/include/blitz/tvecglobs.h @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 2.8 KB
Line 
1// -*- C++ -*-
2/***************************************************************************
3 * blitz/tvecglobs.h     TinyVector global functions
4 *
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
14 * of the License, or (at your option) any later version.
15 *
16 * Blitz is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Lesser General Public License for more details.
20 *
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   
26 *
27 * For more information, please see the Blitz++ Home Page:
28 *    https://sourceforge.net/projects/blitz/
29 *
30 ***************************************************************************/
31
32#ifndef BZ_TVECGLOBS_H
33#define BZ_TVECGLOBS_H
34
35#include <blitz/meta/metaprog.h>
36#include <blitz/numtrait.h>
37
38#include <blitz/tvcross.h>       // Cross products
39#include <blitz/meta/dot.h>
40#include <blitz/meta/product.h>
41#include <blitz/meta/sum.h>
42
43BZ_NAMESPACE(blitz)
44
45template<typename T_numtype1, typename T_numtype2, int N_length>
46inline BZ_PROMOTE(T_numtype1, T_numtype2)
47dot(const TinyVector<T_numtype1, N_length>& a, 
48    const TinyVector<T_numtype2, N_length>& b)
49{
50    return _bz_meta_vectorDot<N_length, 0>::f(a,b);
51}
52
53template<typename T_numtype1, int N_length>
54inline BZ_SUMTYPE(T_numtype1)
55product(const TinyVector<T_numtype1, N_length>& a)
56{
57    return _bz_meta_vectorProduct<N_length, 0>::f(a);
58}
59
60template<typename T_numtype, int N_length>
61inline BZ_SUMTYPE(T_numtype)
62sum(const TinyVector<T_numtype, N_length>& a)
63{
64    return _bz_meta_vectorSum<N_length, 0>::f(a);
65}
66
67// explicit returntype functions follow
68
69template<typename T_ret>
70class _bz_returntype {
71public:
72
73  template<typename T_numtype1, typename T_numtype2, int N_length>
74static inline T_ret
75dot(const TinyVector<T_numtype1, N_length>& a, 
76    const TinyVector<T_numtype2, N_length>& b)
77{
78  return _bz_meta_vectorDotRet<N_length, 0, T_ret>::f(a,b);
79};
80
81template<typename T_numtype1, int N_length>
82static inline T_ret
83product(const TinyVector<T_numtype1, N_length>& a)
84{
85    return _bz_meta_vectorProductRet<N_length, 0, T_ret>::f(a);
86};
87
88template<typename T_numtype, int N_length>
89static inline T_ret
90sum(const TinyVector<T_numtype, N_length>& a)
91{
92    return _bz_meta_vectorSumRet<N_length, 0, T_ret>::f(a);
93};
94
95};
96
97BZ_NAMESPACE_END
98
99#endif // BZ_TVECGLOBS_H
100
Note: See TracBrowser for help on using the repository browser.