antioch-0.4.0
valarray_utils_decl.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 #ifndef ANTIOCH_VALARRAY_UTILS_DECL_H
28 #define ANTIOCH_VALARRAY_UTILS_DECL_H
29 
30 #ifdef ANTIOCH_METAPROGRAMMING_H
31 # error valarray_utils_decl.h must be included before metaprogramming.h
32 #endif
33 
34 // Antioch
36 
37 // C++
38 #include <iostream>
39 #include <valarray>
40 
41 // Add some overloads that are blatantly missing from the std:: namespace
42 
43 namespace Antioch
44 {
45 
46 template <typename T>
47 struct is_valarray {
48  static const bool value = false;
49 };
50 
51 template <typename T>
52 struct is_valarray<std::valarray<T> > {
53  static const bool value = true;
54 };
55 
56 // FIXME: need to add specializations for expression template types
57 template <typename T>
58 struct state_type<T, typename enable_if_c<is_valarray<T>::value,void>::type> {
59  typedef T type;
60 };
61 // Class to allow tag dispatching to std::valarray specializations
63 
64 }
65 
66 
67 namespace std
68 {
69 
70 template <typename T>
71 inline
72 typename Antioch::enable_if_c<
74  std::ostream&>::type
75 operator<< (std::ostream& output, const T& a);
76 
77 template <typename T, typename T2>
78 inline
79 typename Antioch::enable_if_c<
80  Antioch::is_valarray<T>::value,
81  typename Antioch::state_type<T>::type>::type
82 pow (const T& in, const T2& n);
83 
84 template <typename T>
85 inline
86 std::valarray<T>
87 max (const std::valarray<T>& a, const std::valarray<T>& b);
88 
89 template <typename T>
90 inline
91 std::valarray<T>
92 min (const std::valarray<T>& a, const std::valarray<T>& b);
93 
94 } // end namespace std
95 
96 
97 namespace Antioch
98 {
99 template <typename T, typename NewScalar>
100 struct rebind<std::valarray<T>, NewScalar>
101 {
102  typedef std::valarray<NewScalar> type;
103 };
104 
105 template <typename T>
106 inline
107 T
108 max (const std::valarray<T>& in);
109 
110 template <typename T>
111 inline
112 T
113 min (const std::valarray<T>& in);
114 
115 template <typename T>
116 struct return_auto<T, typename Antioch::enable_if_c<is_valarray<T>::value,void>::type>;
117 
118 template <typename T>
119 struct has_size<std::valarray<T> >;
120 
121 template <typename T>
122 struct size_type<std::valarray<T> >;
123 
124 template <typename T>
125 struct value_type<std::valarray<T> >;
126 
127 template <typename T>
128 struct raw_value_type<std::valarray<T> >;
129 
130 template <typename T>
131 inline
132 std::valarray<T>
133 zero_clone(const std::valarray<T>& example);
134 
135 template <typename T1, typename T2>
136 inline
137 void
138 zero_clone(std::valarray<T1>& output, const std::valarray<T2>& example);
139 
140 template <typename T, typename Scalar>
141 inline
142 std::valarray<T>
143 constant_clone(const std::valarray<T>& example, const Scalar& value);
144 
145 template <typename T>
146 inline
147 void
148 init_clone(std::valarray<T>& output, const std::valarray<T>& example);
149 
150 /*template <typename T, typename VectorScalar>
151 inline
152 std::valarray<T> custom_clone(const std::valarray<T>& example, const VectorScalar& values, const std::valarray<unsigned int> & indexes);
153 */
154 
155 template <typename T>
156 inline
157 std::valarray<T>
158 if_else(const std::valarray<bool>& condition,
159  const std::valarray<T>& if_true,
160  const std::valarray<T>& if_false);
161 
162 
163 template <typename VectorT>
164 inline
165 typename Antioch::enable_if_c<
166  Antioch::is_valarray<typename value_type<VectorT>::type>::value,
167  typename value_type<VectorT>::type
168 >::type
169 eval_index(const VectorT& vec, const std::valarray<unsigned int>& index);
170 
171 } // end namespace Antioch
172 
173 
174 #endif //ANTIOCH_VALARRAY_UTILS_DECL_H
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type max(const T &in)
Definition: eigen_utils.h:88
Antioch::enable_if_c< Antioch::is_valarray< T >::value, std::ostream & >::type operator<<(std::ostream &output, const T &a)
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type min(const T &in)
Definition: eigen_utils.h:98
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
void init_clone(T &output, const T &example)
enable_if_c< is_eigen< typename value_type< VectorT >::type >::value, typename value_type< VectorT >::type >::type eval_index(const VectorT &vec, const _Matrix< _UIntT, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &index)
Definition: eigen_utils.h:268
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > constant_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex, const Scalar &value)
Definition: eigen_utils.h:181
max(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a, const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &b) ANTIOCH_AUTOFUNC(_Matrix< _Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols >
enable_if_c< is_eigen< T1 >::value &&is_eigen< T2 >::value, typename state_type< T1 >::type >::type if_else(const Condition &condition, const T1 &if_true, const T2 &if_false)
Definition: eigen_utils.h:250
The parameters are reduced parameters.
typename _Scalar int _Rows int _Cols int _Options int _MaxRows int _MaxCols inline min(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a, const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &b) ANTIOCH_AUTOFUNC(_Matrix< _Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols >
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)
Definition: eigen_utils.h:145
static const bool value

Generated on Thu Jul 7 2016 11:09:46 for antioch-0.4.0 by  doxygen 1.8.8