56 template<
typename dtype>
61 const auto& aShape = inA.
shape();
62 const auto& bShape = inB.
shape();
64 const auto bIsFlat = inB.
isflat();
65 if (bIsFlat && bShape.size() != aShape.rows)
69 else if (!bIsFlat && inA.
shape().
rows != bShape.rows)
74 SVD svd(inA.template astype<double>());
78 return svd.lstsq(inB.template astype<double>());
81 const auto bCast = inB.template astype<double>();
82 const auto bRowSlice = bCast.rSlice();
85 const auto resultRowSlice = result.rSlice();
87 for (
uint32 col = 0; col < bShape.cols; ++col)
89 result.put(resultRowSlice, col,
svd.lstsq(bCast(bRowSlice, col)));
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
bool isflat() const noexcept
Definition: NdArrayCore.hpp:3025
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4591
uint32 rows
Definition: Core/shape.hpp:44
Performs the singular value decomposition of a general matrix.
Definition: svd/SVD.hpp:50
Definition: cholesky.hpp:41
void svd(const NdArray< dtype > &inArray, NdArray< double > &outU, NdArray< double > &outS, NdArray< double > &outVT)
Definition: SVD.hpp:51
NdArray< double > lstsq(const NdArray< dtype > &inA, const NdArray< dtype > &inB)
Definition: lstsq.hpp:57
std::uint32_t uint32
Definition: Types.hpp:40