So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Evaluators.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2015 Gilles Daviet <gdaviet@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10 
11 #ifndef BOGUS_BLOCK_EVALUATORS_HPP
12 #define BOGUS_BLOCK_EVALUATORS_HPP
13 
14 #include "Traits.hpp"
15 
16 namespace bogus {
17 
19 template< typename Src, typename Dest = typename BlockMatrixTraits<Src>::PlainObjectType >
20 struct Evaluator ;
21 
22 template< typename Src, typename Dest >
23 struct Evaluator {
24  Dest val ;
25 
26  Evaluator( const Src& src )
27  : val(src)
28  {}
29 
30  const Dest& operator * ( ) const {
31  return val;
32  }
33  const Dest* operator -> ( ) const {
34  return &val;
35  }
36 };
37 
38 
39 template< typename Src >
40 struct Evaluator< Src, Src > {
41  const Src &val ;
42 
43  Evaluator( const Src& src )
44  : val(src)
45  {}
46 
47  const Src& operator * ( ) const {
48  return val;
49  }
50  const Src* operator -> ( ) const {
51  return &val;
52  }
53 };
54 
55 template< typename Src, typename Dest >
56 struct Evaluator< Transpose<Src>, Dest >
57 : public Evaluator< Src, Dest >
58 {
59  Evaluator( const Transpose< Src >& src )
60  : Evaluator< Src, Dest >( src.matrix )
61  {}
62 } ;
63 
64 }
65 
66 #endif
Base class for Transpose views of a BlockObjectBase.
Definition: Expressions.hpp:22
Evaluates an expression inside a temporary if necessary, otherwise returns directly a matrix referenc...
Definition: Evaluators.hpp:20