help-octave
[Top][All Lists]
Advanced

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

Re: how to call and use liboctave


From: niles
Subject: Re: how to call and use liboctave
Date: Wed, 23 Apr 97 09:26:16 -0400

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


reply via email to

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