ocmath_ex_svbksb

 

Contents

Description

Solves linear system using singular value backsubstitution.

Syntax

int ocmath_ex_svbksb( double ** ppu, double * pw, double ** ppv, int m, int n, double * pb, double * px )

Parameters

ppu
[input]the pointer to the m by n matrix U in the standard "pointer-to-rows" form,
obtained by singular value decomposition from the LHS of a linear system.
pw
[input]the pointer to the vector W of size n,
obtained by singular value decomposition from the LHS of a linear system.
ppv
[input]the pointer to the n by n matrix V in the standard "pointer-to-rows" form,
obtained by singular value decomposition from the LHS of a linear system.
m
[input]number of rows in the original matrix
n
[input]number of columns in the original matrix.
pb
[input]pointer to a vector of size m holding the RHS of the linear system.
px
[output]pointer to a vector of size n which will on return receive the solution.

Return

Returns 0 if OK, 1 if any error, for example, the values of the vector W

are so small (by absolute value) that they cannot be divided with.

Examples

EX1

void ocmath_ex_svbksb_ex1()
{
    double dArray1[4]={2,3,5,7};
    double dArray2[4]={11,13,17,19};
    double dArray3[4]={23,29,31,37};
    double *dArrayTest1[3];
    int m = 3;
    int n = 4;
    dArrayTest1[0]= dArray1;
    dArrayTest1[1]= dArray2;
    dArrayTest1[2]= dArray3;
    double dArray4[4]={2,3,5,7};
    double dArray5[4]={11,13,17,19};
    double dArray6[4]={23,29,31,37};
    double dArray7[4]={41,43,47,49};
    double *dArrayTest2[4];
        dArrayTest2[0]=dArray4;
        dArrayTest2[1]=dArray5;
        dArrayTest2[2]=dArray6;
        dArrayTest2[3]=dArray7;
    vector vW={1,2,3,4};
    vector vb={1,2,3};
    vector vx;
    vx.SetSize(n);
    int iRet = ocmath_ex_svbksb(dArrayTest1,vW,dArrayTest2,m,n,vb,vx);
}

Remark

See Also

header to Include

origin.h

Reference