#ifndef _MTL_MATRIX_TRAITS_ #define _MTL_MATRIX_TRAITS_ #include #include #include namespace mtl { #if 0 // OBSOLETE, see mtl/traits.h //: The "traits" class for MTL matrices. //!component: type //!category: containers, tags template struct matrix_traits { //: The shape of the matrix, either rectangle_tag, banded_tag, diagonal_tag, triangle_tag, or symmetric_tag typedef typename Matrix::shape shape; //: The orientation, either row_tag or column_tag typedef typename Matrix::orientation orientation; //: The sparsity, either dense_tag or sparse_tag typedef typename Matrix::sparsity sparsity; //: Used by the trans helper function typedef typename Matrix::transpose_type transpose_type; //: Used by rows() and cols() helper functions typedef typename Matrix::strided_type strided_type; //: Whether the rows and columns functions can be used with this Matrix typedef typename Matrix::strideability strideability; //: Whether the Matrix owns its data, either external_tag or internal_tag typedef typename Matrix::storage_loc storage_loc; //: A OneD part of a Matrix. This could be a Row, a Column or a Diagonal depending on the type of Matrix. typedef typename Matrix::OneD OneD; //: The element type of the matrix typedef typename Matrix::OneD::value_type element_type; typedef typename Matrix::reference reference; typedef typename Matrix::const_reference const_reference; typedef typename Matrix::pointer pointer; //: A NonNegativeIntegral type typedef typename Matrix::size_type size_type; typedef typename Matrix::difference_type difference_type; }; #endif #if 0 //: Row Matrix Traits //!component: type //!category: containers, tags template struct row_matrix_traits { typedef typename Matrix::Row Row; }; //: Column Matrix Traits //!component: type //!category: containers, tags template struct column_matrix_traits { typedef typename Matrix::Column Column; }; //: Diagonal Matrix Traits //!component: type //!category: containers, tags template struct diagonal_matrix_traits { typedef typename Matrix::Diagonal Diagonal; }; #endif // OBSOLETE template struct number_traits { typedef number_type magnitude_type; }; template inline number_type zero(number_type) { return number_type(0); } template inline number_type one(number_type) { return number_type(1); } template inline number_type ident(number_type) { return number_type(1); } // issue, clash with STL functor identity // OBSOLETE //: Linear Algebra Object (Matrix and Vector) Traits //!component: type //!category: containers, tags template struct linalg_traits { /* enum { dimension = Linalg::dimension }; 1 for vectors, 2 for matrices */ //: Whether the object is a 1D or 2D container typedef typename Linalg::dimension dimension; //: The element type within the container typedef typename Linalg::value_type value_type; //: Either sparse or dense typedef typename Linalg::sparsity sparsity; //: Either row, column, or ... typedef typename Linalg::orientation orientation; //: The return type for abs(value_type) typedef typename number_traits::magnitude_type magnitude_type; }; template <> struct linalg_traits { typedef zerod_tag dimension; typedef double value_type; typedef dense_tag sparsity; typedef double magnitude_type; typedef void orientation; }; template <> struct linalg_traits { typedef zerod_tag dimension; typedef float value_type; typedef dense_tag sparsity; typedef float magnitude_type; typedef void orientation; }; template <> struct linalg_traits { typedef zerod_tag dimension; typedef int value_type; typedef dense_tag sparsity; typedef int magnitude_type; typedef void orientation; }; /* This class encodes the linalg_traits info */ #if 0 template struct info { typedef T value_type; // Matrix::OneD or Vector::value_type typedef Dim dimension; typedef Orien orientation; typedef Sparsity sparsity; typedef DimSizes dim_sizes; // Cons, Cons >, etc. typedef Sc scalar_type; // same for matrices and vectors }; template struct make_dimsizes { typedef ConsV<1,Nil> RET; }; template struct make_dimsizes { typedef ConsV RET; }; template struct make_dimsizes { typedef ConsV > RET; }; template struct get_value_type { typedef T RET; }; template struct get_value_type { typedef typename linalg_traits::value_type RET; }; template struct get_value_type { typedef typename T::OneD RET; }; template struct make_info { typedef typename linalg_traits::dimension Dim; typedef info::RET, Dim, typename linalg_traits::orientation, typename linalg_traits::sparsity, typename make_dimsizes::RET, typename linalg_traits::value_type > RET; }; #endif //: Identifies matrices that can be used with the rows and columns functions //!component: type //!category: containers, tags struct strideable { }; //: Identifies matrices that can not be used with the rows and columns functions //!component: type //!category: containers, tags struct not_strideable { }; /* the following are used in constructors to avoid ambiguity and compiler errors */ //: blah //!noindex: struct do_transpose { }; //: blah //!noindex: struct do_strided { }; //: blah //!noindex: struct do_scaled { }; //: blah //!noindex: struct do_stream { }; } /* namespace mtl */ #endif /* _MTL_MATRIX_TRAITS_ */