NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
lstsq.hpp
Go to the documentation of this file.
1
28#pragma once
29
32#include "NumCpp/NdArray.hpp"
33
34namespace nc::linalg
35{
36 //============================================================================
37 // Method Description:
56 template<typename dtype>
57 NdArray<double> lstsq(const NdArray<dtype>& inA, const NdArray<dtype>& inB, double inTolerance = 1e-12)
58 {
60
61 SVD svdSolver(inA.template astype<double>());
62 const double threshold = inTolerance * svdSolver.s().front();
63
64 return svdSolver.solve(inB.template astype<double>(), threshold);
65 }
66} // namespace nc::linalg
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
const_reference front() const noexcept
Definition: NdArrayCore.hpp:2860
Definition: SVDClass.hpp:47
NdArray< double > solve(const NdArray< double > &inInput, double inThresh=-1.)
Definition: SVDClass.hpp:110
const NdArray< double > & s() noexcept
Definition: SVDClass.hpp:96
constexpr double e
eulers number
Definition: Core/Constants.hpp:37
Definition: cholesky.hpp:41
NdArray< double > lstsq(const NdArray< dtype > &inA, const NdArray< dtype > &inB, double inTolerance=1e-12)
Definition: lstsq.hpp:57