slvblk
Solve almost block-diagonal linear system
Syntax
x = slvblk(blokmat,b)
x = slvblk(blockmat,b,w)
Description
x = slvblk(blokmat,b)
returns the solution (if any) of the linear system Ax = b
, with the matrix A
stored in blokmat
in the spline almost block-diagonal form. At present, only the command spcol
provides such a description, of the matrix whose typical entry is the value of some derivative (including the 0th derivative, i.e., the value) of a B-spline at some site. If the linear system is overdetermined (i.e., has more equations than unknowns but is of full rank), then the least-squares solution is returned.
The right side b
may contain several columns, and is expected to contain as many rows as there are rows in the matrix described by blokmat
.
x = slvblk(blockmat,b,w)
returns the vector x
that minimizes the weighted sum Σjw(j)((Ax – b)(j))2.
Examples
sp=spmak(knots,slvblk(spcol(knots,k,x,1),y.'))
provides in sp
the B-form of the spline s of order k
with knot sequence knots
that matches the given data (x,y)
, i.e., for which s(x)
equals y
.
Algorithms
The command bkbrk
is used to obtain the essential parts of the coefficient matrix described by blokmat
(in one of two available forms).
A QR factorization is made of each diagonal block, after it was augmented by the equations not dealt with when factoring the preceding block. The resulting factorization is then used to solve the linear system by back substitution.