Interfacing octave with C#

后端 未结 5 2000
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 18:09

I have developed a program in Octave to which I would like to add a GUI layer. I want to create an executable program in C# that I can distribute but want to stick with the

相关标签:
5条回答
  • 2020-12-15 18:37

    I recently needed this functionality for my pet-project and all existing solutions weren't user friendly or just didn't work. I created an open-source, cross-platform, .NET Standard library for this sole purpose. I hope it will save some headaches - Octave.NET on GitHub

    0 讨论(0)
  • 2020-12-15 18:44

    There are lots of math libraries for c#. Math.NET Numerics seems to be a good free alternative. There are also commercial implementations.

    Another alternative is to call Octave with Process.Start and parse the output. This saves you from rewriting your calculations but you need to able do bundle Octave with your application. If you want to tightly mix c# and math code this will be a quite complicated, but if your math code is a big calculation with a single set of inputs and a single set of outputs it might be a good alternative.

    0 讨论(0)
  • 2020-12-15 18:44

    To build a standalone: http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

    I have a similar problem, which is to create a .dll for C# I've been looking for a way to do this for a while now, I have not been able to find instructions or an easy way to do it. This is more an ongoing project than a question, but I' d definitely take any answer or help!:)

    I am planning to keep track of my efforts here, so at the end this should become a page that will allow people to find how to compile octave into a .dll ( always assuming this is possible)

    So:

    -I am using VS2010

    -I started with the MS VS2010 compiled binaries for octave, assuming this will be closer.

    -I created a project in VS and used the following code:

    #include <iostream>
    #include <octave/oct.h>
    #include <octave/octave.h>
    #include <octave/parse.h>
    
    
    int main(int argc, char* argv[])
    {
        std::cout<<"hello world"<<std::endl;
        char a[900];
        std::cin>>a;
        return 0;
    }
    

    -The code would of course not find the octave libs, so I added them, e.g.,

    C:\Octave\Octave-3.6.1-VS10\lib\octave\3.6.1;C:\Octave\Octave-3.6.1-VS10\include\octave-3.6.1;C:\Octave\Octave-3.6.1-VS10\include;$(VCInstallDir)include;...
    

    To Include Directories (Right click on Project-->Properties)

    Now I get

    Error   73  error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall octave_value::~octave_value(void)" (__imp_??1octave_value@@QAE@XZ) referenced in function "public: void * __thiscall octave_value::`vector deleting destructor'(unsigned int)" (??_Eoctave_value@@QAEPAXI@Z)    ...\Projects\cppap32\cppap32\main.obj   cppap32
    

    which basically means it cannot find octave_value... By using dumpbin.exe we can see that it needs to have both octave.lib AND octinterp.lib

    It now does compile.... :)

    Next step create a .dll ...

    Notes:

    To check what is exported by a .lib:

    dumpbin.exe /exports C:\Octave\Octave-3.6.1-VS10\lib\octave\3.6.1\octave.lib
    

    Relevant links:

    Similar, open question on other site: http://www.daniweb.com/software-development/cpp/threads/297336/gnu-octave-for-c-how-to-start

    0 讨论(0)
  • 2020-12-15 18:48

    I have written an Octave C# wrapper for my Adastra project:

    http://code.google.com/p/adastra/source/browse/trunk/src/Adastra/Tools/OctaveController.cs

    This is an example usage: http://code.google.com/p/adastra/source/browse/trunk/src/Adastra/Algorithms/OctaveLogisticRegression.cs This is a hybrid Octave and C# implementation of Logistic Regression classificator.

    0 讨论(0)
  • 2020-12-15 18:59

    Maybe you can look the Xoctave. This is an GUI written for Octave. Here is the link: www.xoctave.com

    And maybe the guys there could have a solution for your questions.

    0 讨论(0)
提交回复
热议问题