tnt.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_TNT_H
00015 #define BOOST_NUMERIC_BINDINGS_TRAITS_TNT_H
00016 
00017 // Roldan Pozo's TNT (Template Numerical Toolkit)
00018 // see: http://math.nist.gov/tnt/index.html
00019 
00020 #include <boost/numeric/bindings/traits/config.hpp> 
00021 
00022 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00023 
00024 #include <boost/numeric/bindings/traits/traits.hpp>
00025 #include <tnt/tnt_array1d.h>
00026 #include <tnt/tnt_fortran_array1d.h>
00027 #include <tnt/tnt_array2d.h>
00028 #include <tnt/tnt_fortran_array2d.h>
00029 
00030 namespace boost { namespace numeric { namespace bindings { namespace traits {
00031 
00032   // TNT::Array1D<>
00033   template <typename T, typename V>
00034   struct vector_detail_traits<TNT::Array1D<T>, V> 
00035   {
00036 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00037     BOOST_STATIC_ASSERT( 
00038       (boost::is_same< 
00039          TNT::Array1D<T>, typename boost::remove_const<V>::type 
00040        >::value) );
00041 #endif
00042 
00043     typedef TNT::Array1D<T> identifier_type; 
00044     typedef V vector_type;
00045     typedef T value_type; 
00046     typedef typename detail::generate_const<V,T>::type* pointer; 
00047 
00048     static pointer storage (vector_type& v) { return &v[0]; }
00049     static int size (vector_type& v) { return v.dim(); } 
00050     static int stride (vector_type& v) { return 1; } 
00051   }; 
00052 
00053   // TNT::Fortran_Array1D<>
00054   template <typename T, typename V>
00055   struct vector_detail_traits<TNT::Fortran_Array1D<T>, V> 
00056   {
00057 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00058     BOOST_STATIC_ASSERT( 
00059       (boost::is_same< 
00060          TNT::Fortran_Array1D<T>, typename boost::remove_const<V>::type 
00061        >::value) );
00062 #endif
00063 
00064     typedef TNT::Fortran_Array1D<T> identifier_type; 
00065     typedef V vector_type;
00066     typedef T value_type; 
00067     typedef typename detail::generate_const<V,T>::type* pointer; 
00068 
00069     static pointer storage (vector_type& v) { return &v(1); }
00070     static int size (vector_type& v) { return v.dim(); } 
00071     static int stride (vector_type& v) { return 1; } 
00072   }; 
00073 
00074 
00075   // TNT::Array2D<>
00076   template <typename T, typename M>
00077   struct matrix_detail_traits<TNT::Array2D<T>, M> 
00078   {
00079 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00080     BOOST_STATIC_ASSERT( 
00081       (boost::is_same< 
00082          TNT::Array2D<T>, typename boost::remove_const<M>::type 
00083        >::value) );
00084 #endif
00085 
00086     typedef TNT::Array2D<T> identifier_type; 
00087     typedef M matrix_type;
00088     typedef general_t matrix_structure; 
00089     typedef row_major_t ordering_type; 
00090 
00091     typedef T value_type; 
00092     typedef typename detail::generate_const<M,T>::type* pointer; 
00093 
00094     static pointer storage (matrix_type& m) { return m[0]; }
00095     static int size1 (matrix_type& m) { return m.dim1(); } 
00096     static int size2 (matrix_type& m) { return m.dim2(); } 
00097     static int storage_size (matrix_type& m) { 
00098       return size1 (m) * size2 (m); 
00099     }
00100     static int leading_dimension (matrix_type& m) { return m.dim2(); } 
00101   }; 
00102 
00103   // TNT::Fortran_Array2D<>
00104   template <typename T, typename M>
00105   struct matrix_detail_traits<TNT::Fortran_Array2D<T>, M> {
00106 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00107     BOOST_STATIC_ASSERT( 
00108       (boost::is_same< 
00109          TNT::Fortran_Array2D<T>, typename boost::remove_const<M>::type 
00110        >::value) );
00111 #endif
00112 
00113     typedef TNT::Fortran_Array2D<T> identifier_type; 
00114     typedef M matrix_type;
00115     typedef general_t matrix_structure; 
00116     typedef column_major_t ordering_type; 
00117 
00118     typedef T value_type; 
00119     typedef typename detail::generate_const<M,T>::type* pointer; 
00120 
00121     static pointer storage (matrix_type& m) { return &m(1, 1); }
00122     static int size1 (matrix_type& m) { return m.dim1(); } 
00123     static int size2 (matrix_type& m) { return m.dim2(); } 
00124     static int storage_size (matrix_type& m) { 
00125       return size1 (m) * size2 (m); 
00126     }
00127     static int leading_dimension (matrix_type& m) { return m.dim1(); } 
00128   }; 
00129 
00130 }}}}  
00131 
00132 #else // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00133 
00134 #error with your compiler TNT cannot be used in bindings
00135 
00136 #endif // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00137 
00138 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_TNT_H

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