ublas_symmetric.hpp

Go to the documentation of this file.
00001 /*
00002  * 
00003  * Copyright (c) 2002, 2003 Kresimir Fresl, Toon Knapen and Karl Meerbergen
00004  *
00005  * Distributed under the Boost Software License, Version 1.0.
00006  * (See accompanying file LICENSE_1_0.txt or copy at
00007  * http://www.boost.org/LICENSE_1_0.txt)
00008  *
00009  * KF acknowledges the support of the Faculty of Civil Engineering, 
00010  * University of Zagreb, Croatia.
00011  *
00012  */
00013 
00014 #ifndef BOOST_NUMERIC_BINDINGS_TRAITS_UBLAS_SYMMETRIC_H
00015 #define BOOST_NUMERIC_BINDINGS_TRAITS_UBLAS_SYMMETRIC_H
00016 
00017 #include <boost/numeric/bindings/traits/traits.hpp>
00018 
00019 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00020 
00021 #ifndef BOOST_UBLAS_HAVE_BINDINGS
00022 #  include <boost/numeric/ublas/symmetric.hpp> 
00023 #endif 
00024 #include <boost/numeric/bindings/traits/ublas_matrix.hpp>
00025 #include <boost/numeric/bindings/traits/detail/ublas_uplo.hpp>
00026 
00027 
00028 namespace boost { namespace numeric { namespace bindings { namespace traits {
00029 
00030   // ublas::symmetric_matrix<>
00031   template <typename T, typename F1, typename F2, typename A, typename M>
00032   struct matrix_detail_traits<boost::numeric::ublas::symmetric_matrix<T, F1, F2, A>, M>
00033   {
00034 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00035     BOOST_STATIC_ASSERT( (boost::is_same<boost::numeric::ublas::symmetric_matrix<T, F1, F2, A>, typename boost::remove_const<M>::type>::value) );
00036 #endif
00037 #ifdef BOOST_BINDINGS_FORTRAN
00038     BOOST_STATIC_ASSERT((boost::is_same<
00039       typename F2::orientation_category, 
00040       boost::numeric::ublas::column_major_tag
00041     >::value)); 
00042 #endif 
00043 
00044     typedef boost::numeric::ublas::symmetric_matrix<T, F1, F2, A> identifier_type;
00045     typedef M                                                     matrix_type;
00046 
00047     typedef symmetric_packed_t matrix_structure; 
00048     typedef typename detail::ublas_ordering<
00049       typename F2::orientation_category
00050     >::type ordering_type; 
00051     typedef typename detail::ublas_uplo< F1 >::type uplo_type; 
00052 
00053     typedef T                                           value_type ; 
00054     typedef typename detail::generate_const<M,T>::type* pointer ; 
00055 
00056     static pointer storage (matrix_type& sm) {
00057       typedef typename detail::generate_const<M,A>::type array_type ;
00058       return vector_traits<array_type>::storage (sm.data()); 
00059     }
00060     static int size1 (matrix_type& sm) { return sm.size1(); } 
00061     static int size2 (matrix_type& sm) { return sm.size2(); }
00062     static int storage_size (matrix_type& sm) { 
00063       return (size1 (sm) + 1) * size2 (sm) / 2; 
00064     }
00065   }; 
00066 
00067 
00068   // ublas::symmetric_adaptor<>
00069   template <typename M, typename F1, typename MA>
00070   struct matrix_detail_traits<boost::numeric::ublas::symmetric_adaptor<M, F1>, MA>
00071   {
00072 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00073     BOOST_STATIC_ASSERT( (boost::is_same<boost::numeric::ublas::symmetric_adaptor<M, F1>, typename boost::remove_const<MA>::type>::value) );
00074 #endif
00075 
00076     typedef boost::numeric::ublas::symmetric_adaptor<M, F1> identifier_type;
00077     typedef MA                                              matrix_type;
00078     typedef symmetric_t                                     matrix_structure; 
00079     typedef typename matrix_traits<M>::ordering_type        ordering_type; 
00080     typedef typename detail::ublas_uplo< F1 >::type         uplo_type; 
00081 
00082     typedef typename M::value_type                                 value_type; 
00083     typedef typename detail::generate_const<MA, value_type>::type* pointer; 
00084 
00085   private:
00086     typedef typename detail::generate_const<MA, typename MA::matrix_closure_type>::type m_type; 
00087 
00088   public:
00089     static pointer storage (matrix_type& sm) {
00090       return matrix_traits<m_type>::storage (sm.data());
00091     }
00092     static int size1 (matrix_type& sm) { return sm.size1(); } 
00093     static int size2 (matrix_type& sm) { return sm.size2(); }
00094     static int storage_size (matrix_type& sm) { 
00095       return size1 (sm) * size2 (sm); 
00096     }
00097     static int leading_dimension (matrix_type& sm) {
00098       return matrix_traits<m_type>::leading_dimension (sm.data()); 
00099     }
00100   }; 
00101 
00102 }}}}
00103 
00104 #endif // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00105 
00106 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_UBLAS_SYMMETRIC_H

Generated on Wed Nov 23 19:00:52 2011 for FreeCAD by  doxygen 1.6.1