1 | /*************************************************************************** |
---|
2 | * blitz/tvecglobs.h TinyVector global functions |
---|
3 | * |
---|
4 | * $Id: tvecglobs.h,v 1.3 2003/12/11 03:44:22 julianc Exp $ |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or |
---|
7 | * modify it under the terms of the GNU General Public License |
---|
8 | * as published by the Free Software Foundation; either version 2 |
---|
9 | * of the License, or (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * Suggestions: blitz-dev@oonumerics.org |
---|
17 | * Bugs: blitz-bugs@oonumerics.org |
---|
18 | * |
---|
19 | * For more information, please see the Blitz++ Home Page: |
---|
20 | * http://oonumerics.org/blitz/ |
---|
21 | * |
---|
22 | ***************************************************************************/ |
---|
23 | |
---|
24 | #ifndef BZ_TVECGLOBS_H |
---|
25 | #define BZ_TVECGLOBS_H |
---|
26 | |
---|
27 | #ifndef BZ_META_METAPROG_H |
---|
28 | #include <blitz/meta/metaprog.h> |
---|
29 | #endif |
---|
30 | |
---|
31 | #ifndef BZ_NUMTRAIT_H |
---|
32 | #include <blitz/numtrait.h> |
---|
33 | #endif |
---|
34 | |
---|
35 | #include <blitz/tvcross.h> // Cross products |
---|
36 | #include <blitz/meta/dot.h> |
---|
37 | #include <blitz/meta/product.h> |
---|
38 | #include <blitz/meta/sum.h> |
---|
39 | |
---|
40 | BZ_NAMESPACE(blitz) |
---|
41 | |
---|
42 | template<typename T_numtype1, typename T_numtype2, int N_length> |
---|
43 | inline BZ_PROMOTE(T_numtype1, T_numtype2) |
---|
44 | dot(const TinyVector<T_numtype1, N_length>& a, |
---|
45 | const TinyVector<T_numtype2, N_length>& b) |
---|
46 | { |
---|
47 | return _bz_meta_vectorDot<N_length, 0>::f(a,b); |
---|
48 | } |
---|
49 | |
---|
50 | template<typename T_expr1, typename T_numtype2, int N_length> |
---|
51 | inline BZ_PROMOTE(_bz_typename T_expr1::T_numtype, T_numtype2) |
---|
52 | dot(_bz_VecExpr<T_expr1> a, const TinyVector<T_numtype2, N_length>& b) |
---|
53 | { |
---|
54 | return _bz_meta_vectorDot<N_length, 0>::f_value_ref(a,b); |
---|
55 | } |
---|
56 | |
---|
57 | template<typename T_numtype1, typename T_expr2, int N_length> |
---|
58 | inline BZ_PROMOTE(T_numtype1, _bz_typename T_expr2::T_numtype) |
---|
59 | dot(const TinyVector<T_numtype1, N_length>& a, _bz_VecExpr<T_expr2> b) |
---|
60 | { |
---|
61 | return _bz_meta_vectorDot<N_length, 0>::f_ref_value(a,b); |
---|
62 | } |
---|
63 | |
---|
64 | template<typename T_numtype1, int N_length> |
---|
65 | inline BZ_SUMTYPE(T_numtype1) |
---|
66 | product(const TinyVector<T_numtype1, N_length>& a) |
---|
67 | { |
---|
68 | return _bz_meta_vectorProduct<N_length, 0>::f(a); |
---|
69 | } |
---|
70 | |
---|
71 | template<typename T_numtype, int N_length> |
---|
72 | inline T_numtype |
---|
73 | sum(const TinyVector<T_numtype, N_length>& a) |
---|
74 | { |
---|
75 | return _bz_meta_vectorSum<N_length, 0>::f(a); |
---|
76 | } |
---|
77 | |
---|
78 | BZ_NAMESPACE_END |
---|
79 | |
---|
80 | #endif // BZ_TVECGLOBS_H |
---|
81 | |
---|