[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exp(A) where A is a matix
From: |
John W. Eaton |
Subject: |
Re: exp(A) where A is a matix |
Date: |
Wed, 4 Aug 1999 12:06:59 -0500 (CDT) |
On 4-Aug-1999, A. Scottedward Hodel <address@hidden> wrote:
| Haven't looked in the octave sources, but it would take less time to
| write
|
| #include <math.h>
| ...
| Matrix retval = ...;
|
| for (int ii = 0 ; ii < retval.rows() ; ii++)
| for ( int jj = 0 ; jj < retval.columns() ; jj++)
| retval(ii,jj) = exp(retval(ii,jj));
|
|
| than to dig through the code. [Eventually, guilt would
| catch up to me and I'd have to search through the liboctave
| and src/DLD-FUNCTIONS sources to see how the exp function handles
| matrix arguments.]
I think you would find that it is implemented approximately the way
you have above, but it is done through a function pointer instead of
duplicating code for every function (sin, cos, tan, exp, log, etc.).
So, I don't think there is a
Matrix exp (const Matrix& m)
function defined in the Octave sources. But there are `map' and
`apply' functions defined for the matrix and vector classes. They
allow you to write
Matrix m, r;
...
r = m.map (exp);
The `map' function is a const function, so it doesn't change the
object on which it operates. The `apply' function is not a const
function and it modifies the object on which it operates.
jwe
---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL. To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------