help-octave
[Top][All Lists]
Advanced

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

How do I initialize the Matrix class?


From: niles
Subject: How do I initialize the Matrix class?
Date: Thu, 01 Aug 96 14:29:37 -0400

I'm new to C++ and would like to use the liboctave stuff.

How can I do the following simple Octave operation in
C++ using liboctave?

%%%%%%%%%%%%%%%%%%%%%%%%%%
a = [1 2];
b = [3 4; 5 6];
c = a*b;
%%%%%%%%%%%%%%%%%%%%%%%%%%

Here's a guess:

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

main()
{
  RowVector a(2), c(2); // Can't I 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;

  cout << "a = ["  << a << "]" << endl;
  cout << "b = \n" << b << endl;
  cout << "c = ["  << c << "]" << endl;
}

//////////////////////////


        Thanks,
        Rick Niles.


reply via email to

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