12 #include <visp3/core/vpMatrix.h>
30 int xCols = x.getCols();
31 int xRows = x.getRows();
38 mxArray *T = mxCreateDoubleMatrix(xRows, xCols, mxREAL);
49 std::cout <<
"ViSP Input Matrix:" << std::endl;
50 for (
size_t i = 0; i < xRows; i++) {
51 for (
size_t j = 0; j < xCols; j++)
52 std::cout << x.data[i * xCols + j] <<
" ";
53 std::cout << std::endl;
58 if (!(ep = engOpen(
""))) {
59 fprintf(stderr,
"\nCan't start MATLAB engine\n");
66 memcpy((
void *)mxGetPr(T), (
void *)x.data, xRows * xCols *
sizeof(
double));
71 engPutVariable(ep,
"Tm", T);
77 engEvalString(ep,
"Dm = sum(Tm');");
82 D = engGetVariable(ep,
"Dm");
87 memcpy((
void *)res, (
void *)mxGetPr(D),
sizeof(res));
91 std::cout << std::endl <<
"MATLAB Output Matrix (Column-wise sum):" << std::endl;
92 for (
size_t i = 0; i < resCols; i++)
93 std::cout << res[i] <<
" ";
94 std::cout << std::endl;
97 std::cout << std::endl <<
"Hit return to quit\n" << std::endl;
104 engEvalString(ep,
"close;");
Implementation of a matrix and operations on matrices.