help-octave
[Top][All Lists]
Advanced

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

Re: How to program a new type


From: Paul Kienzle
Subject: Re: How to program a new type
Date: Wed, 13 Nov 2002 14:33:14 -0500
User-agent: Mutt/1.2.5.1i

It should be possible for you to define a new octave type which mostly
mimics matlab's objects without changing any octave internals.  Instead of
implementing basic operations, the type should translate operators into
calls to feval on the appropriate function.  

As it stands, octave doesn't support the class directory business, so you
will instead have to do something like call the operators classMop and
paste the name of the class to the name of the operator before calling
feval.

To override builtin functions for a class requires different magic.  At one
point I wrote and had mostly working a dispatch command whereby you could
register an internal function (e.g., classMsum) by an external name (sum)
if the first parameter to that function was of a certain type.  This will
need to be reworked for octave 2.1.39.

Paul Kienzle
address@hidden

On Wed, Nov 13, 2002 at 10:36:59AM -0800, withaar wrote:
> Thank you for the suggestions, I will certainly study them.
> 
> I was thinking of making a generic type that can be created with
> a command like:
> 
> afoo.num = [1 0 0 3] ;
> afoo.den = [1 2 -2 -2 1] ;
> afoo = class(afoo,'sys') ;
> 
> When I want to make a bode plot of such a system, I
> migh want to specify a special function in
> 
> @sys/bode.m
> 
> which will be called with:
> 
> bode(sys)
> 
> This means that the method of object sys will be called
> before the general version. Besides creating a generic type
> with a custom type-name, it also needs a change in the
> script execution mechanism in that the @sys/ path should
> be scanned before other paths for a script to execute.
> That _seems_ like a fairly uncomplicated modification, but
> I have not familiarized myself with the code yet. I tought
> I would start with seeing how easy it would be to do a 
> generic type.
> 
> 
> On Tue, 12 Nov 2002 21:34:35 -0500 (EST), "Andy Adler"
> <address@hidden> said:
> > Two suggestions:
> > 
> > 1. Look at examples/make_int.cc in the octave source.
> > 2. Look at main/sparse/*.cc in octave-forge
> > 
> > octave has great support for new types.
> > What are you planning to do?
> > 
> > Andy
> > --
> > Andy Adler,
> > Assistant Professor, School of Information Technology and Engineering,
> > University of Ottawa, Tel:1(613)562-5800 X 2345,
> > Email:address@hidden
> 
> 
> 
> -------------------------------------------------------------
> 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
-------------------------------------------------------------



reply via email to

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