#include #include #include #include #include #include #include #include #include "fun.h" extern "C" { int fun(FUNCARGS *inp, FUNCCALL *funcall) { static octave::interpreter interpreter; bool status = interpreter.initialized(); if(status==false) { interpreter.initialize (); int status_exec = interpreter.execute (); if (status_exec != 0) { std::cerr << "creating embedded Octave interpreter failed!" << std::endl; } } try { octave_value_list in; unsigned int k; int l; int str_count = 0; char str_fun[20]; char str_pkg[20]; int pkg=0; int nouts; for(l=0;ln_in_arguments;l++) { if(inp[l].type==TYPE_DOUBLE) { if(inp[l].is_in_cmplx==1) { ComplexMatrix matr = ComplexMatrix (inp[l].n_in_rows,inp[l].n_in_cols); double* id_real = (double *)inp[l].in_data_real; double* id_img = (double *)inp[l].in_data_img; k=0; for (int r=0;rn_out_user); int row; int col; nouts = out.length(); funcall->n_out_arguments = nouts; //std::cout << "funcall->n_out_arguments is: " << funcall->n_out_arguments << '\n'; for( unsigned int ii = 0; ii < nouts; ii++ ) { if(out(ii).iscomplex()==1) { inp[ii].is_out_cmplx=1; //std::cout << "out "<< ii<< " is complex" << '\n'; ComplexMatrix cmOut(out(ii).complex_matrix_value()); //std::cout << "cmOut "<< cmOut << '\n'; //std::cout << "Out(ii) "<< out(ii).complex_matrix_value() << '\n'; //std::cout << "out(ii) "<< out(ii) << '\n'; row = cmOut.rows(); col = cmOut.columns(); inp[ii].n_out_rows = row; inp[ii].n_out_cols = col; k=0; inp[ii].out_data_real = malloc(sizeof(double)*(row*col)); inp[ii].out_data_img = malloc(sizeof(double)*(row*col)); double* rd = (double *)inp[ii].out_data_real; double* cd = (double *)inp[ii].out_data_img; for(unsigned int i=0;i