sparse_traits.hpp

Go to the documentation of this file.
00001 /*
00002  * 
00003  * Copyright (c) 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 author acknowledges the support of the Faculty of Civil Engineering, 
00010  * University of Zagreb, Croatia.
00011  *
00012  */
00013 
00014 #ifndef BOOST_NUMERIC_BINDINGS_TRAITS_SPARSE_TRAITS_H
00015 #define BOOST_NUMERIC_BINDINGS_TRAITS_SPARSE_TRAITS_H
00016 
00017 #include <boost/numeric/bindings/traits/config.hpp> 
00018 
00019 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00020 
00021 #include <boost/numeric/bindings/traits/traits.hpp>
00022 
00023 namespace boost { namespace numeric { namespace bindings { namespace traits {
00024 
00027 
00029   template <typename MIdentifier, typename MType>
00030   struct sparse_matrix_detail_traits {
00031     typedef MIdentifier identifier_type;
00032     typedef MType       matrix_type; 
00033   };
00034 
00036   template <typename M>
00037   struct sparse_matrix_traits 
00038     : sparse_matrix_detail_traits <typename boost::remove_const<M>::type, M>
00039   {
00040     // typedefs:
00041     //   matrix_structure 
00042     //   storage_format 
00043     //   ordering_type
00044     //   value_type
00045     //   value_pointer
00046     //   index_pointer 
00047     // enum (or static size_t const): 
00048     //   index_base
00049     // static functions:
00050     //   index_pointer index1_storage()
00051     //     - compressed column: array of column start locations 
00052     //     - compressed row: array of row start locations 
00053     //     - coordinate, column major: column indices of nonzeros
00054     //     - coordinate, row major: row indices of nonzeros
00055     //   index_pointer index2_storage()
00056     //     - compressed column: array of row indices of nonzeros
00057     //     - compressed row: array of column indices of nonzeros
00058     //     - coordinate, column major: row indices of nonzeros
00059     //     - coordinate, row major: column indices of nonzeros
00060     //   value_pointer value_storage()
00061     //     - array of nonzeros 
00062     //   int size1()
00063     //   int size2()
00064     //   int num_nonzeros() 
00065   }; 
00066 
00067 
00068   // storage format tags 
00069   struct compressed_t {};
00070   struct coordinate_t {}; 
00071 
00072 
00074   //
00075   // free accessor functions
00076   //
00078 
00079   template <typename M>
00080   inline
00081   typename sparse_matrix_traits<M>::index_pointer 
00082   spmatrix_index1_storage (M& m) { 
00083     return sparse_matrix_traits<M>::index1_storage (m); 
00084   }
00085   template <typename M>
00086   inline
00087   typename sparse_matrix_traits<M>::index_pointer 
00088   spmatrix_index2_storage (M& m) { 
00089     return sparse_matrix_traits<M>::index2_storage (m); 
00090   }
00091   
00092   template <typename M>
00093   inline
00094   typename sparse_matrix_traits<M>::value_pointer 
00095   spmatrix_value_storage (M& m) { 
00096     return sparse_matrix_traits<M>::value_storage (m); 
00097   }
00098   
00099   template <typename M>
00100   inline
00101   int spmatrix_size1 (M& m) { return sparse_matrix_traits<M>::size1 (m); }
00102   template <typename M>
00103   inline
00104   int spmatrix_size2 (M& m) { return sparse_matrix_traits<M>::size2 (m); }
00105   
00106   template <typename M>
00107   inline
00108   int spmatrix_num_nonzeros (M& m) { 
00109     return sparse_matrix_traits<M>::num_nonzeros (m); 
00110   }
00111   
00112   
00113 }}}}  
00114 
00115 #else // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00116 
00117 #error with your compiler sparse matrices cannot be used in bindings
00118 
00119 #endif // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS 
00120 
00121 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_SPARSE_TRAITS_H

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