Possible extension/fix to the linear-algebra funm function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible extension/fix to the linear-algebra funm function

José Abílio Matos
Hi,
        when using funm from linear-algebra I have noticed a small
incompatibility with the corresponding matlab function.

        funm does not accept as argument the functions "exp", "log" and
"sqrt". The reason for that is described in the function's documentation:

## Note that you should not use funm for 'sqrt', 'log' or 'exp'; instead
## use sqrtm, logm and expm as these are more robust.

Yet reading the code this seems to be an outdated comment because if we add
them to the set of supported functions then funm will delegate the evaluation
to the thfm function that supports them (by calling the corresponding sqrtm,
logm and expm functions).

So, at least for compatibility, I suggest to add those three functions to the
set of supported function since funm already does the right thing and thus I
also suggest to remove that comment from the documentation.

I send an attached patch with the proposed trivial changes.

What do you think?

Regards,
--
José Matos


linear-algebra.diff (860 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Possible extension/fix to the linear-algebra funm function

PhilipNienhuis
José Abílio Matos wrote

> Hi,
> when using funm from linear-algebra I have noticed a small
> incompatibility with the corresponding matlab function.
>
> funm does not accept as argument the functions "exp", "log" and
> "sqrt". The reason for that is described in the function's documentation:
>
> ## Note that you should not use funm for 'sqrt', 'log' or 'exp'; instead
> ## use sqrtm, logm and expm as these are more robust.
>
> Yet reading the code this seems to be an outdated comment because if we
> add
> them to the set of supported functions then funm will delegate the
> evaluation
> to the thfm function that supports them (by calling the corresponding
> sqrtm,
> logm and expm functions).
>
> So, at least for compatibility, I suggest to add those three functions to
> the
> set of supported function since funm already does the right thing and thus
> I
> also suggest to remove that comment from the documentation.
>
> I send an attached patch with the proposed trivial changes.
>
> What do you think?

Thanks José.
You're right in principle but IMO it is still better to directly call the
core functions logm, expm and sqrtm if only to avoid overhead.
Please upload your patch to the patch tracker if you want:
https://savannah.gnu.org/patch/?group=octave

BTW, there's a much better funm.m looming here:

https://github.com/RickOne16/matrix/tree/master/funm

I hope that one can be absorbed one day in the linear-algebra package or
rather, core Octave.
AFAICS it works fine - but I only tested it for mathematically fairly easy
cases (positive-semidefinite (symmetric) matrices of limited size, max. size
~50).

Philip




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html