matSupSub.hpp

Go to the documentation of this file.
00001 /*
00002  * Bayes++ the Bayesian Filtering Library
00003  * Copyright (c) 2002 Michael Stevens
00004  * See accompanying Bayes++.htm for terms and conditions of use.
00005  *
00006  * $Id: matSupSub.hpp 562 2006-04-05 20:46:23 +0200 (Wed, 05 Apr 2006) mistevens $
00007  */
00008 
00009 /*
00010  * Matrix types for filter classes
00011  *  Provides the predefined type 'Vec' and a variety of 'Matrix' types
00012  *  Replace this header to substitute alternative matrix support
00013  *
00014  * Everything in namespace Bayes_filter_matrix is intended to support the matrix storage
00015  * and algebra requirements of the library. Therefore the interfaces and implementation is
00016  * not intended to be stable.
00017  */
00018 
00019 /*
00020  * Use the Boost uBLAS Basic Linear Algebra library
00021  * That is boost::numeric::ublas
00022  *  Thanks to Joerg Walter and Mathias Koch for an excellent library!
00023  *
00024  * Gappy matrix support: The macros BAYES_FILTER_(SPARSE/COMPRESSED/COORDINATE) control experimental gappy matrix support
00025  * When enabled the default storage types are replaced with their sparse equivilents
00026  */
00027 
00028 #include <boost/version.hpp>
00029 #if !(BOOST_VERSION >= 103200)
00030 #error Requires Boost 1.32.0 or later
00031 #endif
00032 
00033 #include <boost/numeric/ublas/vector.hpp>
00034 #include <boost/numeric/ublas/vector_proxy.hpp>
00035 #include <boost/numeric/ublas/matrix.hpp>
00036 #include <boost/numeric/ublas/matrix_proxy.hpp>
00037 #include <boost/numeric/ublas/symmetric.hpp>
00038 #include <boost/numeric/ublas/triangular.hpp>
00039 #include <boost/numeric/ublas/banded.hpp>
00040 #if defined(BAYES_FILTER_MAPPED) || defined(BAYES_FILTER_COMPRESSED) || defined(BAYES_FILTER_COORDINATE)
00041 #include <map>
00042 #include <boost/numeric/ublas/vector_sparse.hpp>
00043 #include <boost/numeric/ublas/matrix_sparse.hpp>
00044 #define BAYES_FILTER_GAPPY
00045 #endif
00046 
00047 
00048 
00049 /* Filter Matrix Namespace */
00050 namespace Bayesian_filter_matrix
00051 {
00052                         // Allow use of a local ublas namespace
00053 namespace ublas = boost::numeric::ublas;
00054 
00055 /*
00056  * Declare the value used for ALL linear algebra operations
00057  * Also required as the matrix/vector container value_type
00058  */
00059 typedef double Float;
00060 
00061 /*
00062  * uBlas base types - these will be wrapper to provide the actual vector and matrix types
00063  *  Symmetric types don't appear. They are defined later by adapting these base types
00064  */
00065 namespace detail {
00066                             // Dense types
00067 typedef ublas::vector<Float> BaseDenseVector;
00068 typedef ublas::matrix<Float, ublas::row_major> BaseDenseRowMatrix;
00069 typedef ublas::matrix<Float, ublas::column_major> BaseDenseColMatrix;
00070 typedef ublas::triangular_matrix<Float, ublas::upper, ublas::row_major> BaseDenseUpperTriMatrix;
00071 typedef ublas::triangular_matrix<Float, ublas::lower, ublas::row_major> BaseDenseLowerTriMatrix;
00072 typedef ublas::banded_matrix<Float> BaseDenseDiagMatrix;
00073                             // Mapped types
00074 #if defined(BAYES_FILTER_MAPPED)
00075 typedef ublas::mapped_vector<Float, std::map<std::size_t,Float> > BaseSparseVector;
00076 typedef ublas::mapped_matrix<Float, ublas::row_major, std::map<std::size_t,Float> > BaseSparseRowMatrix;
00077 typedef ublas::mapped_matrix<Float, ublas::column_major, std::map<std::size_t,Float> > BaseSparseColMatrix;
00078                             // OR Compressed types
00079 #elif defined(BAYES_FILTER_COMPRESSED)
00080 typedef ublas::compressed_vector<Float> BaseSparseVector;
00081 typedef ublas::compressed_matrix<Float, ublas::row_major> BaseSparseRowMatrix;
00082 typedef ublas::compressed_matrix<Float, ublas::column_major> BaseSparseColMatrix;
00083                             // OR Coordinate types
00084 #elif defined(BAYES_FILTER_COORDINATE)
00085 typedef ublas::coordinate_vector<Float> BaseSparseVector;
00086 typedef ublas::coordinate_matrix<Float, ublas::row_major> BaseSparseRowMatrix;
00087 typedef ublas::coordinate_matrix<Float, ublas::column_major> BaseSparseColMatrix;
00088 #endif
00089 
00090                             // Default types Dense or Gappy
00091 #ifndef BAYES_FILTER_GAPPY
00092 typedef BaseDenseVector BaseVector;
00093 typedef BaseDenseRowMatrix BaseRowMatrix;
00094 typedef BaseDenseColMatrix BaseColMatrix;
00095 typedef BaseDenseUpperTriMatrix BaseUpperTriMatrix;
00096 typedef BaseDenseLowerTriMatrix BaseLowerTriMatrix;
00097 typedef BaseDenseDiagMatrix BaseDiagMatrix;
00098 #else
00099 typedef BaseSparseVector BaseVector;
00100 typedef BaseSparseRowMatrix BaseRowMatrix;
00101 typedef BaseSparseColMatrix BaseColMatrix;
00102 typedef BaseDenseUpperTriMatrix BaseUpperTriMatrix;     // No sparse triangular or banded
00103 typedef BaseDenseLowerTriMatrix BaseLowerTriMatrix;
00104 typedef BaseDenseDiagMatrix BaseDiagMatrix;
00105 #endif
00106 
00107 }
00108 
00109 }//namespace
00110 
00111 /*
00112  * Common type independant uBlas interface
00113  */
00114 #include "uBLASmatrix.hpp"

Generated on Wed Oct 4 22:57:23 2006 for Bayes++ Bayesian Filtering Classes by  doxygen 1.4.6