[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changing data type in octave_value_list
From: |
Joshua Rigler |
Subject: |
Changing data type in octave_value_list |
Date: |
Fri, 11 Aug 2006 12:52:43 -0600 |
User-agent: |
Thunderbird 1.5.0.5 (X11/20060719) |
This might be more of a C/C++ question, so please be kind...
I am writing a .oct file, and the source includes the following standard
definition at the beginning:
DEFUN_DLD (cdflib, args, nargout, "...whatever...")
As I understand things, 'args' is my input list, passed from the
interpreter, and of type octave_value_list. I want to be able to pass
one of my inputs as either a scalar, or a string that I can then
convert/map to a corresponding scalar and place back into the same
position in args, before proceeding to subsequent operations.
What I naively thought I could do is (paraphrased):
if (args(0).is_string)
{
args(0) = double (convert_s2i(args(0).string_value) );
}
...where 'convert_s2i' is just a function that maps certain strings to
long integers, which I am then happy to store as double-floats, since
this is what Octave expects (I suppose newer versions have support for
additional data types, including integers, but I'm perfectly happy with
doubles). Note, I am not simply trying to convert an ascii '1' into its
scalar equivalent, but rather a multi-character string that associates
with a particular integer inside a C++ map object.
Anyway, the problem I face is that I keep getting the following error:
error: invalid conversion from string to real scalar
I assume this corresponds to my attempt to transform args(0) from a
string into a scalar. Is there a straight-forward way to do this?
Thanks.
-EJR
- Changing data type in octave_value_list,
Joshua Rigler <=