Mercurial > hg > what-is-octave
diff PoliMI2012/examples/embedded.cc @ 4:0a1567794b40
[mq]: folder_reorganization
author | Carlo de Falco <cdf@users.sourceforge.net> |
---|---|
date | Thu, 08 Nov 2012 09:55:34 +0100 |
parents | |
children |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/PoliMI2012/examples/embedded.cc @@ -0,0 +1,29 @@ +#include <iostream> +#include <octave/oct.h> +#include <octave/octave.h> +#include <octave/parse.h> + +int main (void) +{ + string_vector octave_argv (2); + octave_argv(0) = "embedded"; + octave_argv(1) = "-q"; + + octave_main (2, octave_argv.c_str_vec (), 1); + + + octave_value_list out = feval ("version", octave_value_list (), 1); + std::cout << out(0).string_value () << std::endl; + + Matrix A (4, 4); + for (octave_idx_type i = 0; i < 4; i++) + for (octave_idx_type j = 0; j < 4; j++) + A(i,j) = 1.0 / (static_cast<double> (i) + + static_cast<double> (j) + 1); + + ColumnVector b (4, 1.0); + + out = feval ("mldivide", octave_value (A), octave_value (b), 1); + + return 0; +}