yat  0.21pre
TransposedMatrix.h
1 #ifndef _theplu_yat_utility_expression_transposed_matrix
2 #define _theplu_yat_utility_expression_transposed_matrix
3 
4 // $Id: TransposedMatrix.h 3908 2020-05-13 06:58:38Z peter $
5 
6 /*
7  Copyright (C) 2020 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 
26 namespace theplu {
27 namespace yat {
28 namespace utility {
29 namespace expression {
30 
32 
33  template<class T>
34  class TransposedMatrix : public MatrixExpression<TransposedMatrix<T> >
35  {
36  public:
37  TransposedMatrix(const BasicMatrix<T>& A)
38  : A_(A) {}
39 
40  size_t rows(void) const { return A_.columns(); }
41  size_t columns(void) const { return A_.rows(); }
42 
43  double operator()(size_t i, size_t j) const
44  {
45  return A_(j, i);
46  }
47 
48  void calculate_matrix(gsl_matrix*& result) const
49  {
50  detail::reallocate(result, rows(), columns());
51  gsl_matrix_transpose_memcpy(result, A_.gsl_matrix_p());
52  }
53 
54  const T& base(void) const
55  {
56  return static_cast<const T&>(A_);
57  }
58 
59  private:
60  const BasicMatrix<T>& A_;
61  };
62 
64 
65 }}}} // of namespace expression, utility, yat, and theplu
66 
67 #endif
The Department of Theoretical Physics namespace as we define it.

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14