~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/algebre/spanplus.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
7
//F.D.
 
8
//!
 
9
// Copyright INRIA
 
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
 
13
[lhs,rhs]=argn(0);
 
14
if rhs==2 then tol=%eps*na*nb*ma*mb;end
 
15
if na<>nb then error('uncompatible dimensions!'),end
 
16
[x,dima]=rowcomp(a);
 
17
b=x*b;x=x'    //update b,x
 
18
if dima == na then dim=dima,return,end;
 
19
low=(dima+1):na;
 
20
blow=b(low,:);
 
21
if norm(blow,1) <= tol*norm(b,1),dim=dima,return,end
 
22
[u2,r2]=rowcomp(blow);
 
23
dim=dima+r2;
 
24
x(:,low)=x(:,low)*u2';    //update
 
25
 
 
26
 
 
27