[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave_map and vectors
From: |
John W. Eaton |
Subject: |
Re: Octave_map and vectors |
Date: |
Tue, 28 Oct 2003 09:58:46 -0600 |
On 28-Oct-2003, Geraint Paul Bevan <address@hidden> wrote:
| -----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
| ~ }
|
| )
Yes, this works, but why would you want to do that when Octave_map is
already capable of holding structure arrays?
jwe
-------------------------------------------------------------
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
-------------------------------------------------------------
- Octave_map and vectors, Claudio Belotti, 2003/10/28
- Re: Octave_map and vectors, Geraint Paul Bevan, 2003/10/28
- Re: Octave_map and vectors, Claudio Belotti, 2003/10/28
- Re: Octave_map and vectors, Geraint Paul Bevan, 2003/10/28
- Re: Octave_map and vectors, Claudio Belotti, 2003/10/30
- Re: Octave_map and vectors, John W. Eaton, 2003/10/30