[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange problem
From: |
pkienzle |
Subject: |
Re: strange problem |
Date: |
Sat, 29 Nov 2003 05:43:42 +0000 |
In standard octave, you cannot overload any functions. You
can replace m-file and oct-functions with your own implementation
but you can't overload them for a specific type. You cannot
replace builtin functions without writing an oct-file routine to
excise the builtin from the function table. I haven't done it yet,
but such a facility would be useful for running octave as a CGI
script --- strip all the OS functions like fopen, load, save, cd,
ls, pwd, system, fork, getpid, etc.
With octave-forge, you can write dispatch("fn","t_fn","t"), which
says call t_fn instead of fn when the first argument is of type
"t". This works for m-files, oct-files and builtins.
Paul Kienzle
address@hidden
> I believe you can only overload user-defined ( read as: M-file
> functions ) functions. I'm not sure about OCT-file functions. And I
> can confidently say that you are not able to overload built-in
> functions.
>
> ~Tomer
>
>
> On Nov 28, 2003 at 10:00am, Christoph Dalitz wrote:
>
> christ >Date: Fri, 28 Nov 2003 10:00:36 +0100
> christ >From: Christoph Dalitz <address@hidden>
> christ >To: Mike Miller <address@hidden>
> christ >Cc: Octave Mailing List <address@hidden>
> christ >Subject: Re: strange problem
> christ >Resent-Date: Fri, 28 Nov 2003 03:03:09 -0600
> christ >Resent-From: address@hidden
> christ >
> christ >On Fri, 28 Nov 2003 02:34:07 -0600 (CST)
> christ >Mike Miller <address@hidden> wrote:
> christ >>
> christ >> > > The number -2.0817e-17 is -0.000000000000000020817, which is
> very,
> very
> christ >> > > close to zero.
> christ >> >
> christ >> > Is there an Octave function that truncates/rounds such small
> numbers
> to
> christ >> > zero (like the Scilab function "clean")?
> christ >> >
> christ >> > I have tried "help round" and "help trunc", but found nothing
> christ >> > appropriate.
> christ >>
> christ >> Why not use 'round' but first multiply by a large number, then
> divide
> by
> christ >> that same number after round.
> christ >>
> christ >For some strange reason I believed that there was no "round" function
> because
> christ >it is not documented ("help round" gives "help: sorry, `round' is not
> documented").
> christ >
> christ >> You could write a function that performs that operation on matrices.
> christ >>
> christ >Tried this with:
> christ >
> christ > function y = round(x,n)
> christ > y = round(x*10^n)/10^n;
> christ > endfunction
> christ >
> christ >It seems however that Octave does not support function overloading,
> because
> christ >I obtain the error
> christ >
> christ > octave:3> round(5.4,0)
> christ > error: round: too many arguments
> christ >
> christ >I am using Octave 2.1.35. Is function overloading supported in some
> later version?
> christ >
> christ >Thanks,
> christ >
> christ >Christoph
> christ >
> christ >
> christ >
> christ >-------------------------------------------------------------
> christ >Octave is freely available under the terms of the GNU GPL.
> christ >
> christ >Octave's home on the web: http://www.octave.org
> christ >How to fund new projects: http://www.octave.org/funding.html
> christ >Subscription information: http://www.octave.org/archive.html
> christ >-------------------------------------------------------------
> christ >
> christ >
>
>
>
> -------------------------------------------------------------
> 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
> -------------------------------------------------------------
>
-------------------------------------------------------------
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
-------------------------------------------------------------
- Re: strange problem, (continued)
strange problem, John W. Eaton, 2003/11/28
RE: strange problem, THOMAS Paul Richard, 2003/11/28
RE: strange problem, THOMAS Paul Richard, 2003/11/28
Re: strange problem,
pkienzle <=