how to call and use liboctave

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

how to call and use liboctave

Jinyoung Choi
Recently I manage to complie the liboctave.
But with the 'Octave C++ Classes' included octave package,
I don't know how to call the functions and the class of
liboctave.
Because I don't know C++ well, only using C.
If there are some example(easy example), I can do that.

All my friends are using only Windoz 95 but me, OS/2
Would you help me?

Bye.

Reply | Threaded
Open this post in threaded view
|

Re: how to call and use liboctave

niles-5

> Because I don't know C++ well, only using C.
> If there are some example(easy example), I can do that.

I'm pretty sure your going to have a hell of a time linking in a C++
library into C.  While the other way around is easy, C++ is a
super-set of C.  If you do get it working it will be very ugly and
probably compiler dependent (i.e. non-portable).  The following is a
simple C++ example.  Learn C++ it's worth it.  The header files
config.h and Matrix.h are from the octave dist.


#include <iostream.h>
#include <config.h>
#include <Matrix.h>

main()
{
  RowVector a(2), c(2); // Can't set the value of a
  a.elem(0) = 1;        // in the constructor.
  a.elem(1) = 2;

  Matrix b(2,2);
  b.elem(0,0) = 3;
  b.elem(0,1) = 4;
  b.elem(1,0) = 5;
  b.elem(1,1) = 6;

  c = a * b;

  Matrix d = b.transpose();
  cout << "a = ["  << a << "]" << endl;
  cout << "b = \n" << b << endl;
  cout << "c = ["  << c << "]" << endl;
}

        Good luck,
        Rick Niles.