[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vectorize problem?
From: |
Paul Kienzle |
Subject: |
Re: vectorize problem? |
Date: |
Sat, 2 Jul 2005 09:23:43 -0400 |
The routine is defined in src/ov-fcn-inline.cc.
You should be able to do something like:
if (args(0).is_string())
{
retval = octave_value(vectorize(args(0).string_value()));
}
else
{
octave_fcn_inline* old = args(0).fcn_inline_value(true);
if (old)
{
std::string new_fun = vectorize(args(0).string_value());
retval = octave_value(new octave_fcn_inline(new_func,
old->fcn_arg_names());
}
else
{
error("vectorize: must be a string or inline function");
}
}
where vectorize is just the old_func -> new_func code in the current
vectorize:
std::string vectorize(const std::string& old_func)
{
size_t i = 0;
while (i < old_func.length ())
{
std::string t1 = old_func.substr (i, 1);
if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^")
{
if (i && old_func.substr (i-1, 1) != ".")
new_func.append (".");
// Special case for ** operator.
if (t1 == "*" && i < (old_func.length () - 1)
&& old_func.substr (i+1, 1) == "*")
{
new_func.append ("*");
i++;
}
}
new_func.append (t1);
i++;
}
return new_func;
}
Test it, create a patch and submit to address@hidden
- Paul
On Jul 2, 2005, at 7:45 AM, Peter Brinkmann wrote:
Hi,
I just realized with horror that IODE (http://www.math.uiuc.edu/iode/)
isn't working with Octave 2.1.69 because the vectorize function doesn't
accept string arguments.
Would it be possible to change the behavior of vectorize to match the
behavior under Matlab? The Matlab version accepts both strings and
inline functions.
-------------------------------------------------------------
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
-------------------------------------------------------------