NumCpp
2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
|
Namespaces | |
namespace | detail |
Data Structures | |
class | SVD |
Functions | |
template<typename dtype > | |
NdArray< double > | cholesky (const NdArray< dtype > &inMatrix) |
template<typename dtype > | |
auto | det (const NdArray< dtype > &inArray) |
template<typename dtype , typename... Params, std::enable_if_t< std::is_arithmetic_v< dtype >, int > = 0, std::enable_if_t< all_arithmetic_v< Params... >, int > = 0, std::enable_if_t< all_same_v< dtype, Params... >, int > = 0> | |
std::pair< NdArray< double >, double > | gaussNewtonNlls (const uint32 numIterations, const NdArray< dtype > &coordinates, const NdArray< dtype > &measurements, const std::function< dtype(const NdArray< dtype > &, const NdArray< dtype > &)> &function, const std::array< std::function< dtype(const NdArray< dtype > &, const NdArray< dtype > &)>, sizeof...(Params)> &derivatives, Params... initialGuess) |
template<typename dtype > | |
NdArray< dtype > | hat (const NdArray< dtype > &inVec) |
NdArray< double > | hat (const Vec3 &inVec) |
template<typename dtype > | |
NdArray< dtype > | hat (dtype inX, dtype inY, dtype inZ) |
template<typename dtype > | |
NdArray< double > | inv (const NdArray< dtype > &inArray) |
template<typename dtype > | |
NdArray< double > | lstsq (const NdArray< dtype > &inA, const NdArray< dtype > &inB, double inTolerance=1e-12) |
template<typename dtype > | |
std::pair< NdArray< double >, NdArray< double > > | lu_decomposition (const NdArray< dtype > &inMatrix) |
template<typename dtype > | |
NdArray< double > | matrix_power (const NdArray< dtype > &inArray, int16 inPower) |
template<typename dtype > | |
NdArray< dtype > | multi_dot (const std::initializer_list< NdArray< dtype > > &inList) |
template<typename dtype > | |
NdArray< double > | pinv (const NdArray< dtype > &inArray) |
template<typename dtype > | |
std::tuple< NdArray< double >, NdArray< double >, NdArray< double > > | pivotLU_decomposition (const NdArray< dtype > &inMatrix) |
template<typename dtype > | |
NdArray< double > | solve (const NdArray< dtype > &inA, const NdArray< dtype > &inB) |
template<typename dtype > | |
void | svd (const NdArray< dtype > &inArray, NdArray< double > &outU, NdArray< double > &outS, NdArray< double > &outVt) |
NdArray< double > nc::linalg::cholesky | ( | const NdArray< dtype > & | inMatrix | ) |
matrix cholesky decomposition A = L * L.transpose()
NumPy Reference: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.cholesky.html#numpy.linalg.cholesky
inMatrix | NdArray to be decomposed |
auto nc::linalg::det | ( | const NdArray< dtype > & | inArray | ) |
matrix determinant. NOTE: can get verrrrry slow for large matrices (order > 10)
SciPy Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.det.html#scipy.linalg.det
inArray |
std::pair< NdArray< double >, double > nc::linalg::gaussNewtonNlls | ( | const uint32 | numIterations, |
const NdArray< dtype > & | coordinates, | ||
const NdArray< dtype > & | measurements, | ||
const std::function< dtype(const NdArray< dtype > &, const NdArray< dtype > &)> & | function, | ||
const std::array< std::function< dtype(const NdArray< dtype > &, const NdArray< dtype > &)> | , | ||
sizeof... | Params, | ||
& | derivatives, | ||
Params... | initialGuess | ||
) |
The Gauss�Newton algorithm is used to solve non-linear least squares problems. It is a modification of Newton's method for finding a minimum of a function. https://en.wikipedia.org/wiki/Gauss%E2%80%93Newton_algorithm
numIterations | the number of iterations to perform |
coordinates | the coordinate values. The shape needs to be [n x d], where d is the number of diminsions of the fit function (f(x) is one dimensional, f(x, y) is two dimensions, etc), and n is the number of observations that are being fit to. |
measurements | the measured values that are being fit |
function | a std::function of the function that is being fit. The function takes as inputs an NdArray of a single set of the coordinate values, and an NdArray of the current values of the fit parameters |
derivatives | array of std::functions to calculate the function derivatives. The function that is being fit. The function takes as inputs an NdArray of a single set of the coordinate values, and an NdArray of the current values of the fit parameters |
initialGuess | the initial guess of the parameters to be solved for |
NdArray< dtype > nc::linalg::hat | ( | dtype | inX, |
dtype | inY, | ||
dtype | inZ | ||
) |
matrix inverse
SciPy Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.inv.html#scipy.linalg.inv
inArray |
NdArray< double > nc::linalg::lstsq | ( | const NdArray< dtype > & | inA, |
const NdArray< dtype > & | inB, | ||
double | inTolerance = 1e-12 |
||
) |
Solves the equation a x = b by computing a vector x that minimizes the Euclidean 2-norm || b - a x ||^2. The equation may be under-, well-, or over- determined (i.e., the number of linearly independent rows of a can be less than, equal to, or greater than its number of linearly independent columns). If a is square and of full rank, then x (but for round-off error) is the "exact" solution of the equation.
SciPy Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.lstsq.html#scipy.linalg.lstsq
inA | coefficient matrix |
inB | Ordinate or "dependent variable" values |
inTolerance | (default 1e-12) |
std::pair< NdArray< double >, NdArray< double > > nc::linalg::lu_decomposition | ( | const NdArray< dtype > & | inMatrix | ) |
matrix LU decomposition A = LU
inMatrix | NdArray to be decomposed |
NdArray< double > nc::linalg::matrix_power | ( | const NdArray< dtype > & | inArray, |
int16 | inPower | ||
) |
Raise a square matrix to the (integer) power n.
For positive integers n, the power is computed by repeated matrix squarings and matrix multiplications. If n == 0, the identity matrix of the same shape as M is returned. If n < 0, the inverse is computed and then raised to the abs(n).
NumPy Reference: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.matrix_power.html#numpy.linalg.matrix_power
inArray | |
inPower |
NdArray< dtype > nc::linalg::multi_dot | ( | const std::initializer_list< NdArray< dtype > > & | inList | ) |
Compute the dot product of two or more arrays in a single function call.
NumPy Reference: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.multi_dot.html#numpy.linalg.multi_dot
inList | list of arrays |
matrix psuedo-inverse
NumPy Reference: https://numpy.org/doc/stable/reference/generated/numpy.linalg.pinv.html
inArray |
std::tuple< NdArray< double >, NdArray< double >, NdArray< double > > nc::linalg::pivotLU_decomposition | ( | const NdArray< dtype > & | inMatrix | ) |
matrix pivot LU decomposition PA = LU
inMatrix | NdArray to be decomposed |
NdArray< double > nc::linalg::solve | ( | const NdArray< dtype > & | inA, |
const NdArray< dtype > & | inB | ||
) |
Solve a linear matrix equation, or system of linear scalar equations. Computes the “exact” solution, x, of the well-determined, i.e., full rank, linear matrix equation ax = b.
https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html
inA | |
inB |
void nc::linalg::svd | ( | const NdArray< dtype > & | inArray, |
NdArray< double > & | outU, | ||
NdArray< double > & | outS, | ||
NdArray< double > & | outVt | ||
) |
matrix svd
NumPy Reference: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.svd.html#numpy.linalg.svd
inArray | NdArray to be SVDed |
outU | NdArray output U |
outS | NdArray output S |
outVt | NdArray output V transpose |