1
function [x,dim,dima]=spanplus(a,b,tol)
2
//[X,dim,dima]=spanplus(A,B,tol) computes an orthogonal basis of
3
// a+b such that : the first dima columns of x span Range(A)
4
// and the following (dim-dima) columns make a basis of a+b
5
// relative to a. tol is an optional argument.
6
// The dim first columns of x make a basis for A+B.
10
[na,ma]=size(a);[nb,mb]=size(b);
11
if na*ma==0 then [x,dima]=rowcomp(b);dim=dima;x=x';return;end
12
if nb*mb==0 then [x,dima]=rowcomp(a);dim=dima;x=x';return;end
14
if rhs==2 then tol=%eps*na*nb*ma*mb;end
15
if na<>nb then error('uncompatible dimensions!'),end
17
b=x*b;x=x' //update b,x
18
if dima == na then dim=dima,return,end;
21
if norm(blow,1) <= tol*norm(b,1),dim=dima,return,end
22
[u2,r2]=rowcomp(blow);
24
x(:,low)=x(:,low)*u2'; //update