ProxyReferenceTraits.h
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief Traits which allow to define ProxyReferences for types
5  *
6  * A ProxyReference can be used in the context of abstract functions to bind several related types
7  * of arguments to a single proxy type. Main use are ublas expression templates so that
8  * vectors, matrix rows and subvectors can be treated as one argument type
9  *
10  *
11  *
12  * \author O.Krause
13  * \date 2012
14  *
15  *
16  * \par Copyright 1995-2017 Shark Development Team
17  *
18  * <BR><HR>
19  * This file is part of Shark.
20  * <http://shark-ml.org/>
21  *
22  * Shark is free software: you can redistribute it and/or modify
23  * it under the terms of the GNU Lesser General Public License as published
24  * by the Free Software Foundation, either version 3 of the License, or
25  * (at your option) any later version.
26  *
27  * Shark is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  *
32  * You should have received a copy of the GNU Lesser General Public License
33  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
34  *
35  */
36 #ifndef SHARC_CORE_PROXYREFERENCETRAITS_H
37 #define SHARC_CORE_PROXYREFERENCETRAITS_H
38 #include <string>
39 #include <shark/LinAlg/Base.h>
40 namespace shark {
41  ///\brief sets the type of ProxxyReference
42  ///
43  ///A Proxy referencecan be used when several related types are to be treated by one proxy type
44  ///argument, for example expression templates
45  template<class T>
47  typedef T const& type;
48  };
49 
50  /// \cond
51 
52  template<class T>
53  struct ConstProxyReference<blas::vector<T> >{
54  typedef blas::dense_vector_adaptor<T const> const& type;
55  };
56  template<class T>
57  struct ConstProxyReference<blas::vector<T> const>{
58  typedef blas::dense_vector_adaptor<T const> const& type;
59  };
60  template<class T>
61  struct ConstProxyReference<blas::compressed_vector<T> >{
62  typedef blas::sparse_vector_adaptor<T const,std::size_t> const& type;
63  };
64  template<class T>
65  struct ConstProxyReference<blas::compressed_vector<T> const >{
66  typedef blas::sparse_vector_adaptor<T const,std::size_t> const& type;
67  };
68  template<class T>
69  struct ConstProxyReference<blas::matrix<T> >{
70  typedef blas::dense_matrix_adaptor<T const,blas::row_major> const& type;
71  };
72  template<class T>
73  struct ConstProxyReference<blas::matrix<T> const >{
74  typedef blas::dense_matrix_adaptor<T const,blas::row_major> const& type;
75  };
76 
77  /// \endcond
78 }
79 #endif