[Top][All Lists]

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

Re: How to overload factorial (m-file) for a class defined in an oct-fil

From: Michael Goffioul
Subject: Re: How to overload factorial (m-file) for a class defined in an oct-file?
Date: Thu, 7 Nov 2013 08:00:49 -0500

On Thu, Nov 7, 2013 at 7:52 AM, Lukas Reichlin <address@hidden> wrote:
On 07.11.2013, at 13:45, "c." <address@hidden> wrote:

> On 7 Nov 2013, at 13:39, Lukas Reichlin <address@hidden> wrote:
>> Dear Octave Community
>> I've created a class "sym" in an oct-file. Now I want to overload Octave's factorial function (an m-file) for this class in C++. How can I do this?
>> DEFUN_DLD (factorial, args, nargout, "factorial help")
>> alone doesn't help because now all factorial calls are handled by the oct-file, instead of just the arguments of class "sym". I need the C++ equivalent of @sym/factorial.m.
>> Thanks in advance for any hints,
>> Lukas
> If I understand corrently your question, I think you just need to place your oct file in the @sym directory:
> address@hidden/factorial.oct
> HTH,
> c.

Is it also possible to create @sym/sym.oct and tell Octave by autoload that it finds @sym/factorial inside @sym/sym.oct? I would like to create a single oct-file which contains all methods for the sym class.

I don't think that's possible, but what you can do is to define an autoloaded function in your oct-file, like __sym_factorial__, then create a simple wrapper @sym/factorial.m:

function y = factorial (x)
  y = __sym_factorial__ (x);

That's what I did for the octave_com_object class in the Windows package from octave-forge.


reply via email to

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