monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
transpose_dense.cpp
Go to the documentation of this file.
1 #include "../../../include/common/monolish_dense.hpp"
2 #include "../../../include/common/monolish_logger.hpp"
3 #include "../../../include/common/monolish_matrix.hpp"
4 #include "../../internal/monolish_internal.hpp"
5 
6 namespace monolish {
7 namespace matrix {
8 
9 template <typename T> Dense<T> &Dense<T>::transpose() {
10  Logger &logger = Logger::get_instance();
11  logger.util_in(monolish_func);
12  Dense<T> B(get_col(), get_row());
13  for (size_t i = 0; i < B.get_row(); ++i) {
14  for (size_t j = 0; j < B.get_col(); ++j) {
15  B.val[i * B.get_col() + j] = val[j * B.get_row() + i];
16  }
17  }
18  std::copy(B.val.data(), B.val.data() + nnz, val.begin());
19  set_row(B.get_row());
20  set_col(B.get_col());
21  logger.util_out();
22  return *this;
23 }
26 
27 template <typename T> void Dense<T>::transpose(const Dense<T> &B) {
28  Logger &logger = Logger::get_instance();
29  logger.util_in(monolish_func);
30  set_row(B.get_col());
31  set_col(B.get_row());
32  val.resize(B.get_row() * B.get_col());
33 
34  for (size_t i = 0; i < get_row(); ++i) {
35  for (size_t j = 0; j < get_col(); ++j) {
36  val[i * get_col() + j] = B.val[j * get_row() + i];
37  }
38  }
39  logger.util_out();
40 }
41 template void Dense<double>::transpose(const Dense<double> &B);
42 template void Dense<float>::transpose(const Dense<float> &B);
43 
44 } // namespace matrix
45 } // namespace monolish
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::Logger
logger class (singleton, for developper class)
Definition: monolish_logger.hpp:19
monolish::matrix::Dense::get_row
size_t get_row() const
get # of row
Definition: monolish_dense.hpp:199
monolish::matrix::Dense::val
std::vector< Float > val
Dense format value(size M x N)
Definition: monolish_dense.hpp:47
monolish::matrix::Dense
Dense format Matrix.
Definition: monolish_coo.hpp:28
monolish::matrix::Dense::transpose
Dense & transpose()
get transposed matrix (A^T)
Definition: transpose_dense.cpp:9
monolish::Logger::util_out
void util_out()
Definition: logger_utils.cpp:123
monolish::Logger::util_in
void util_in(const std::string func_name)
Definition: logger_utils.cpp:113
monolish::blas::copy
void copy(const matrix::Dense< double > &A, matrix::Dense< double > &C)
Dense matrix copy (C=A)
Definition: dense_copy.cpp:25
monolish
Definition: monolish_matrix_blas.hpp:9
monolish::matrix::Dense::get_col
size_t get_col() const
get # of col
Definition: monolish_dense.hpp:208
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42