00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_MATRIX_IDENTITY_INCLUDE
00013 #define MTL_MATRIX_IDENTITY_INCLUDE
00014
00015 #include <boost/numeric/linear_algebra/identity.hpp>
00016 #include <boost/numeric/mtl/matrix/diagonal_setup.hpp>
00017
00018 namespace mtl { namespace matrix {
00019
00020 namespace traits {
00021
00022
00023 template <typename Value= double>
00024 struct identity
00025 {
00026 typedef ::mtl::compressed2D<Value> type;
00027 };
00028 }
00029
00030 template <typename Value>
00031 typename traits::identity<Value>::type
00032 inline identity(std::size_t nrows, std::size_t ncols)
00033 {
00034 typename traits::identity<Value>::type I(nrows, ncols);
00035 diagonal_setup(I, math::one(Value()));
00036 return I;
00037 }
00038
00039
00040 traits::identity<double>::type
00041 inline identity(std::size_t nrows, std::size_t ncols)
00042 {
00043 return identity<double>(nrows, ncols);
00044 }
00045
00046 }}
00047
00048 #endif // MTL_MATRIX_IDENTITY_INCLUDE