[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: equivalent of Scilab 'colcomp' for Octave ?
From: |
Sergei Steshenko |
Subject: |
Re: equivalent of Scilab 'colcomp' for Octave ? |
Date: |
Fri, 29 Jul 2011 20:11:34 -0700 (PDT) |
--- On Fri, 7/29/11, Sergei Steshenko <address@hidden> wrote:
> From: Sergei Steshenko <address@hidden>
> Subject: equivalent of Scilab 'colcomp' for Octave ?
> To: address@hidden
> Date: Friday, July 29, 2011, 7:57 PM
> Hello,
>
> I need to convert a number of Scilab functions to Octave,
> and one of the
> functions uses 'colcomp':
>
> http://help.scilab.org/docs/5.3.2/en_US/colcomp.html
> .
>
> Is there an equivalent function for Octave ?
>
> I've done some web search using
>
> +GNU +Octave +column +compression +matrix
>
> keywords; I understand that the function is related to
> factorization; my
> knowledge of linear algebra is too rusty to be able to
> quickly figure
> out by myself what Octave functions to use,
>
> Probably I'll need functions from
>
> http://www.gnu.org/software/octave/doc/interpreter/Matrix-Factorizations.html
> .
>
> Thanks,
> Sergei.
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
Replying to myself - I've found 'colcomp' source:
"
cat -n scilab-5.3.3/modules/linear_algebra/macros/colcomp.sci
1
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) ????-2008 - INRIA - François DELEBECQUE
4 //
5 // This file must be used under the terms of the CeCILL.
6 // This source file is licensed as described in the file COPYING, which
7 // you should have received as part of this distribution. The terms
8 // are also available at
9 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10
11 function [w,rk]=colcomp(a,flag,tol)
12 //Syntaxes : [w,rk]=colcomp(a)
13 // [w,rk]=colcomp(a,flag)
14 // [w,rk]=colcomp(a,flag,tol)
15 //
16 //column compression of a i.e. comput. of ker(a)
17 //flag and tol are optional parameters
18 //flag='qr' or 'svd' (defaut 'svd')
19 //tol tolerance parameter (of order %eps as defaut value)
20 //the ma-rk first columns of w span the kernel of a when size(a)=(na,ma)
21
22 [ma,na]=size(a)
23 [lhs,rhs]=argn(0)
24 if a==[] then w=[];rk=0;return;end
25 if norm(a,1) < sqrt(%eps)/10 then rk=0,w=eye(na,na),return,end
26 if rhs ==2 then tol=sqrt(%eps)*norm(a,1)*max(ma,na),end
27 if rhs==1 then flag='svd',tol=sqrt(%eps)*norm(a,1)*max(ma,na);end
28 select flag
29 case 'qr' then [q,r,rk,e]=qr(a',tol);
30 //w=[q(:,rk+1:ma),q(:,1:rk)]; <-- le ma me parait suspect je met na
31 w=q(:,na:-1:1)
32 case 'svd' then [u,s,v,rk]=svd(a',tol);
33 //w=[u(:,rk+1:na),u(:,1:rk)];
34 w=u(:,na:-1:1)
35 end
36 endfunction
".
As one can see, 'qr' or 'svd' are used:
[q,r,rk,e]=qr(a',tol);
[u,s,v,rk]=svd(a',tol);
- on both cases 'tol' (tolerance - if I understand correctly) is used.
Octave also has 'qr' and 'svd', but their interface is different, i.e.
both number of return items is different and there is no 'tol'.
Any ideas how to bridge these differences ?
Thanks,
Sergei.