File: spanplus.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (27 lines) | stat: -rw-r--r-- 871 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [x,dim,dima]=spanplus(a,b,tol)
//[X,dim,dima]=spanplus(A,B,tol) computes an orthogonal basis of
// a+b such that : the first dima columns of x span Range(A)
// and the following (dim-dima) columns make a basis of a+b
// relative to a. tol is an optional argument.
// The dim first columns of x make a basis for A+B.
//F.D.
//!
// Copyright INRIA
[na,ma]=size(a);[nb,mb]=size(b);
if na*ma==0 then [x,dima]=rowcomp(b);dim=dima;x=x';return;end
if nb*mb==0 then [x,dima]=rowcomp(a);dim=dima;x=x';return;end
[lhs,rhs]=argn(0);
if rhs==2 then tol=%eps*na*nb*ma*mb;end
if na<>nb then error('uncompatible dimensions!'),end
[x,dima]=rowcomp(a);
b=x*b;x=x'    //update b,x
if dima == na then dim=dima,return,end;
low=(dima+1):na;
blow=b(low,:);
if norm(blow,1) <= tol*norm(b,1),dim=dima,return,end
[u2,r2]=rowcomp(blow);
dim=dima+r2;
x(:,low)=x(:,low)*u2';    //update