my c/c++ "octaveserver" program does not work with inbuilit m-file functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

my c/c++ "octaveserver" program does not work with inbuilit m-file functions

maber
This post was updated on .
Hi!
I have recompiled octave to an "octaveserver" using Visual Studio 2013. This enables me to call octave m-files from a client c/c++ program using a pipe. This works very fine for common math operators like +,-,/,* in my m-files. However when I like to call those simple inbuilt m-file functions like trapz, polyfit.. etc, the "octaveserver" does not provide correct answers. Somehow,  my octaveserver cannot "link" those inbuilt functions properly. Have I missed something in the compilation?

My simple octaveserver function which can analyse spectral data looks as follows

#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/toplev.h>

const octave_value_list Predictor(std::string mfile, double spectrum[], int spectrumsize)  
{
        // Insert spectrum into octave matrix type
        Matrix sz(1, spectrumsize);
        for (int j = 0; j < spectrumsize; j++)
        {
                sz(0, j) = spectrum[j];
        }
        octave_value_list in;
        in(0) = octave_value(sz);
       
        //Start octave
        const char * argvv[] = { "" /* name of program, not relevant */, "--silent" };
        octave_main(2, (char **)argvv, true /* embedded */);
       
        //Evaluate and return the result
        const octave_value_list result = feval(mfile, in, 1);

        return result;
}


I would appreciate any hint in this!! Thanks,
Mads
Reply | Threaded
Open this post in threaded view
|

Re: my c/c++ "octaveserver" program does not work with inbuilit m-file functions

Dave Cottingham 2
maber wrote
Hi!
I have recompiled octave to an "octaveserver" using Visual Studio 2013. This enables me to call octave m-files from a client c/c++ program using a pipe. This works very fine for common math operators like +,-,/,* in my m-files. However when I like to call those simple inbuilt m-file functions like trapz, polyfit.. etc, the "octaveserver" does not provide correct answers. Somehow,  my octaveserver cannot "link" those inbuilt functions properly. Have I missed something in the compilation?
Your symptom sounds like the octave search path isn't set. You can check this by asking your octaveserver to execute the "path" command and see if the result points to the directories where things like polyfit.m are kept.

If this is the problem, I'm not sure exactly how you should solve it. If you weren't on Windows, I'd say set the environment variable OCTAVE_PATH to the appropriate path. Perhaps Windows has some corresponding thing.
Reply | Threaded
Open this post in threaded view
|

Re: my c/c++ "octaveserver" program does not work with inbuilit m-file functions

maber
Thanks!
Yes it appears that the program have not set any paths. The only output of "path" is "." I guess if I can find some way to set the path it should work. How to do this properly on windows is my problem then.