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 18:07:18 -0800 (PST)

I need to call just expm() and I don't know how to write a C++ API for expm.m. I have also tried Mathias Michel's guide without any success. 

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

On Feb 6, 2012, at 8:24 PM, loisp wrote:

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

I'm unfamiliar with what you're asking, but I'll try to help.

If you only need to call expm and don't require anything else, I think you're better off recoding the expm function in c++.

        http://hg.savannah.gnu.org/hgweb/octave/file/3e4350f09a55/scripts/linear-algebra/expm.m

If you really want to call Octave you can start with ...

        http://octave.sourceforge.net/doxygen/html/

There's a rather dated description for call Octave from c++ below.

        http://www.mathias-michel.de/download/howto-octave-c++.ps

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