[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using expm in C++
From: |
Ben Abbott |
Subject: |
Re: Using expm in C++ |
Date: |
Mon, 06 Feb 2012 20:17:15 -0500 |
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