Implement a generic way to do algebric operations on boost::any's. More...
#include <AnyAlgebra.h>
Implement a generic way to do algebric operations on boost::any's.
Definition at line 18 of file AnyAlgebra.h.
Public Member Functions | |
AnyAlgebra () | |
Default constructor. More... | |
unsigned int | Size (boost::any const &obj, int const dim=-1) const |
The size of an object. More... | |
double | Norm (boost::any const &obj) const |
The norm of an object. More... | |
double | InnerProduct (boost::any const &vec1, boost::any const &vec2) const |
The inner product between two vectors. More... | |
boost::any | OuterProduct (boost::any const &vec1, boost::any const &vec2) const |
The outer product between two vectors. More... | |
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. More... | |
boost::any | Zero (std::type_info const &type, unsigned int const rows=0, unsigned int const cols=0) const |
Compute a zero vector. More... | |
bool | IsZero (boost::any const &obj) const |
Determine if an object is the zero object. More... | |
boost::any | Identity (std::type_info const &type, unsigned int const rows=0, unsigned int const cols=0) const |
Compute an identity object. More... | |
boost::any | Add (boost::any const &in0, boost::any const &in1) const |
Add two objects together. More... | |
boost::any | Subtract (boost::any const &in0, boost::any const &in1) const |
Subtract two objects. More... | |
boost::any | Multiply (boost::any const &in0, boost::any const &in1) const |
Multiply two objects. More... | |
boost::any | ApplyInverse (boost::any const &A, boost::any const &x) const |
Apply the inverse of a matrix. More... | |
boost::any | Apply (boost::any const &A, boost::any const &x) const |
Apply a matrix (mat-vec) More... | |
boost::any | Inverse (boost::any const &obj) const |
The inverse. More... | |
boost::any | SquareRoot (boost::any const &obj) const |
Compute the square root of an object. More... | |
double | LogDeterminate (boost::any const &obj) const |
Compute the log-determinate. More... | |
AnyAlgebra::AnyAlgebra | ( | ) |
Default constructor.
Definition at line 5 of file AnyAlgebra.cpp.
boost::any AnyAlgebra::AccessElement | ( | boost::any const & | obj, |
unsigned int const | i = 0 , |
||
unsigned int const | j = 0 |
||
) | const |
Access an element of a vector/matrix.
The return type is whatever the elements of the vector/matrix are (doubles, ints, ect ...)
[in] | obj | The vector/matrix whose data we want to access |
[in] | i | We want to access the \(i^{th}\) element/row of the vector/matrix (defaults to 0) |
[in] | j | We want to access the \(j^{th}\) col of the matrix (defaults to 0) |
Definition at line 124 of file AnyAlgebra.cpp.
References muq::Modeling::SundialsAlgebra::AccessElement(), AccessElementImpl(), muq::Modeling::ScalarAlgebra::IsScalar(), and muq::Modeling::SundialsAlgebra::IsSundialsVector().
|
privatevirtual |
Access an element of a vector.
MUQ automatically checks for some common input types. However, the user may need to overload this function for special types.
[in] | vec | The vector whose data we want to access |
[in] | i | We want to access the \(i^{th}\) element/row |
Definition at line 138 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by AccessElement().
boost::any AnyAlgebra::Add | ( | boost::any const & | in0, |
boost::any const & | in1 | ||
) | const |
Add two objects together.
[in] | in0 | The first input |
[in] | in1 | The second input |
Definition at line 164 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::Add(), AddImpl(), and muq::Modeling::ScalarAlgebra::IsScalar().
|
privatevirtual |
Add two objects together.
MUQ automatically checks for some common pairs. However, the user may need to overload this function for special types.
[in] | in0 | The first input |
[in] | in1 | The second input |
Definition at line 180 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Add().
boost::any AnyAlgebra::Apply | ( | boost::any const & | A, |
boost::any const & | x | ||
) | const |
Apply a matrix (mat-vec)
If the input is a vector, treat is as the diagonal of a matrix
[in] | A | We are applying this matrix |
[in] | x | We are applying the matrix to this vector |
Definition at line 258 of file AnyAlgebra.cpp.
References ApplyImpl(), muq::Modeling::ScalarAlgebra::IsScalar(), and Multiply().
|
privatevirtual |
Apply a matrix (mat-vec)
If the input is a vector, treat is as the diagonal of a matrix
[in] | A | We are applying this matrix |
[in] | x | We are applying the matrix to this vector |
Definition at line 268 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Apply().
boost::any AnyAlgebra::ApplyInverse | ( | boost::any const & | A, |
boost::any const & | x | ||
) | const |
Apply the inverse of a matrix.
If the input is a vector, treat is as the diagonal of a matrix
[in] | A | We are applying the inverse of this matrix |
[in] | x | We are applying the inverse to this vector |
Definition at line 240 of file AnyAlgebra.cpp.
References ApplyInverseImpl(), Inverse(), muq::Modeling::ScalarAlgebra::IsScalar(), and Multiply().
|
privatevirtual |
Apply the inverse of a matrix.
If the input is a vector, treat is as the diagonal of a matrix
[in] | A | We are applying the inverse of this matrix |
[in] | x | We are applying the inverse to this vector |
Definition at line 250 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by ApplyInverse().
boost::any AnyAlgebra::Identity | ( | std::type_info const & | type, |
unsigned int const | rows = 0 , |
||
unsigned int const | cols = 0 |
||
) | const |
Compute an identity object.
If the input type is a vector (e.g., Eigen::Vector), return an identity matrix of corresponding type (e.g., Eigen::Matrix)
[in] | type | The type—return an identity of this type |
[in] | rows | The number of rows (e.g., for a matrix) defaults to 0 since some types imply the size |
[in] | cols | The number of columns (e.g., for a matrix) defaults to 0 since some types imply the size |
Definition at line 146 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::Identity(), IdentityImpl(), and muq::Modeling::ScalarAlgebra::IsScalar().
|
privatevirtual |
Compute an identity object.
[in] | type | The type—return an identity of this type |
[in] | rows | The number of rows (e.g., for a matrix) |
[in] | cols | The number of columns (e.g., for a matrix) |
Definition at line 156 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Identity().
double AnyAlgebra::InnerProduct | ( | boost::any const & | vec1, |
boost::any const & | vec2 | ||
) | const |
The inner product between two vectors.
[in] | vec1 | The first vector |
[in] | vec2 | The second vector |
Definition at line 73 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::InnerProduct(), InnerProductImpl(), and muq::Modeling::ScalarAlgebra::IsScalar().
|
privatevirtual |
The inner product between two vectors.
[in] | vec1 | The first vector |
[in] | vec2 | The second vector |
Definition at line 81 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by InnerProduct().
boost::any AnyAlgebra::Inverse | ( | boost::any const & | obj | ) | const |
The inverse.
[in] | obj | We need the inverse of this object |
Definition at line 276 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::Inverse(), InverseImpl(), and muq::Modeling::ScalarAlgebra::IsScalar().
Referenced by ApplyInverse().
|
privatevirtual |
The inverse.
[in] | obj | We need the inverse of this object |
Definition at line 282 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Inverse().
bool AnyAlgebra::IsZero | ( | boost::any const & | obj | ) | const |
Determine if an object is the zero object.
[in] | obj | An input object |
Definition at line 106 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::IsZero(), and IsZeroImpl().
|
privatevirtual |
Determine if an object is the zero object.
[in] | obj | An input object |
Definition at line 116 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by IsZero().
double AnyAlgebra::LogDeterminate | ( | boost::any const & | obj | ) | const |
Compute the log-determinate.
In the vector case, compute the determinate of a diagonal matrix.
[in] | obj | We need the determinate of this object |
Definition at line 308 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::LogDeterminate(), and LogDeterminateImpl().
|
privatevirtual |
Compute the log-determinate.
In the vector case, compute the determinate of a diagonal matrix.
[in] | obj | We need the determinate of this object |
Definition at line 318 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by LogDeterminate().
boost::any AnyAlgebra::Multiply | ( | boost::any const & | in0, |
boost::any const & | in1 | ||
) | const |
Multiply two objects.
[in] | in0 | The first input |
[in] | in1 | The second input |
Definition at line 212 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::Multiply(), and MultiplyImpl().
Referenced by Apply(), and ApplyInverse().
|
privatevirtual |
Multiply two objects.
MUQ automatically checks for some common pairs. However, the user may need to overload this function for special types.
[in] | in0 | The first input |
[in] | in1 | The second input |
Definition at line 232 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Multiply().
double AnyAlgebra::Norm | ( | boost::any const & | obj | ) | const |
The norm of an object.
[in] | obj | We need the norm of this object |
Definition at line 55 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::Norm(), and NormImpl().
|
privatevirtual |
The norm of an object.
[in] | obj | We need the norm of this object |
Definition at line 65 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Norm().
boost::any AnyAlgebra::OuterProduct | ( | boost::any const & | vec1, |
boost::any const & | vec2 | ||
) | const |
The outer product between two vectors.
[in] | vec1 | The first vector |
[in] | vec2 | The second vector |
Definition at line 89 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::OuterProduct(), and OuterProductImpl().
|
privatevirtual |
The outer product between two vectors.
[in] | vec1 | The first vector |
[in] | vec2 | The second vector |
Definition at line 98 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by OuterProduct().
unsigned int AnyAlgebra::Size | ( | boost::any const & | obj, |
int const | dim = -1 |
||
) | const |
The size of an object.
For vectors/matrices, return the number of elements.
For matrices, the default behavior is to return the total number of elements. For dim=0, return the number of rows, for dim=1 return the number of colums
[in] | obj | We need the size of this object |
[in] | dim | The dimension For matrices: for dim=-1 (default) return the total number of elements, for dim=0, return the number of rows, for dim=1, return the number of colums |
Definition at line 7 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::SundialsAlgebra::IsSundialsVector(), muq::Modeling::SundialsAlgebra::Size(), and SizeImpl().
|
privatevirtual |
The size of an object (implemented by a child for non standard types)
For vectors/matrices, return the number of elements.
[in] | obj | We need the size of this object |
Definition at line 25 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Size().
boost::any AnyAlgebra::SquareRoot | ( | boost::any const & | obj | ) | const |
Compute the square root of an object.
In the vector case, compute the square root of each component. In the matrix case, compute the Cholesky
[in] | obj | We need the square root of this object |
Definition at line 290 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::SquareRoot(), and SquareRootImpl().
|
privatevirtual |
Compute the square root of an object.
In the vector case, compute the square root of each component. In the matrix case, compute the Cholesky
[in] | obj | We need the square root of this object |
Definition at line 300 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by SquareRoot().
boost::any AnyAlgebra::Subtract | ( | boost::any const & | in0, |
boost::any const & | in1 | ||
) | const |
Subtract two objects.
[in] | in0 | The first input |
[in] | in1 | The second input |
Definition at line 188 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::Subtract(), and SubtractImpl().
|
privatevirtual |
Subtract two objects.
MUQ automatically checks for some common pairs. However, the user may need to overload this function for special types.
[in] | in0 | The first input |
[in] | in1 | The second input |
Definition at line 204 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Subtract().
boost::any AnyAlgebra::Zero | ( | std::type_info const & | type, |
unsigned int const | rows = 0 , |
||
unsigned int const | cols = 0 |
||
) | const |
Compute a zero vector.
[in] | type | We need a zero object of this type |
[in] | rows | The size of the vector (defaults to 0 because some types have implied sizes (e.g., Eigen::Vector2d)) or number of rows of the matrix |
[in] | cols | The number of columns in the matrix (defaults to 0 but, again, some types imply a size) |
Definition at line 33 of file AnyAlgebra.cpp.
References muq::Modeling::ScalarAlgebra::IsScalar(), muq::Modeling::ScalarAlgebra::Zero(), and ZeroImpl().
|
privatevirtual |
Compute a zero object for boost::any.
[in] | type | We need a zero object of this type |
[in] | rows | The size of the vector (defaults to 0 because some types have implied sizes (e.g., Eigen::Vector2d)) or number of rows of the matrix |
[in] | cols | The number of columns in the matrix (defaults to 0 but, again, some types imply a size) |
Definition at line 47 of file AnyAlgebra.cpp.
References muq::Utilities::demangle().
Referenced by Zero().