MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
svd.hpp File Reference
#include <cmath>
#include <algorithm>
#include <cassert>
#include <type_traits>
#include <utility>
#include <vector>
#include <limits>
#include <stdexcept>
#include <string>
#include <mtl/concepts/matrix.hpp>
#include <mtl/detail/matrix_checks.hpp>
#include <mtl/vec/dense_vector.hpp>
#include <mtl/mat/dense2D.hpp>
#include <mtl/operation/qr.hpp>
#include <mtl/operation/householder.hpp>
#include <mtl/operation/trans.hpp>
#include <mtl/math/identity.hpp>
#include <mtl/math/accumulator_traits.hpp>
#include <mtl/interface/dispatch_traits.hpp>

Namespaces

namespace  mtl
namespace  mtl::detail
 mat*vec multiply into pre-allocated y: y = A * x.

Functions

template<typename Accumulator, typename value_type, typename Size, typename Term>
value_type mtl::detail::svd_dot (Size len, Term term)
 sum_i a(i) * b(i) for i < len, where term(i) returns {a(i), b(i)}: a plain value_type sum for void, else one accumulator rounded once.
template<typename Accumulator, typename value_type, typename Size, typename Load>
void mtl::detail::svd_pair_sums (Size len, Load load, value_type &alpha, value_type &betac, value_type &gamma)
 alpha = ||p||^2, betac = ||q||^2, gamma = p .
template<typename Accumulator = void, typename value_type>
void mtl::detail::one_sided_jacobi (mat::dense2D< value_type > &B, mat::dense2D< value_type > &V, std::vector< value_type > &sigma_s, value_type tol)
 One-sided Jacobi core shared by every svd overload.
template<typename Accumulator = void, typename value_type>
void mtl::detail::complete_orthonormal (mat::dense2D< value_type > &U, typename mat::dense2D< value_type >::size_type filled)
 Completes the columns [filled, ncol) of U (m x ncol, m >= ncol) to an orthonormal set, given that columns [0, filled) are already orthonormal.
template<typename Accumulator = void, FieldMatrix M>
void mtl::svd (const M &A, mat::dense2D< typename M::value_type > &U, mat::dense2D< typename M::value_type > &S, mat::dense2D< typename M::value_type > &V, typename M::value_type tol=std::numeric_limits< typename M::value_type >::epsilon())
 SVD: decompose A (m x n) = U * S * V^T U is m x m orthogonal, S is m x n diagonal (stored as m x n matrix), V is n x n orthogonal.
template<typename Accumulator = void, FieldMatrix M>
void mtl::svd (const M &A, vec::dense_vector< typename M::value_type > &s, mat::dense2D< typename M::value_type > &V, typename M::value_type tol=std::numeric_limits< typename M::value_type >::epsilon())
 SVD without U: the singular values s (length min(m,n), descending) and the n x n right singular vectors V, so that A * V(:,j) = s(j) * u_j for some unit u_j that is never formed (#566).
template<typename Accumulator = void, FieldMatrix M>
void mtl::svd (const M &A, mat::dense2D< typename M::value_type > &U, vec::dense_vector< typename M::value_type > &s, mat::dense2D< typename M::value_type > &V, typename M::value_type tol=std::numeric_limits< typename M::value_type >::epsilon())
 Thin SVD: A (m x n) = U * diag(s) * V^T with k = min(m, n), U m x k and V n x k, both with orthonormal columns, and s (length k) descending.
template<typename Accumulator = void, FieldMatrix M>
vec::dense_vector< typename M::value_type > mtl::null_vector (const M &A, typename M::value_type tol=std::numeric_limits< typename M::value_type >::epsilon())
 A unit vector x minimizing ||A x||: the right singular vector of A's smallest singular value, i.e.
template<typename Accumulator = void, FieldMatrix M>
auto mtl::svd (const M &A, typename M::value_type tol=std::numeric_limits< typename M::value_type >::epsilon())
 Convenience overload returning a tuple of (U, S, V).