help-octave
[Top][All Lists]
Advanced

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

Re: exp(Matrix) in oct file?


From: Philip Nienhuis
Subject: Re: exp(Matrix) in oct file?
Date: Wed, 10 Mar 2004 04:33:56 -0600

Michael Creel <michael dot creel at uab dot es> wrote:
> Can functions such as exp(), lgamma() etc., be made to work upon the Matrix 
> type? I'm now doing:
> 
>       for (i=0; i < n; i++)
>       {
>               temp = (double) xtheta(i);
>               temp = exp(temp);
>       }
> 
> where xtheta is a column vector.

It depends on what you want. Just the plain function() of every
individual element in a matrix? Or do you need real matrix functions?

For vectors you are probably more or less along the right way, apart
from some optimization.

For exp(<sq. 2D matrix>) see expm. There are a few more 2D square matrix
function types, in octave-forge or maybe even in Octave itself.

For general 2D square matrix functions, have a look at funm.m in
octave-forge. Based upon diagonalization, it can handle many function
types. I don't know if it's easy to implement in an oct-file.
But note that this particular funm.m implementation is *very* basic,
probably even more of a kludge (and I can say that as I wrote it myself
;-) ). Work has been done by other people to improve it but lack of time
seems to have had some bad influence :-( 

You'd probably be better off along the lines of the funm.m from Rlab 
(which AFAICS is quite similar to the one in Matlab), licencing issues 
permitting of course.

Philip



-------------------------------------------------------------
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]