12 #include <visp3/core/vpConfig.h>
13 #include <visp3/core/vpMatrix.h>
18 #ifdef ENABLE_VISP_NAMESPACE
35 int xCols = x.getCols();
36 int xRows = x.getRows();
43 mxArray *T = mxCreateDoubleMatrix(xRows, xCols, mxREAL);
54 std::cout <<
"ViSP Input Matrix:" << std::endl;
55 for (
size_t i = 0; i < xRows; i++) {
56 for (
size_t j = 0; j < xCols; j++)
57 std::cout << x.data[i * xCols + j] <<
" ";
58 std::cout << std::endl;
63 if (!(ep = engOpen(
""))) {
64 fprintf(stderr,
"\nCan't start MATLAB engine\n");
71 memcpy((
void *)mxGetPr(T), (
void *)x.data, xRows * xCols *
sizeof(
double));
76 engPutVariable(ep,
"Tm", T);
82 engEvalString(ep,
"Dm = sum(Tm');");
87 D = engGetVariable(ep,
"Dm");
92 memcpy((
void *)res, (
void *)mxGetPr(D),
sizeof(res));
96 std::cout << std::endl <<
"MATLAB Output Matrix (Column-wise sum):" << std::endl;
97 for (
size_t i = 0; i < resCols; i++)
98 std::cout << res[i] <<
" ";
99 std::cout << std::endl;
102 std::cout << std::endl <<
"Hit return to quit\n" << std::endl;
109 engEvalString(ep,
"close;");
Implementation of a matrix and operations on matrices.