Bayes++ Bayesian Filtering Classes Release 2014.5 - Copyright (c) 2003,2004,2005,2006,2011,2012,2014 Michael Stevens
matSupSub.hpp
Go to the documentation of this file.
1/*
2 * Bayes++ the Bayesian Filtering Library
3 * Copyright (c) 2002 Michael Stevens
4 * See accompanying Bayes++.htm for terms and conditions of use.
5 *
6 * $Id$
7 */
8
9/*
10 * Matrix types for filter classes
11 * Provides the predefined type 'Vec' and a variety of 'Matrix' types
12 * Replace this header to substitute alternative matrix support
13 *
14 * Everything in namespace Bayes_filter_matrix is intended to support the matrix storage
15 * and algebra requirements of the library. Therefore the interfaces and implementation is
16 * not intended to be stable.
17 */
18
19/*
20 * Use the Boost uBLAS Basic Linear Algebra library
21 * That is boost::numeric::ublas
22 * Thanks to Joerg Walter and Mathias Koch for an excellent library!
23 *
24 * Gappy matrix support: The macros BAYES_FILTER_(SPARSE/COMPRESSED/COORDINATE) control experimental gappy matrix support
25 * When enabled the default storage types are replaced with their sparse equivalents
26 */
27
28#include <boost/version.hpp>
29#include <boost/numeric/ublas/vector.hpp>
30#include <boost/numeric/ublas/vector_proxy.hpp>
31#include <boost/numeric/ublas/matrix.hpp>
32#include <boost/numeric/ublas/matrix_proxy.hpp>
33#include <boost/numeric/ublas/symmetric.hpp>
34#include <boost/numeric/ublas/triangular.hpp>
35#include <boost/numeric/ublas/banded.hpp>
36#if defined(BAYES_FILTER_MAPPED) || defined(BAYES_FILTER_COMPRESSED) || defined(BAYES_FILTER_COORDINATE)
37#include <map>
38#include <boost/numeric/ublas/vector_sparse.hpp>
39#include <boost/numeric/ublas/matrix_sparse.hpp>
40#define BAYES_FILTER_GAPPY
41#endif
42
43
44
45/* Filter Matrix Namespace */
47{
48 // Allow use of a local ublas namespace
49namespace ublas = boost::numeric::ublas;
50
51/*
52 * Declare the value used for ALL linear algebra operations
53 * Also required as the matrix/vector container value_type
54 */
55typedef double Float;
56
57/*
58 * uBlas base types - these will be wrapper to provide the actual vector and matrix types
59 * Symmetric types don't appear. They are defined later by adapting these base types
60 */
61namespace detail {
62 // Dense types
63typedef ublas::vector<Float> BaseDenseVector;
64typedef ublas::matrix<Float, ublas::row_major> BaseDenseRowMatrix;
65typedef ublas::matrix<Float, ublas::column_major> BaseDenseColMatrix;
66typedef ublas::triangular_matrix<Float, ublas::upper, ublas::row_major> BaseDenseUpperTriMatrix;
67typedef ublas::triangular_matrix<Float, ublas::lower, ublas::row_major> BaseDenseLowerTriMatrix;
68typedef ublas::banded_matrix<Float> BaseDenseDiagMatrix;
69 // Mapped types
70#if defined(BAYES_FILTER_MAPPED)
71typedef ublas::mapped_vector<Float, std::map<std::size_t,Float> > BaseSparseVector;
72typedef ublas::mapped_matrix<Float, ublas::row_major, std::map<std::size_t,Float> > BaseSparseRowMatrix;
73typedef ublas::mapped_matrix<Float, ublas::column_major, std::map<std::size_t,Float> > BaseSparseColMatrix;
74 // OR Compressed types
75#elif defined(BAYES_FILTER_COMPRESSED)
76typedef ublas::compressed_vector<Float> BaseSparseVector;
77typedef ublas::compressed_matrix<Float, ublas::row_major> BaseSparseRowMatrix;
78typedef ublas::compressed_matrix<Float, ublas::column_major> BaseSparseColMatrix;
79 // OR Coordinate types
80#elif defined(BAYES_FILTER_COORDINATE)
81typedef ublas::coordinate_vector<Float> BaseSparseVector;
82typedef ublas::coordinate_matrix<Float, ublas::row_major> BaseSparseRowMatrix;
83typedef ublas::coordinate_matrix<Float, ublas::column_major> BaseSparseColMatrix;
84#endif
85
86 // Default types Dense or Gappy
87#ifndef BAYES_FILTER_GAPPY
94#else
95typedef BaseSparseVector BaseVector;
96typedef BaseSparseRowMatrix BaseRowMatrix;
97typedef BaseSparseColMatrix BaseColMatrix;
98typedef BaseDenseUpperTriMatrix BaseUpperTriMatrix; // No sparse triangular or banded
101#endif
102
103}
104
105}//namespace
106
107/*
108 * Common type independent uBlas interface
109 */
110#include "uBLASmatrix.hpp"
BaseDenseRowMatrix BaseRowMatrix
Definition matSupSub.hpp:89
BaseDenseDiagMatrix BaseDiagMatrix
Definition matSupSub.hpp:93
BaseDenseLowerTriMatrix BaseLowerTriMatrix
Definition matSupSub.hpp:92
ublas::banded_matrix< Float > BaseDenseDiagMatrix
Definition matSupSub.hpp:68
ublas::triangular_matrix< Float, ublas::lower, ublas::row_major > BaseDenseLowerTriMatrix
Definition matSupSub.hpp:67
BaseDenseUpperTriMatrix BaseUpperTriMatrix
Definition matSupSub.hpp:91
ublas::matrix< Float, ublas::row_major > BaseDenseRowMatrix
Definition matSupSub.hpp:64
ublas::vector< Float > BaseDenseVector
Definition matSupSub.hpp:63
ublas::triangular_matrix< Float, ublas::upper, ublas::row_major > BaseDenseUpperTriMatrix
Definition matSupSub.hpp:66
ublas::matrix< Float, ublas::column_major > BaseDenseColMatrix
Definition matSupSub.hpp:65
BaseDenseVector BaseVector
Definition matSupSub.hpp:88
BaseDenseColMatrix BaseColMatrix
Definition matSupSub.hpp:90
Definition matSup.cpp:34
double Float
Definition matSupSub.hpp:55