1#ifndef IRLBA_TATAMI_TRANSPOSED_HPP
2#define IRLBA_TATAMI_TRANSPOSED_HPP
5#include "tatami_mult/tatami_mult.hpp"
6#include "irlba/irlba.hpp"
7#include "sanisizer/sanisizer.hpp"
21template<
class EigenVector_,
typename TValue_,
typename TIndex_,
class TMatrix_ = tatami::Matrix<TValue_, TIndex_> >
24 TransposedWorkspace(
const TMatrix_& mat,
int num_threads) : my_mat(mat) {
25 opt.num_threads = num_threads;
29 const TMatrix_& my_mat;
30 tatami_mult::Options opt;
33 void multiply(
const EigenVector_& right, EigenVector_& out) {
34 tatami_mult::multiply(right.data(), my_mat, out.data(), opt);
38template<
class EigenVector_,
typename TValue_,
typename TIndex_,
class TMatrix_ = tatami::Matrix<TValue_, TIndex_> >
41 TransposedAdjointWorkspace(
const TMatrix_& mat,
int num_threads) : my_mat(mat) {
42 opt.num_threads = num_threads;
46 const TMatrix_& my_mat;
47 tatami_mult::Options opt;
50 void multiply(
const EigenVector_& right, EigenVector_& out) {
51 tatami_mult::multiply(my_mat, right.data(), out.data(), opt);
55template<
class EigenMatrix_,
typename TValue_,
typename TIndex_,
class TMatrix_ = tatami::Matrix<TValue_, TIndex_> >
58 TransposedRealizeWorkspace(
const TMatrix_& mat,
int num_threads) : my_mat(mat), my_num_threads(num_threads) {}
61 const TMatrix_& my_mat;
65 const EigenMatrix_& realize(EigenMatrix_& buffer) {
68 buffer.resize(my_mat.ncol(), my_mat.nrow());
75 tatami::ConvertToDenseOptions opt;
76 opt.num_threads = my_num_threads;
102template<
class EigenVector_,
class EigenMatrix_,
typename TValue_,
typename TIndex_,
class TMatrixPo
inter_ = std::shared_ptr<const tatami::Matrix<TValue_, TIndex_> > >
110 Transposed(TMatrixPointer_ mat,
int num_threads) : my_mat(std::move(mat)), my_num_threads(num_threads) {
112 sanisizer::cast<Eigen::Index>(tatami::attest_for_Index(my_mat->nrow()));
113 sanisizer::cast<Eigen::Index>(tatami::attest_for_Index(my_mat->ncol()));
117 Eigen::Index rows()
const {
118 return my_mat->ncol();
121 Eigen::Index cols()
const {
122 return my_mat->nrow();
126 TMatrixPointer_ my_mat;
129 typedef std::remove_cv_t<std::remove_reference_t<
decltype(*my_mat)> > TMatrix;
132 std::unique_ptr<irlba::Workspace<EigenVector_> > new_workspace()
const {
136 std::unique_ptr<irlba::AdjointWorkspace<EigenVector_> > new_adjoint_workspace()
const {
140 std::unique_ptr<irlba::RealizeWorkspace<EigenMatrix_> > new_realize_workspace()
const {
149 return std::make_unique<TransposedWorkspace<EigenVector_, TValue_, TIndex_, TMatrix> >(*my_mat, my_num_threads);
156 return std::make_unique<TransposedAdjointWorkspace<EigenVector_, TValue_, TIndex_, TMatrix> >(*my_mat, my_num_threads);
163 return std::make_unique<TransposedRealizeWorkspace<EigenMatrix_, TValue_, TIndex_, TMatrix> >(*my_mat, my_num_threads);
Wrap a transposed tatami matrix for irlba.
Definition transposed.hpp:103
auto new_known_adjoint_workspace() const
Definition transposed.hpp:155
Transposed(TMatrixPointer_ mat, int num_threads)
Definition transposed.hpp:110
auto new_known_realize_workspace() const
Definition transposed.hpp:162
auto new_known_workspace() const
Definition transposed.hpp:148
void convert_to_dense(const Matrix< InputValue_, InputIndex_ > &matrix, const bool row_major, StoredValue_ *const store, const ConvertToDenseOptions &options)