NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
svd.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <utility>
31
34#include "NumCpp/NdArray.hpp"
35
36namespace nc::linalg
37{
38 //============================================================================
39 // Method Description:
49 template<typename dtype>
50 void svd(const NdArray<dtype>& inArray, NdArray<double>& outU, NdArray<double>& outS, NdArray<double>& outVT)
51 {
53
54 const auto svd = SVD{ inArray };
55
56 outU = svd.u();
57 outS = std::move(svd.s()[Slice(std::min(inArray.numRows(), inArray.numCols()))]);
58 outVT = std::move(svd.v().transpose());
59 }
60} // namespace nc::linalg
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
size_type numCols() const noexcept
Definition NdArrayCore.hpp:3541
size_type numRows() const noexcept
Definition NdArrayCore.hpp:3553
A Class for slicing into NdArrays.
Definition Slice.hpp:45
Performs the singular value decomposition of a general matrix.
Definition svd/svd.hpp:48
Definition cholesky.hpp:41
void svd(const NdArray< dtype > &inArray, NdArray< double > &outU, NdArray< double > &outS, NdArray< double > &outVT)
Definition svd.hpp:50