From help-octave-request at bevo dot che dot wisc dot edu Fri Jan 16 01:31:42 2004 Subject: Re: C++ and octave From: "John W. Eaton" To: =?ISO-8859-1?Q?S=F8ren_Hauberg?= Cc: help-octave at bevo dot che dot wisc dot edu Date: Thu, 15 Jan 2004 20:08:14 -0800 On 14-Jan-2004, Søren Hauberg wrote: | Thanks for the quick reply, and I'm sorry about my late reply | | A method that I need to implement on C++ needs to compute the mean and | standard deviation of the values in a matrix. I cannot find any | functions I can call from C++ to compute these values and google gives | me nothing. | | Typing "type mean" inside octave gives me an m-file implementation of | the mean function. Does this mean I can't call mean from C++ ? | At the moment I have just a quick 'n' dirty implementation of mean & std | in C++. Is this really the way to go? Yes, you would need to reimplement it. As Geraint Paul Bevan mentioned, if you are writing a dynamically linked function for Octave, you could also use feval to call Octave's .m file version of the function, but if you are writing a standalone program, that won't work (without also loading all of Octave's interpreter, which I would bet is more than you really want). And in either case, if you use the interpreted function, it will probably be a lot slower than you want (that is probably part of the reason that you are solving your problem with C++). This kind of problem will always exist for people who wish to write C++ code that uses functions from Octave. Some useful functions are written as .m files, and for larger functions, it may be a significant amount of work to translate them to useful and efficient C++ (that's probably one of the reasons they are implemented as .m files). When functions are small, it is not too hard to write adequate C++ versions. But just because someone translates the code for functions like this doesn't mean that they should go into liboctave (we could easily make Octave even more bloated if we did that for every function that anyone ever needed in C++). OTOH, perhaps mean (and a few other basic functions that are currently .m files) should be a part of the liboctave array classes. If you (or anyone else) would like that to happen, then please submit a patch. Finally, my primary goal in writing Octave was to make it easy to use the interpreted language. Making it easy to write C++ code is nice, but it is a secondary goal. 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 -------------------------------------------------------------