help-octave
[Top][All Lists]
Advanced

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

Re: Octave_map and vectors


From: Geraint Paul Bevan
Subject: Re: Octave_map and vectors
Date: Tue, 28 Oct 2003 15:50:04 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Claudio Belotti wrote:
|
| thanks Geraint,
| with oct function I was meaning a c++ dynamical extension of the
Octave interpreter, not a an octave script.
|

Sorry, I misread your question. I think that this is what you are
looking for:

// -*-c++-*-
// test.cc

#include <octave/oct.h>
#include <octave/oct-map.h>

DEFUN_DLD (test, args, , "test")
{
~  static octave_value_list retval;
~  octave_value_list array;

~  Octave_map map1, map2;

~  map1.assign("name", octave_value("hello"));
~  map1.assign("type", octave_value("int32"));

~  map2.assign("name", octave_value("world"));
~  map2.assign("type", octave_value("int32"));

~  array(0) = map1;
~  array(1) = map2;

~  retval(0) = array;
~  return retval;
}


$ mkoctfile test.cc && echo test | octave -q
ans =
(
~  [1] =
~  {
~    name = hello
~    type = int32
~  }

~  [2] =
~  {
~    name = world
~    type = int32
~  }

)


- --
Geraint Bevan
http://www.mech.gla.ac.uk/~gbevan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iEYEARECAAYFAj+ekCsACgkQcXV3N50QmNNawwCgg5BfhoCipR0U687yVjadzbgX
2BEAoI/B+nBoqmC/B/EEphrx9Vegn04o
=iR6b
-----END PGP SIGNATURE-----



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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