octave-maintainers
[Top][All Lists]
Advanced

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

Re: AD matrix operations


From: Brad Bell
Subject: Re: AD matrix operations
Date: Thu, 26 Jan 2017 07:30:02 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

The type a_double in Octave (and other languages)
    http://www.seanet.com/~bradbell/cppad_swig/a_double_ctor.htm
is a scalar type that will record floating point operations with the purpose of creating a corresponding function object
    http://www.seanet.com/~bradbell/cppad_swig/a_fun_ctor.htm

In python, you can create a numpy matrix of type a_double and perform operations, like matrix addition, multiplication, etc on the objects. The actual matrix loops are done in C (not in python). Can one do a similar thing in Octave ?



On 01/26/2017 07:20 AM, John W. Eaton wrote:
On 01/26/2017 08:50 AM, Brad Bell wrote:
In python, numpy will provide matrix operations for overloaded types.
This worked for AD matrix operations; see
    http://www.seanet.com/~bradbell/pycppad/pycppad.htm
Is there a package, similar to numpy, that works for Octave ?

In Matlab, you can create a function like this (the @double directory needs to be somewhere in your MATLABPATH):

  @double/mtimes.m:
  function r = mtimes (x, y)
    fprintf ('my mtimes!\n');
    r = builtin ('mtimes', x, y);
  end

to overload the builtin mtimes function that is called for the syntax "x * y" when x and y are double precision numeric objects (that includes sparse and complex). You'd need a separate definition for single.

Is that what you are looking for?

The overloading feature is not yet implemented in Octave for built-in types like double and single.

jwe






reply via email to

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