help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: strange problem


From: Thomas Shores
Subject: RE: strange problem
Date: 28 Nov 2003 19:35:16 -0600

If one is only cleaning a final product, clean() is a good idea. If,
however, one is at an intermediate stage, there might be problems.
Consider, for example,


octave:10> function
xout=clean(xin,prec);xout=xin*(abs(xin>prec));endfunction
octave:11> A=1e-16*eye(2);inv(A)
ans =

   1.0000e+16  -0.0000e+00
   0.0000e+00   1.0000e+16

octave:12> B=clean(A,eps);inv(B)
warning: inverse: matrix singular to machine precision, rcond = 0
ans =

  0  0
  0  0


The point is that error is a relative matter. So I suggest a slight
modification:

octave:13> function
xout=clean(xin,prec);relprec=prec*norm(xin,inf);xout=xin*(abs(xin>relprec));endfunction
octave:14> B=clean(A,eps);inv(B)
ans =

   1.0000e+16  -0.0000e+00
   0.0000e+00   1.0000e+16


Tom Shores



On Fri, 2003-11-28 at 05:39, THOMAS Paul Richard wrote:
> Gerald,
> 
> I am glad that the function did it for you.  As several of the respondents
> said, this is a result of limitations in floating point arithmetic.
> 
> Not only is the response time of this list good but you should check out the
> times of the replies and the locations of some of our friends on this list.
> I sort of wonder if they have homes to go to?
> 
> Paul
> 
> -----Message d'origine-----
> De : Gerald Ebberink [mailto:address@hidden
> Envoyé : vendredi 28 novembre 2003 11:39
> À : address@hidden
> Objet : Re: strange problem
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Problem solved,
> thnx all
> 
> since I don't work under windows the function gives me a nice way of
> cleaning th results after each multiplication.
> 
> by the way, this list has a very low response time. Other programs have
> far worse lists.
> 
> THOMAS Paul Richard wrote:
> | Dear All,
> |
> | The matrix multiplication gives zero for ans(1,1) in octave 2.1.49 (under
> | Cygwin)!  However, Matlab5 gives the same result as Gerald's.
> |
> | Compiling the expression 1-(100*-1)/100 in g++ or intel C++ give 0.  I
> would
> | conclude that this is some peculiarity of BLAS that seems to have been
> | eliminated in later versions of Octave/BLAS.
> |
> | It seems to me that Gerald's work-around might be to use
> |
> | function xout=clean(xin,prec);xout=xin.*(abs(xin)>prec);endfunction;
> |
> | so that
> |
> | a=clean([1,100;0,1]*[1,0;(-1/100),1],1E-16);
> |
> | a(1,1) yields 0
> |
> | Paul
> |
> | ---
> | Outgoing mail is certified Virus Free.
> | Checked by AVG anti-virus system (http://www.grisoft.com).
> | Version: 6.0.536 / Virus Database: 331 - Release Date: 03/11/03
> |
> |
> |
> |
> | -------------------------------------------------------------
> | Octave is freely available under the terms of the GNU GPL.
> |
> | Octave's home on the web:  http://www.octave.org
> | How to fund new projects:  http://www.octave.org/funding.html
> | Subscription information:  http://www.octave.org/archive.html
> | -------------------------------------------------------------
> |
> 
> 
> - --
> Ing. Gerald Ebberink
> Laser Technician
> 
> Kernfysisch Versneller Instituut
> Rijksuniversiteit Groningen
> Zernikelaan 25
> 9747 AA Groningen
> The Netherlands
> tel: +31 50 363 3518
> lab: +31 50 363 3588
> fax: +31 50 363 4003
> 
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQE/xyXdbSbfYz8yWIMRAkSgAJ0T93dwzwCxxbd+mbbZDZ4ozo+UlQCdFZsg
> Cui81rFrM+PQo87RnSSvMCA=
> =U9e8
> -----END PGP SIGNATURE-----
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.536 / Virus Database: 331 - Release Date: 03/11/03
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.536 / Virus Database: 331 - Release Date: 03/11/03
>  
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
-- 
Thomas Shores <address@hidden>
Department of Mathematics, UNL



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]