blitz  Version 1.0.2
tvecglobs.h
Go to the documentation of this file.
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 
43 namespace blitz {
44 
45 template<typename T_numtype1, typename T_numtype2, int N_length>
46 inline BZ_PROMOTE(T_numtype1, T_numtype2)
47 dot(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 
53 template<typename T_numtype1, int N_length>
54 inline BZ_SUMTYPE(T_numtype1)
55 product(const TinyVector<T_numtype1, N_length>& a)
56 {
57  return _bz_meta_vectorProduct<N_length, 0>::f(a);
58 }
59 
60 template<typename T_numtype, int N_length>
61 inline BZ_SUMTYPE(T_numtype)
62 sum(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 
69 template<typename T_ret>
71 public:
72 
73  template<typename T_numtype1, typename T_numtype2, int N_length>
74 static inline T_ret
77 {
78  return _bz_meta_vectorDotRet<N_length, 0, T_ret>::f(a,b);
79 };
80 
81 template<typename T_numtype1, int N_length>
82 static inline T_ret
84 {
85  return _bz_meta_vectorProductRet<N_length, 0, T_ret>::f(a);
86 };
87 
88 template<typename T_numtype, int N_length>
89 static inline T_ret
91 {
92  return _bz_meta_vectorSumRet<N_length, 0, T_ret>::f(a);
93 };
94 
95 };
96 
97 }
98 
99 #endif // BZ_TVECGLOBS_H
100 
Definition: tvecglobs.h:70
static T_ret product(const TinyVector< T_numtype1, N_length > &a)
Definition: tvecglobs.h:83
BZ_PROMOTE(T_numtype1, T_numtype2) dot(const TinyVector< T_numtype1
Definition: array-impl.h:66
BZ_SUMTYPE(T_numtype1) product(const TinyVector< T_numtype1
static T_ret dot(const TinyVector< T_numtype1, N_length > &a, const TinyVector< T_numtype2, N_length > &b)
Definition: tvecglobs.h:75
N_length & a
Definition: tvecglobs.h:47
static T_ret sum(const TinyVector< T_numtype, N_length > &a)
Definition: tvecglobs.h:90
N_length const TinyVector< T_numtype2, N_length > & b
Definition: tvecglobs.h:49
The TinyVector class is a one-dimensional, fixed length vector that implements the blitz expression t...
Definition: et-forward.h:14