Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
svd.h File Reference

Singular value decomposition helper shared by chart and color-math code. More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+ Include dependency graph for svd.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static double SIGN (double a, double b)
 
static double PYTHAG (double a, double b)
 
static int dsvd (double *a, int m, int n, int str, double *w, double *v)
 Compute the singular value decomposition of a dense matrix.
 

Detailed Description

Singular value decomposition helper shared by chart and color-math code.

This routine computes the SVD of a dense matrix stored row-major with an explicit row stride. It is adapted from the svdecomp.c implementation that shipped with XLISP-STAT 2.1, itself credited to Luke Tierney and David Betz.

Function Documentation

◆ dsvd()

static int dsvd ( double a,
int  m,
int  n,
int  str,
double w,
double v 
)
inlinestatic

Compute the singular value decomposition of a dense matrix.

The input matrix is overwritten by the left singular vectors. The right singular vectors are stored in v and the singular values are stored in w. The function assumes m >= n and returns zero if the problem is malformed or the QR iteration does not converge.

Parameters
[in,out]aInput matrix overwritten with the left singular vectors.
[in]mNumber of rows of a.
[in]nNumber of columns of a.
[in]strRow stride of a.
[out]wSingular values, length n.
[out]vRight singular vectors stored as an n x n row-major matrix.
Returns
1 on success, 0 on failure.

References dt_free, f, flag, g, i, k, m, MAX, n, PYTHAG(), SIGN(), v, and x.

Referenced by solve().

◆ PYTHAG()

static double PYTHAG ( double  a,
double  b 
)
inlinestatic

Referenced by dsvd().

◆ SIGN()

static double SIGN ( double  a,
double  b 
)
inlinestatic

Referenced by dsvd().