Qu

svd

Builtin index · Core maths

result = svd(A)

Input: A · Output: result

What it is

Thin SVD of A (r×c Mat or CMat), A = U·diag(s)·Vᵀ.

Overloads

A can be Mat or CMat.

2 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.

CodeInputOutputDescription
result = svd(A)
A Matnot documented yet
u Matr×k Mat
s Veclength-k Vec of singular values
vt Matk×c Mat
Returns a Model with fields u (r×k Mat), s (length-k Vec of singular values), and vt (k×c Mat), where k = min(r,c) — the full factorization, ready to reassemble A.

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

A = [4, 1; 1, 3]
r = svd(A)
print(r.s)   # [4.618034, 2.381966]

output
[4.618034, 2.381966]
CodeInputOutputDescription
result = svd(A)
A CMatnot documented yet
values —the singular values
Returns a *differently-shaped* Model — only values (the singular values), condition, and rank; there is no u/vt factor pair to reassemble A from in this branch.

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

C = [1 + 1j, 2; 3, 4 - 1j]
rc = svd(C)
print("values={rc.values}  condition={round(rc.condition, 3)}  rank={rc.rank}")
output
values=[5.628889, 0.561794]  condition=10.019  rank=2

How it works

svd(A) — the thin SVD A = U * diag(s) * V^T. Model kind "svd", fields u/s/vt — the same named-field multi-return convention as kalman_init/ols_model, since the three factors are one related result.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.