00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MATH_IS_INVERTIBLE_INCLUDE
00014 #define MATH_IS_INVERTIBLE_INCLUDE
00015
00016 #include <boost/numeric/linear_algebra/operators.hpp>
00017 #include <boost/numeric/linear_algebra/identity.hpp>
00018
00019 namespace math {
00020
00021 template <typename Operation, typename Element>
00022 struct is_invertible_t
00023 {
00024
00025 };
00026
00027
00028
00029
00030
00031 template <typename Element>
00032 struct is_invertible_t< add<Element>, Element >
00033 : public std::binary_function<add<Element>, Element, Element>
00034 {
00035 bool operator() (const add<Element>&, const Element&) const
00036 {
00037 return true;
00038 }
00039 };
00040
00041
00042
00043
00044
00045 template <typename Element>
00046 struct is_invertible_t< mult<Element>, Element >
00047 : public std::binary_function<mult<Element>, Element, Element>
00048 {
00049 bool operator() (const mult<Element>&, const Element& v) const
00050 {
00051 return v != zero(v);
00052 }
00053 };
00054
00055
00056
00057 template <typename Operation, typename Element>
00058 inline bool is_invertible(const Operation& op, const Element& v)
00059 {
00060 return is_invertible_t<Operation, Element>() (op, v);
00061 }
00062
00063
00064 namespace detail {
00065
00066
00067
00068 template <typename Operation, typename Element>
00069 struct non_zero_is_invertible_t
00070 {
00071 bool operator() (const Operation&, const Element& v)
00072 {
00073 return v != Element(0);
00074 }
00075 };
00076
00077 }
00078
00079 }
00080
00081 #endif // MATH_IS_INVERTIBLE_INCLUDE