help-octave
[Top][All Lists]
Advanced

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

Re: Can you call repmat from feval in C++?


From: jkirby
Subject: Re: Can you call repmat from feval in C++?
Date: Sat, 27 Nov 2010 10:47:37 -0800 (PST)

In reading through the archives, it seems this should work. I was skeptical
that the loaded interpreter was not initializing paths correctly but I think
it is. 

I tried a simplified test to see if a generic .m file can be called via
feval from C++. I'm not sure why this isn't working:

C++ (I call octave_main elsewhere)
...
   Matrix  testmat (3,1);
   testmat(0,0) = 0.710893235843446;
   testmat(1,0) = 0.000000850010567;
   testmat(2,0) = 0.000000541896504;
   
   {
     octave_function *fnc = load_fcn_from_file ("repmat2.m", "./", "",
"repmat2", true);
     std::cout << "isdef = " << fnc->is_defined() << " isfunc = " <<
fnc->is_function() << std::endl;


     octave_value_list args;
     args(0) = testmat;
     args(1) = octave_value(2);
     args(2) = octave_value(3);
     octave_value_list ret = feval(fnc, args, 1);
     std::cout << "ret numargs = " << ret.length() << " type = " <<
check_value_type(ret(0)) << std::endl;
     std::cout << "ret = " << ret(0).matrix_value();
   }
...

and repmat2.m has been hacked to be simply:
function x = repmat2 (a, m, n)

  x = [1,2;3,4];

endfunction




ret output is basically: (is_* => that function returned true)

isdef = 1 isfunc = 1
ret numargs = 1 type =  is_undefined()
 is_empty()
 is_zero_by_zero()


are .oct wrappers required in order to call 'feval'? The code seems to
handle this case so I'm not sure what's happening. getcwd() agrees with
where I have repmat2.m so I believe it can find the file correctly.
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Can-you-call-repmat-from-feval-in-C-tp3038328p3061810.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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