My Project

Perform Singular Value Decomposition. More...

Functions

AFAPI void svd (array &u, array &s, array &vt, const array &in)
 C++ Interface for SVD decomposition.
 
AFAPI void svdInPlace (array &u, array &s, array &vt, array &in)
 C++ Interface for SVD decomposition.
 
AFAPI af_err af_svd (af_array *u, af_array *s, af_array *vt, const af_array in)
 C Interface for SVD decomposition.
 
AFAPI af_err af_svd_inplace (af_array *u, af_array *s, af_array *vt, af_array in)
 C Interface for SVD decomposition.
 

Detailed Description

Perform Singular Value Decomposition.

This function factorizes a matrix A into two unitary matrices U and Vt, and a diagonal matrix S such that

 \f$A = U * S * Vt\f$

If A has M rows and N columns, U is of the size M x M , V is of size N x N, and S is of size M x N

The arrayfire function only returns the non zero diagonal elements of S. To reconstruct the original matrix A from the individual factors, the following code snuppet can be used:

af::array U, S, Vt;
af::svd(U, S, Vt, A);
const int MN = std::min(M, N);
af::array UU = U(af::span, af::seq(MN));
af::array SS = af::diag(S, 0, false).as(ty);
af::array VV = Vt(af::seq(MN), af::span);
af::array AA = matmul(UU, SS, VV);
A multi dimensional data container.
Definition array.h:27
seq is used to create seq for indexing af::array
Definition seq.h:46
AFAPI array diag(const array &in, const int num=0, const bool extract=true)
AFAPI void svd(array &u, array &s, array &vt, const array &in)
C++ Interface for SVD decomposition.
const array as(dtype type) const
Converts the array into another type.
AFAPI seq span

When memory is a concern, and A is dispensible, svdInPlace() can be used


Function Documentation

◆ af_svd()

AFAPI af_err af_svd ( af_array u,
af_array s,
af_array vt,
const af_array  in 
)

C Interface for SVD decomposition.

Parameters
[out]uis the output array containing U
[out]sis the output array containing the diagonal values of sigma, (singular values of the input matrix))
[out]vtis the output array containing V^H
[in]inis the input matrix

◆ af_svd_inplace()

AFAPI af_err af_svd_inplace ( af_array u,
af_array s,
af_array vt,
af_array  in 
)

C Interface for SVD decomposition.

Parameters
[out]uis the output array containing U
[out]sis the output array containing the diagonal values of sigma, (singular values of the input matrix))
[out]vtis the output array containing V^H
[in,out]inis the input matrix that will contain random data after this operation

◆ svd()

AFAPI void svd ( array u,
array s,
array vt,
const array in 
)

C++ Interface for SVD decomposition.

Parameters
[out]uis the output array containing U
[out]sis the output array containing the diagonal values of sigma, (singular values of the input matrix))
[out]vtis the output array containing V^H
[in]inis the input matrix

◆ svdInPlace()

AFAPI void svdInPlace ( array u,
array s,
array vt,
array in 
)

C++ Interface for SVD decomposition.

Parameters
[out]uis the output array containing U
[out]sis the output array containing the diagonal values of sigma, (singular values of the input matrix))
[out]vtis the output array containing V^H
[in,out]inis the input matrix and will contain random data after this operation