using .m scripts in C++ programs

Ken Massey kpmassey at gmail.com
Wed Apr 9 16:08:56 CDT 2008


How can I use existing .m scripts in my C++ code?  e.g. the one to
find the rank of a matrix:

  http://velveeta.che.wisc.edu/cgi-bin/cvsweb.cgi/~checkout~/octave/scripts/linear-algebra/rank.m?rev=HEAD&content-type=text/plain

Do these .m scripts have compiled versions I can link into my C++ program?


#include <octave/oct.h>
int main (void) {
       int n = 2;
       Matrix A = Matrix (n, n);
      A(1,1)=1;  A(1,2) =2;
      A(2,1)=2;  A(2,2) = 4;

     // how can I do something like this?
       std::cout << rank(A);
              //  or
       std::cout << A.rank();
}


More information about the Help-octave mailing list