[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange problem
From: |
Geraint Paul Bevan |
Subject: |
Re: strange problem |
Date: |
Fri, 28 Nov 2003 08:52:15 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mike Miller wrote:
| On Fri, 28 Nov 2003, Christoph Dalitz wrote:
|
|>Is there an Octave function that truncates/rounds such small numbers to
|>zero (like the Scilab function "clean")?
|
| Why not use 'round' but first multiply by a large number, then divide by
| that same number after round. For example:
|
| octave:1> x=-2.0817e-17
| x = -2.0817e-17
| octave:2> round(x*1e+15)/1e+15
| ans = 0
|
| You could write a function that performs that operation on matrices.
|
Element-wise multiplication by (abs(x)>eps) works for matrices:
octave:1> a = [ 1 , 100 ; 0 , 1 ] * [ 1 , 0 ; -1/100 , 1 ];
octave:2> a = a .* (abs(a) > eps)
a =
~ -0.00000 100.00000
~ -0.01000 1.00000
- --
Geraint Bevan
http://homepage.ntlworld.com/geraint.bevan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAj/HDL0ACgkQcXV3N50QmNOgRACggq37hu/vfvVPb1aIhYls14gT
dSYAnRBhQdT65U19XK7+sZH/eK8HGPZ7
=MZtp
-----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
-------------------------------------------------------------
Message not available
strange problem, John W. Eaton, 2003/11/28