MUQ  0.4.3
AnyAlgebra.h
Go to the documentation of this file.
1 #ifndef ANYALGEBRA_H_
2 #define ANYALGEBRA_H_
3 
4 #include <iostream>
5 
6 #include "MUQ/config.h"
7 
11 #if MUQ_HAS_SUNDIALS==1
13 #endif
14 
15 namespace muq {
16  namespace Modeling {
18  class AnyAlgebra {
19  public:
20 
22  AnyAlgebra();
23 
25 
33  unsigned int Size(boost::any const& obj, int const dim=-1) const;
34 
36 
40  double Norm(boost::any const& obj) const;
41 
43 
48  double InnerProduct(boost::any const& vec1, boost::any const& vec2) const;
49 
51 
56  boost::any OuterProduct(boost::any const& vec1, boost::any const& vec2) const;
57 
59 
66  boost::any AccessElement(boost::any const& obj, unsigned int const i = 0, unsigned int const j = 0) const;
67 
69 
74  boost::any Zero(std::type_info const& type, unsigned int const rows = 0, unsigned int const cols = 0) const;
75 
77 
81  bool IsZero(boost::any const& obj) const;
82 
84 
91  boost::any Identity(std::type_info const& type, unsigned int const rows=0, unsigned int const cols=0) const;
92 
94 
99  boost::any Add(boost::any const& in0, boost::any const& in1) const;
100 
102 
107  boost::any Subtract(boost::any const& in0, boost::any const& in1) const;
108 
110 
115  boost::any Multiply(boost::any const& in0, boost::any const& in1) const;
116 
118 
124  boost::any ApplyInverse(boost::any const& A, boost::any const& x) const;
125 
127 
133  boost::any Apply(boost::any const& A, boost::any const& x) const;
134 
136 
140  boost::any Inverse(boost::any const& obj) const;
141 
143 
148  boost::any SquareRoot(boost::any const& obj) const;
149 
151 
156  double LogDeterminate(boost::any const& obj) const;
157 
158  private:
159 
161 
166  virtual unsigned int SizeImpl(boost::any const& obj) const;
167 
169 
173  virtual double NormImpl(boost::any const& obj) const;
174 
176 
181  virtual double InnerProductImpl(boost::any const& vec1, boost::any const& vec2) const;
182 
184 
189  virtual boost::any OuterProductImpl(boost::any const& vec1, boost::any const& vec2) const;
190 
192 
198  virtual boost::any AccessElementImpl(boost::any const& vec, unsigned int const i) const;
199 
201 
207  virtual boost::any IdentityImpl(std::type_info const& type, unsigned int const rows, unsigned int const cols) const;
208 
210 
216  virtual boost::any AddImpl(boost::any const& in0, boost::any const& in1) const;
217 
219 
225  virtual boost::any SubtractImpl(boost::any const& in0, boost::any const& in1) const;
226 
228 
234  virtual boost::any MultiplyImpl(boost::any const& in0, boost::any const& in1) const;
235 
237 
243  virtual boost::any ApplyImpl(boost::any const& A, boost::any const& x) const;
244 
246 
252  virtual boost::any ApplyInverseImpl(boost::any const& A, boost::any const& x) const;
253 
255 
260  virtual boost::any ZeroImpl(std::type_info const& type, unsigned int const rows, unsigned int const cols) const;
261 
263 
267  virtual bool IsZeroImpl(boost::any const& obj) const;
268 
270 
274  virtual boost::any InverseImpl(boost::any const& obj) const;
275 
277 
282  virtual boost::any SquareRootImpl(boost::any const& obj) const;
283 
285 
290  virtual double LogDeterminateImpl(boost::any const& obj) const;
291 
292  };
293  } // namespace Modeling
294 } // namespace muq
295 
296 #endif
Implement a generic way to do algebric operations on boost::any's.
Definition: AnyAlgebra.h:18
virtual boost::any ZeroImpl(std::type_info const &type, unsigned int const rows, unsigned int const cols) const
Compute a zero object for boost::any.
Definition: AnyAlgebra.cpp:47
virtual boost::any IdentityImpl(std::type_info const &type, unsigned int const rows, unsigned int const cols) const
Compute an identity object.
Definition: AnyAlgebra.cpp:156
boost::any Add(boost::any const &in0, boost::any const &in1) const
Add two objects together.
Definition: AnyAlgebra.cpp:164
AnyAlgebra()
Default constructor.
Definition: AnyAlgebra.cpp:5
boost::any Identity(std::type_info const &type, unsigned int const rows=0, unsigned int const cols=0) const
Compute an identity object.
Definition: AnyAlgebra.cpp:146
boost::any Inverse(boost::any const &obj) const
The inverse.
Definition: AnyAlgebra.cpp:276
virtual boost::any SquareRootImpl(boost::any const &obj) const
Compute the square root of an object.
Definition: AnyAlgebra.cpp:300
boost::any OuterProduct(boost::any const &vec1, boost::any const &vec2) const
The outer product between two vectors.
Definition: AnyAlgebra.cpp:89
boost::any Apply(boost::any const &A, boost::any const &x) const
Apply a matrix (mat-vec)
Definition: AnyAlgebra.cpp:258
boost::any Zero(std::type_info const &type, unsigned int const rows=0, unsigned int const cols=0) const
Compute a zero vector.
Definition: AnyAlgebra.cpp:33
double InnerProduct(boost::any const &vec1, boost::any const &vec2) const
The inner product between two vectors.
Definition: AnyAlgebra.cpp:73
virtual boost::any SubtractImpl(boost::any const &in0, boost::any const &in1) const
Subtract two objects.
Definition: AnyAlgebra.cpp:204
virtual bool IsZeroImpl(boost::any const &obj) const
Determine if an object is the zero object.
Definition: AnyAlgebra.cpp:116
double LogDeterminate(boost::any const &obj) const
Compute the log-determinate.
Definition: AnyAlgebra.cpp:308
virtual boost::any AddImpl(boost::any const &in0, boost::any const &in1) const
Add two objects together.
Definition: AnyAlgebra.cpp:180
virtual double InnerProductImpl(boost::any const &vec1, boost::any const &vec2) const
The inner product between two vectors.
Definition: AnyAlgebra.cpp:81
virtual double LogDeterminateImpl(boost::any const &obj) const
Compute the log-determinate.
Definition: AnyAlgebra.cpp:318
virtual double NormImpl(boost::any const &obj) const
The norm of an object.
Definition: AnyAlgebra.cpp:65
virtual boost::any ApplyImpl(boost::any const &A, boost::any const &x) const
Apply a matrix (mat-vec)
Definition: AnyAlgebra.cpp:268
boost::any SquareRoot(boost::any const &obj) const
Compute the square root of an object.
Definition: AnyAlgebra.cpp:290
virtual boost::any ApplyInverseImpl(boost::any const &A, boost::any const &x) const
Apply the inverse of a matrix.
Definition: AnyAlgebra.cpp:250
virtual boost::any OuterProductImpl(boost::any const &vec1, boost::any const &vec2) const
The outer product between two vectors.
Definition: AnyAlgebra.cpp:98
boost::any Multiply(boost::any const &in0, boost::any const &in1) const
Multiply two objects.
Definition: AnyAlgebra.cpp:212
unsigned int Size(boost::any const &obj, int const dim=-1) const
The size of an object.
Definition: AnyAlgebra.cpp:7
bool IsZero(boost::any const &obj) const
Determine if an object is the zero object.
Definition: AnyAlgebra.cpp:106
boost::any Subtract(boost::any const &in0, boost::any const &in1) const
Subtract two objects.
Definition: AnyAlgebra.cpp:188
boost::any ApplyInverse(boost::any const &A, boost::any const &x) const
Apply the inverse of a matrix.
Definition: AnyAlgebra.cpp:240
double Norm(boost::any const &obj) const
The norm of an object.
Definition: AnyAlgebra.cpp:55
boost::any AccessElement(boost::any const &obj, unsigned int const i=0, unsigned int const j=0) const
Access an element of a vector/matrix.
Definition: AnyAlgebra.cpp:124
virtual boost::any AccessElementImpl(boost::any const &vec, unsigned int const i) const
Access an element of a vector.
Definition: AnyAlgebra.cpp:138
virtual boost::any MultiplyImpl(boost::any const &in0, boost::any const &in1) const
Multiply two objects.
Definition: AnyAlgebra.cpp:232
virtual boost::any InverseImpl(boost::any const &obj) const
The inverse.
Definition: AnyAlgebra.cpp:282
virtual unsigned int SizeImpl(boost::any const &obj) const
The size of an object (implemented by a child for non standard types)
Definition: AnyAlgebra.cpp:25