cheshirekow  v0.1.0
transpose.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of fiber.
5  *
6  * fiber is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * fiber is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with fiber. If not, see <http://www.gnu.org/licenses/>.
18  */
25 #ifndef FIBER_TRANSPOSE_H_
26 #define FIBER_TRANSPOSE_H_
27 
28 
29 namespace fiber {
30 
32 template <typename Scalar, class Exp>
33 class _Transpose : public _RValue<Scalar, _Transpose<Scalar, Exp> > {
34  Exp const& m_A;
35 
36  public:
37  enum {
38  ROWS_ = Exp::COLS_,
39  COLS_ = Exp::ROWS_,
40  SIZE_ = Exp::SIZE_
41  };
42 
43  _Transpose(Exp const& A) : m_A(A) {}
44 
45  Size size() const { return m_A.size(); }
46  Size rows() const { return m_A.cols(); }
47  Size cols() const { return m_A.rows(); }
48 
49  Scalar operator[](Size i) const { return m_A[i]; }
50  Scalar operator()(Size i, Size j) const { return m_A(j, i); }
51 };
52 
53 template <typename Scalar, class Exp>
55  return _Transpose<Scalar, Exp>(static_cast<Exp const&>(A));
56 }
57 
58 } // namespace fiber
59 
60 
61 #endif // FIBER_TRANSPOSE_H_
Exp const & m_A
Definition: transpose.h:34
expression template for rvalues
Definition: rvalue.h:33
expression template for difference of two matrix expressions
Definition: transpose.h:33
unsigned int Size
Definition: fiber.h:32
Scalar operator()(Size i, Size j) const
Definition: transpose.h:50
Scalar operator[](Size i) const
Definition: transpose.h:49
Size cols() const
Definition: transpose.h:47
_Transpose< Scalar, Exp > Transpose(_RValue< Scalar, Exp > const &A)
Definition: transpose.h:54
_Transpose(Exp const &A)
Definition: transpose.h:43
Size size() const
Definition: transpose.h:45
Size rows() const
Definition: transpose.h:46