help-octave
[Top][All Lists]
Advanced

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

Re: Using expm in C++


From: loisp
Subject: Re: Using expm in C++
Date: Mon, 6 Feb 2012 17:24:57 -0800 (PST)

The thing is I don't want to use an oct-file. I want my code to be in C++ and to use Octave just for the expm() function. Is there any way I can achieve that?

On Tue, Feb 7, 2012 at 6:48 AM, bpabbott [via Octave] <[hidden email]> wrote:

On Feb 6, 2012, at 5:58 PM, loisp wrote:

> Hello,
>
> I'm writing a C++ program and want to use the Octave function expm()
> (exponential of a matrix). Here is the relevant snippet from my code.
>
> hamiltonian = Matrix (N+1, N+1);
> for(int i = 0; i < N+1; i++)
> {
> for(int j = 0; j < N+1; j++)
> {
> if((i+1 == j) || (i == j+1))
> hamiltonian (i, j) = -1;
> }
> }
>
> hamiltonian = hamiltonian.expm();
>
>
> When I try to compile my program using mkoctfile I get the following error
>
> dmatrix.cpp: In function ‘int main()’:
> dmatrix.cpp:54: error: ‘class Matrix’ has no member named ‘expm’
>
> I was wondering if the classes Matrix and ComplexMatrix provide that
> function and if they don't, do you have any work around to suggest? I am
> using MacOSX and have Octave installed though fink.
>
> Thanks in advance.
>
> Lois
I may be wrong, but I don't think there is an expm is an on the c++ side. However, there is an m-file version. You can call it via feval (although I've never tried).

http://www.gnu.org/software/octave/doc/interpreter/Calling-Octave-Functions-from-Oct_002dFiles.html

Ben


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave



If you reply to this email, your message will be added to the discussion below:
http://octave.1599824.n4.nabble.com/Using-expm-in-C-tp4363138p4363437.html
To unsubscribe from Using expm in C++, click here.
NAML



View this message in context: Re: Using expm in C++
Sent from the Octave - General mailing list archive at Nabble.com.

reply via email to

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