/// Materialize a linear operator into a dense column-major matrix.
/// Computes A_dense = A_linop * I by applying the operator to the identity.
template <typename T, typename LinOp>
::std::vector materialize_linop(LinOp& A_linop, int64_t m, int64_t n) {
::std::vector A_dense(m * n, 0.0);
::std::vector Eye(n * n, 0.0);
::RandLAPACK::util::eye(n, n, Eye.data());
A_linop(::blas::Side::Left, ::blas::Layout::ColMajor, ::blas::Op::NoTrans, ::blas::Op::NoTrans,
m, n, n, (T)1.0, Eye.data(), n, (T)0.0, A_dense.data(), m);
return A_dense;
}
Riley says: I'd caution against using this function in testing. In RandBLAS we have separate to_explicit_buffer implementations for different types. This is needed in order to have valid tests of correctness for linear operators. (Note how some of RandBLAS' linear operators tests are literally just applying the linop to the identity matrix.)
Max says: I'll keep it for now because I may be using it in forthcoming parts of PR#115; added a comment though
/// Materialize a linear operator into a dense column-major matrix.
/// Computes A_dense = A_linop * I by applying the operator to the identity.
template <typename T, typename LinOp>
::std::vector materialize_linop(LinOp& A_linop, int64_t m, int64_t n) {
::std::vector A_dense(m * n, 0.0);
::std::vector Eye(n * n, 0.0);
::RandLAPACK::util::eye(n, n, Eye.data());
A_linop(::blas::Side::Left, ::blas::Layout::ColMajor, ::blas::Op::NoTrans, ::blas::Op::NoTrans,
m, n, n, (T)1.0, Eye.data(), n, (T)0.0, A_dense.data(), m);
return A_dense;
}
Riley says: I'd caution against using this function in testing. In RandBLAS we have separate to_explicit_buffer implementations for different types. This is needed in order to have valid tests of correctness for linear operators. (Note how some of RandBLAS' linear operators tests are literally just applying the linop to the identity matrix.)
Max says: I'll keep it for now because I may be using it in forthcoming parts of PR#115; added a comment though