svd2 {sanic}R Documentation

Singular Value Decomposition

Description

Solvers for generalized eigenproblems around the matrix A. Compute singular values \Sigma, left singular vectors U and right singular vectors V of A, such that A = U \Sigma V^*. Two different types are available: (1) bidiagonal divide and conquer strategy (BDC) SVD, and (2) two-sided Jacobi SVD for small matrices (<16) and high accuracy.

Usage

svd2(a, type = c("BDC", "Jacobi"), vectors = TRUE, thin = TRUE)

Arguments

a

Numeric matrix.

type

Character scalar. Whether to use BDC or Jacobi SVD.

vectors

Logical scalar indicating whether singular vectors should be computed and returned.

thin

Logical scalar indicating whether singular vectors should be returned in thinned or full format.

Value

Solves the generalised eigenproblem and returns a list with singular values in the "d" component and, if requested, singular vectors in the components "u" and "v".

Examples

set.seed(42)
# Compute singular values and vectors using BDC
A <- matrix(rnorm(9), nrow = 3, ncol = 3)
sv <- svd2(A)

# Compute singular values using Jacobi
A <- matrix(rnorm(9), nrow = 3, ncol = 3)
sv <- svd2(A, type = "J", vectors = FALSE)

# Compute singular values and full vectors using BDC
A <- matrix(rnorm(12), nrow = 4, ncol = 3)
sv <- svd2(A, type = "B", thin = FALSE)
A <- matrix(rnorm(12), nrow = 3, ncol = 4)
sv <- svd2(A, type = "B", thin = FALSE)


[Package sanic version 0.0.2 Index]