I am new to the topic of API.Can you tell me why the program crashes? What am I doing wrong? I work in Ubuntu. Octave 6.4.0
#include <iostream>#include <octave/oct.h>#include <octave/octave.h>#include <parse.h>#include <interpreter.h>using namespace std;int main() { // Созданиематрицы Matrix mat(2, 3); mat(0, 0) = 1; mat(0, 1) = 2; mat(0, 2) = 3; mat(1, 0) = 4; mat(1, 1) = 5; mat(1, 2) = 6; // Выводисходнойматрицы cout << "Исходнаяматрица:" << endl << mat << endl; // Транспонированиематрицы octave_value_list in, out; in(0) = mat; out = octave::feval("transpose", in, 1); // Получениетранспонированнойматрицыизвыходногосписказначений Matrix transposed_mat = out(0).matrix_value(); // Выводтранспонированнойматрицы cout << "Транспонированнаяматрица:" << endl << transposed_mat << endl; return 0;}
Here's my compilation:
g++ -o 2 2.cpp -I/usr/include/octave-6.4.0 -I/usr/include/octave-6.4.0/octave -I/usr/include/octave-6.4.0/octave/interpreter -I/usr/include -I/usr/include/octave-6.4.0/octave -loctave -loctinterp -Wl,-rpath,/usr/lib/x86_64-linux-gnu/octave/6.4.0 -L/usr/lib/x86_64-linux-gnu/octave/6.4.0 -Wl,--no-as-needed -loctave -loctinterp
It's very difficult to understand the topic of API without manuals(didn't find them), but so far I've only tried to write a solution to a system of linear equations(got it and it works).If there is something wrong with compilation, please advise.