45 #include <visp3/core/vpConfig.h> 46 #include <visp3/core/vpDebug.h> 47 #include <visp3/core/vpGEMM.h> 48 #include <visp3/core/vpHomogeneousMatrix.h> 49 #include <visp3/core/vpMath.h> 50 #include <visp3/core/vpVelocityTwistMatrix.h> 57 bool test(
const std::string &s,
const vpMatrix &M,
const std::vector<double> &bench)
59 static unsigned int cpt = 0;
60 std::cout <<
"** Test " << ++cpt << std::endl;
61 std::cout << s <<
"(" << M.
getRows() <<
"," << M.
getCols() <<
") = \n" << M << std::endl;
62 if (bench.size() != M.
size()) {
63 std::cout <<
"Test fails: bad size wrt bench" << std::endl;
66 for (
unsigned int i = 0; i < M.
size(); i++) {
67 if (std::fabs(M.
data[i] - bench[i]) > std::fabs(M.
data[i]) * std::numeric_limits<double>::epsilon()) {
68 std::cout <<
"Test fails: bad content" << std::endl;
76 double getRandomValues(
const double min,
const double max)
78 return (max - min) * ((double)rand() / (double)RAND_MAX) + min;
81 bool equalMatrix(
const vpMatrix &A,
const vpMatrix &B,
const double tol = std::numeric_limits<double>::epsilon())
87 for (
unsigned int i = 0; i < A.
getRows(); i++) {
88 for (
unsigned int j = 0; j < A.
getCols(); j++) {
98 vpMatrix generateRandomMatrix(
const unsigned int rows,
const unsigned int cols,
const double min,
const double max)
102 for (
unsigned int i = 0; i < M.
getRows(); i++) {
103 for (
unsigned int j = 0; j < M.
getCols(); j++) {
104 M[i][j] = getRandomValues(min, max);
111 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) 112 vpColVector generateRandomVector(
const unsigned int rows,
const double min,
const double max)
116 for (
unsigned int i = 0; i < v.getRows(); i++) {
117 v[i] = getRandomValues(min, max);
137 unsigned int BcolNum = B.
getCols();
138 unsigned int BrowNum = B.
getRows();
139 unsigned int i, j, k;
140 for (i = 0; i < A.
getRows(); i++) {
141 double *rowptri = A[i];
143 for (j = 0; j < BcolNum; j++) {
145 for (k = 0; k < BrowNum; k++)
146 s += rowptri[k] * B[k][j];
160 unsigned int i, j, k;
163 for (i = 0; i < A.
getCols(); i++) {
165 for (j = 0; j < i; j++) {
168 for (k = 0; k < A.
getRows(); k++) {
169 s += (*(ptr + i)) * (*(ptr + j));
177 for (k = 0; k < A.
getRows(); k++) {
178 s += (*(ptr + i)) * (*(ptr + i));
199 for (
unsigned int j = 0; j < A.
getCols(); j++) {
201 for (
unsigned int i = 0; i < A.
getRows(); i++) {
202 w[i] += A[i][j] * vj;
221 unsigned int VcolNum = V.
getCols();
222 unsigned int VrowNum = V.
getRows();
224 for (
unsigned int i = 0; i < A.
getRows(); i++) {
225 double *rowptri = A[i];
227 for (
unsigned int j = 0; j < VcolNum; j++) {
229 for (
unsigned int k = 0; k < VrowNum; k++)
230 s += rowptri[k] * V[k][j];
240 int main(
int argc,
char *argv[])
244 for (
int i = 1; i < argc; i++) {
245 if (std::string(argv[i]) ==
"--benchmark") {
251 const double val = 10.0;
253 M.
resize(5, 5,
false,
false);
255 for (
unsigned int i = 0; i < M.
getRows(); i++) {
256 for (
unsigned int j = 0; j < M.
getCols(); j++) {
257 if (!
vpMath::equal(M[i][j], val, std::numeric_limits<double>::epsilon())) {
258 std::cerr <<
"Issue with matrix assignment with value." << std::endl;
262 if (!
vpMath::equal(M2[i][j], val, std::numeric_limits<double>::epsilon())) {
263 std::cerr <<
"Issue with matrix constructor initialized with value." << std::endl;
271 std::vector<double> bench(9, 0);
272 bench[2] = bench[4] = bench[6] = 1.;
274 M[2][0] = M[1][1] = M[0][2] = 1.;
276 if (test(
"R1", R1, bench) ==
false)
280 if (test(
"R2", R2, bench) ==
false)
286 std::vector<double> bench(6, 1);
288 if (test(
"M1", M1, bench) ==
false)
291 if (test(
"M2", M2, bench) ==
false)
297 for (
unsigned int i = 0; i < M.
getRows(); i++) {
298 for (
unsigned int j = 0; j < M.
getCols(); j++) {
303 M.
print(std::cout, 4);
306 N.
init(M, 0, 1, 2, 3);
308 N.
print(std::cout, 4);
309 std::string header(
"My 4-by-5 matrix\nwith a second line");
313 std::cout <<
"Matrix saved in matrix.mat file" << std::endl;
321 std::cout <<
"Matrix loaded from matrix.mat file with header \"" << header_ <<
"\": \n" << M1 << std::endl;
324 if (header != std::string(header_)) {
325 std::cout <<
"Bad header in matrix.mat" << std::endl;
331 std::cout <<
"Matrix saved in matrix.bin file" << std::endl;
337 std::cout <<
"Matrix loaded from matrix.bin file with header \"" << header_ <<
"\": \n" << M1 << std::endl;
340 if (header != std::string(header_)) {
341 std::cout <<
"Bad header in matrix.bin" << std::endl;
347 std::cout <<
"Matrix saved in matrix.yml file" << std::endl;
354 std::cout <<
"Matrix loaded from matrix.yml file with header \"" << header_ <<
"\": \n" << M2 << std::endl;
357 if (header != std::string(header_)) {
358 std::cout <<
"Bad header in matrix.mat" << std::endl;
365 std::cout <<
"R: \n" << R << std::endl;
367 std::cout <<
"M1: \n" << M1 << std::endl;
369 std::cout <<
"M2: \n" << M2 << std::endl;
371 std::cout <<
"M3: \n" << M3 << std::endl;
373 std::cout <<
"M4: \n" << M4 << std::endl;
377 std::cout <<
"------------------------" << std::endl;
378 std::cout <<
"--- TEST PRETTY PRINT---" << std::endl;
379 std::cout <<
"------------------------" << std::endl;
383 std::cout <<
"call std::cout << M;" << std::endl;
384 std::cout << M << std::endl;
386 std::cout <<
"call M.print (std::cout, 4);" << std::endl;
387 M.
print(std::cout, 4);
389 std::cout <<
"------------------------" << std::endl;
395 std::cout <<
"call std::cout << M;" << std::endl;
397 std::cout <<
"call M.print (std::cout, 6);" << std::endl;
398 M.
print(std::cout, 6);
399 std::cout << std::endl;
401 std::cout <<
"------------------------" << std::endl;
405 std::cout <<
"call std::cout << M;" << std::endl;
406 std::cout << M << std::endl;
408 std::cout <<
"call M.print (std::cout, 10);" << std::endl;
409 M.print(std::cout, 10);
410 std::cout << std::endl;
412 std::cout <<
"call M.print (std::cout, 2);" << std::endl;
413 M.print(std::cout, 2);
414 std::cout << std::endl;
416 std::cout <<
"------------------------" << std::endl;
419 M[0][2] = -0.0000000876;
420 std::cout <<
"call std::cout << M;" << std::endl;
421 std::cout << M << std::endl;
423 std::cout <<
"call M.print (std::cout, 4);" << std::endl;
424 M.print(std::cout, 4);
425 std::cout << std::endl;
426 std::cout <<
"call M.print (std::cout, 10, \"M\");" << std::endl;
427 M.print(std::cout, 10,
"M");
428 std::cout << std::endl;
429 std::cout <<
"call M.print (std::cout, 20, \"M\");" << std::endl;
430 M.print(std::cout, 20,
"M");
431 std::cout << std::endl;
433 std::cout <<
"------------------------" << std::endl;
434 std::cout <<
"--- TEST RESIZE --------" << std::endl;
435 std::cout <<
"------------------------" << std::endl;
436 std::cout <<
"5x5" << std::endl;
437 M.resize(5, 5,
false);
438 std::cout << M << std::endl;
439 std::cout <<
"3x2" << std::endl;
440 M.resize(3, 2,
false);
441 std::cout << M << std::endl;
442 std::cout <<
"2x2" << std::endl;
443 M.resize(2, 2,
false);
444 std::cout << M << std::endl;
445 std::cout <<
"------------------------" << std::endl;
454 std::cout <<
"------------------------" << std::endl;
455 std::cout <<
"--- TEST vpRowVector * vpColVector" << std::endl;
456 std::cout <<
"------------------------" << std::endl;
469 r.print(std::cout, 2,
"r");
470 c.print(std::cout, 2,
"c");
471 std::cout <<
"r * c = " << rc << std::endl;
473 std::cout <<
"------------------------" << std::endl;
474 std::cout <<
"--- TEST vpRowVector * vpMatrix" << std::endl;
475 std::cout <<
"------------------------" << std::endl;
484 r.
print(std::cout, 2,
"r");
485 M.print(std::cout, 10,
"M");
486 std::cout <<
"r * M = " << rM << std::endl;
488 std::cout <<
"------------------------" << std::endl;
489 std::cout <<
"--- TEST vpGEMM " << std::endl;
490 std::cout <<
"------------------------" << std::endl;
505 vpGEMM(M, N, 2, C, 3, D, VP_GEMM_A_T);
506 std::cout << D << std::endl;
510 std::cout <<
"------------------------" << std::endl;
511 std::cout <<
"--- TEST vpMatrix insert() with same colNum " << std::endl;
512 std::cout <<
"------------------------" << std::endl;
513 const unsigned int nb = ctest ? 10 : 100;
514 const unsigned int size = ctest ? 10 : 100;
517 std::vector<vpMatrix> submatrices(nb);
518 for (
size_t cpt = 0; cpt < submatrices.size(); cpt++) {
521 for (
unsigned int i = 0; i < m.getRows(); i++) {
522 for (
unsigned int j = 0; j < m.getCols(); j++) {
523 m[i][j] = getRandomValues(-100.0, 100.0);
527 submatrices[cpt] = m;
531 for (
unsigned int i = 0; i < nb; i++) {
532 m_big.insert(submatrices[(
size_t)i], i * size, 0);
535 std::cout <<
"Matrix insert(): " << t <<
" ms" << std::endl;
537 for (
unsigned int cpt = 0; cpt < nb; cpt++) {
538 for (
unsigned int i = 0; i < size; i++) {
539 for (
unsigned int j = 0; j < 6; j++) {
540 if (!
vpMath::equal(m_big[cpt * size + i][j], submatrices[(
size_t)cpt][i][j],
541 std::numeric_limits<double>::epsilon())) {
542 std::cerr <<
"Problem with vpMatrix insert()!" << std::endl;
554 std::cout <<
"Insert empty matrices:" << std::endl;
555 std::cout <<
"m1:\n" << m1 << std::endl;
556 std::cout <<
"m2:\n" << m2 << std::endl;
557 std::cout <<
"m3:\n" << m3 << std::endl;
559 std::cout <<
"\n------------------------" << std::endl;
560 std::cout <<
"--- TEST vpMatrix stack()" << std::endl;
561 std::cout <<
"------------------------" << std::endl;
567 std::cout <<
"L:\n" << L << std::endl;
571 std::cout <<
"L:\n" << L << std::endl;
577 for (
unsigned int i = 0; i < nb; i++) {
578 m_big_stack.
stack(submatrices[(
size_t)i]);
581 std::cout <<
"Matrix stack(): " << t <<
" ms" << std::endl;
583 if (!equalMatrix(m_big, m_big_stack)) {
584 std::cerr <<
"Problem with vpMatrix stack()!" << std::endl;
589 std::cout <<
"\n------------------------" << std::endl;
590 std::cout <<
"--- TEST vpMatrix stack(vpRowVector)" << std::endl;
591 std::cout <<
"------------------------" << std::endl;
593 vpMatrix m_big_stack = generateRandomMatrix(10000, ctest ? 10 : 100, -1000.0, 1000.0);
594 std::cout <<
"m_big_stack: " << m_big_stack.
getRows() <<
"x" << m_big_stack.
getCols() << std::endl;
598 for (
unsigned int i = 0; i < m_big_stack.
getRows(); i++) {
602 std::cout <<
"Matrix stack(vpRowVector): " << t <<
" ms" << std::endl;
604 if (!equalMatrix(m_big_stack, m_big_stack_row)) {
605 std::cerr <<
"Problem with vpMatrix stack(vpRowVector)!" << std::endl;
609 std::cout <<
"\n------------------------" << std::endl;
610 std::cout <<
"--- TEST vpMatrix stack(vpColVector)" << std::endl;
611 std::cout <<
"------------------------" << std::endl;
615 for (
unsigned int j = 0; j < m_big_stack.
getCols(); j++) {
619 std::cout <<
"Matrix stack(vpColVector): " << t <<
" ms" << std::endl;
621 if (!equalMatrix(m_big_stack, m_big_stack_col)) {
622 std::cerr <<
"Problem with vpMatrix stack(vpColVector)!" << std::endl;
626 std::cout <<
"\n------------------------" << std::endl;
627 std::cout <<
"--- TEST vpMatrix::stack()" << std::endl;
628 std::cout <<
"------------------------" << std::endl;
634 std::cout <<
"L:\n" << L << std::endl;
639 std::cout <<
"L:\n" << L << std::endl;
643 vpMatrix m_big_stack_static, m_big_stack_static_tmp;
645 for (
unsigned int i = 0; i < nb; i++) {
646 vpMatrix::stack(m_big_stack_static_tmp, submatrices[(
size_t)i], m_big_stack_static);
647 m_big_stack_static_tmp = m_big_stack_static;
650 std::cout <<
"Matrix::stack(): " << t <<
" ms" << std::endl;
652 if (!equalMatrix(m_big, m_big_stack_static)) {
653 std::cerr <<
"Problem with vpMatrix::stack()!" << std::endl;
658 std::cout <<
"\n------------------------" << std::endl;
659 std::cout <<
"--- TEST vpMatrix::stack(vpMatrix, vpRowVector, vpMatrix)" << std::endl;
660 std::cout <<
"------------------------" << std::endl;
662 vpMatrix m_big_stack_static = generateRandomMatrix(ctest ? 100 : 1000, ctest ? 10 : 100, -1000.0, 1000.0);
663 std::cout <<
"m_big_stack_static: " << m_big_stack_static.
getRows() <<
"x" << m_big_stack_static.
getCols() << std::endl;
665 vpMatrix m_big_stack_static_row, m_big_stack_static_row_tmp;
667 for (
unsigned int i = 0; i < m_big_stack_static.
getRows(); i++) {
669 m_big_stack_static_row_tmp = m_big_stack_static_row;
672 std::cout <<
"Matrix::stack(vpMatrix, vpRowVector, vpMatrix): " << t <<
" ms" << std::endl;
674 if (!equalMatrix(m_big_stack_static, m_big_stack_static_row)) {
675 std::cerr <<
"Problem with vpMatrix::stack(vpMatrix, vpRowVector, " 681 std::cout <<
"\n------------------------" << std::endl;
682 std::cout <<
"--- TEST vpMatrix::stack(vpMatrix, vpColVector, vpMatrix)" << std::endl;
683 std::cout <<
"------------------------" << std::endl;
685 vpMatrix m_big_stack_static_col, m_big_stack_static_col_tmp;
687 for (
unsigned int j = 0; j < m_big_stack_static.
getCols(); j++) {
689 m_big_stack_static_col_tmp = m_big_stack_static_col;
692 std::cout <<
"Matrix::stack(vpMatrix, vpColVector, vpMatrix): " << t <<
" ms" << std::endl;
694 if (!equalMatrix(m_big_stack_static, m_big_stack_static_col)) {
695 std::cerr <<
"Problem with vpMatrix::stack(vpMatrix, vpColVector, " 704 for (
unsigned int i = 0; i < m2.
getRows(); i++) {
705 for (
unsigned int j = 0; j < m2.
getCols(); j++) {
706 m2[i][j] = getRandomValues(-100.0, 100.0);
710 unsigned int offset_i = 4, offset_j = 3;
711 m1.insert(m2, offset_i, offset_j);
713 for (
unsigned int i = 0; i < m2.
getRows(); i++) {
714 for (
unsigned int j = 0; j < m2.
getCols(); j++) {
715 if (!
vpMath::equal(m1[i + offset_i][j + offset_j], m2[i][j], std::numeric_limits<double>::epsilon())) {
716 std::cerr <<
"Problem with vpMatrix insert()!" << std::endl;
722 offset_i = 4, offset_j = 5;
723 m1.insert(m2, offset_i, offset_j);
725 for (
unsigned int i = 0; i < m2.
getRows(); i++) {
726 for (
unsigned int j = 0; j < m2.
getCols(); j++) {
727 if (!
vpMath::equal(m1[i + offset_i][j + offset_j], m2[i][j], std::numeric_limits<double>::epsilon())) {
728 std::cerr <<
"Problem with vpMatrix insert()!" << std::endl;
734 offset_i = 8, offset_j = 5;
735 m1.insert(m2, offset_i, offset_j);
737 for (
unsigned int i = 0; i < m2.
getRows(); i++) {
738 for (
unsigned int j = 0; j < m2.
getCols(); j++) {
739 if (!
vpMath::equal(m1[i + offset_i][j + offset_j], m2[i][j], std::numeric_limits<double>::epsilon())) {
740 std::cerr <<
"Problem with vpMatrix insert()!" << std::endl;
748 std::cout <<
"\n------------------------" << std::endl;
749 std::cout <<
"--- TEST vpMatrix::juxtaposeMatrices()" << std::endl;
750 std::cout <<
"------------------------" << std::endl;
753 for (
unsigned int i = 0; i < A.
getRows(); i++) {
754 for (
unsigned int j = 0; j < A.
getCols(); j++) {
758 B[i][j] = (i * B.
getCols() + j) * 10;
765 std::cout <<
"juxtaposeM:\n" << juxtaposeM << std::endl;
768 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) 770 std::cout <<
"\n------------------------" << std::endl;
771 std::cout <<
"--- BENCHMARK dgemm/dgemv" << std::endl;
772 std::cout <<
"------------------------" << std::endl;
774 size_t nb_matrices = ctest ? 100 : 10000;
775 unsigned int rows = 200, cols = 6;
776 double min = -1.0, max = 1.0;
777 std::vector<vpMatrix> vec_A, vec_B, vec_C, vec_C_regular;
778 vec_C.reserve(nb_matrices);
779 vec_C_regular.reserve(nb_matrices);
781 for (
size_t i = 0; i < nb_matrices; i++) {
782 vec_A.push_back(generateRandomMatrix(cols, rows, min, max));
783 vec_B.push_back(generateRandomMatrix(rows, cols, min, max));
787 for (
size_t i = 0; i < nb_matrices; i++) {
788 vec_C.push_back(vec_A[i] * vec_B[i]);
791 std::cout << nb_matrices <<
" matrix multiplication: (6x200) x (200x6)" << std::endl;
792 std::cout <<
"Lapack: " << t <<
" ms" << std::endl;
793 std::cout <<
"vec_C:\n" << vec_C.back() << std::endl;
796 for (
size_t i = 0; i < nb_matrices; i++) {
797 vec_C_regular.push_back(dgemm_regular(vec_A[i], vec_B[i]));
800 std::cout <<
"\nRegular: " << t <<
" ms" << std::endl;
801 std::cout <<
"vec_C_regular:\n" << vec_C_regular.back() << std::endl;
803 vpMatrix A = generateRandomMatrix(480, 640, min, max), B = generateRandomMatrix(640, 480, min, max);
809 std::cout <<
"\nMatrix multiplication: (480x640) x (640x480)" << std::endl;
810 std::cout <<
"Lapack: " << t <<
" ms" << std::endl;
814 AB_regular = dgemm_regular(A, B);
816 std::cout <<
"Regular: " << t <<
" ms" << std::endl;
818 bool res = equalMatrix(AB, AB_regular, 1e-9);
819 std::cout <<
"Check result: " << res << std::endl;
821 std::cerr <<
"Problem with matrix multiplication!" << std::endl;
825 int nb_iterations = 1000;
826 vpMatrix L = generateRandomMatrix(1000, 6, min, max);
830 for (
int i = 0; i < nb_iterations; i++)
833 std::cout <<
"\n" << nb_iterations <<
" iterations of AtA for size: (1000x6)" << std::endl;
834 std::cout <<
"Lapack: " << t <<
" ms" << std::endl;
835 std::cout <<
"LTL:\n" << LTL << std::endl;
838 for (
int i = 0; i < nb_iterations; i++)
839 LTL_regular = AtA_regular(L);
841 std::cout <<
"\nRegular: " << t <<
" ms" << std::endl;
842 std::cout <<
"LTL_regular:\n" << LTL_regular << std::endl;
843 res = equalMatrix(LTL, LTL_regular, 1e-9);
844 std::cout <<
"Check result: " << res << std::endl;
846 std::cerr <<
"Problem with vpMatrix::AtA()!" << std::endl;
850 vpMatrix LT = generateRandomMatrix(6, 1000, min, max);
851 vpColVector R = generateRandomVector(1000, min, max);
855 for (
int i = 0; i < nb_iterations; i++)
860 <<
" iterations of matrix vector multiplication: (6x1000) x " 863 std::cout <<
"Lapack: " << t <<
" ms" << std::endl;
864 std::cout <<
"LTR:\n" << LTR.
t() << std::endl;
867 for (
int i = 0; i < nb_iterations; i++)
868 LTR_regular = dgemv_regular(LT, R);
870 std::cout <<
"\nRegular: " << t <<
" ms" << std::endl;
871 std::cout <<
"LTR_regular:\n" << LTR_regular.
t() << std::endl;
872 res = equalMatrix(LTR, LTR_regular, 1e-9);
873 std::cout <<
"Check result: " << res << std::endl;
875 std::cerr <<
"Problem with dgemv!" << std::endl;
879 vpVelocityTwistMatrix V(getRandomValues(min, max), getRandomValues(min, max), getRandomValues(min, max),
880 getRandomValues(min, max), getRandomValues(min, max), getRandomValues(min, max));
884 for (
int i = 0; i < nb_iterations; i++)
889 <<
" iterations of matrix velocity twist matrix " 890 "multiplication: (1000x6) x (6x6)" 892 std::cout <<
"Lapack: " << t <<
" ms" << std::endl;
895 for (
int i = 0; i < nb_iterations; i++)
896 LV_regular = mat_mul_twist_matrix(L, V);
898 std::cout <<
"Regular: " << t <<
" ms" << std::endl;
899 res = equalMatrix(LV, LV_regular, 1e-9);
900 std::cout <<
"Check result: " << res << std::endl;
902 std::cerr <<
"Problem with matrix and velocity twist matrix multiplication!" << std::endl;
908 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 910 std::vector<vpMatrix> vec_mat;
911 vec_mat.emplace_back(5, 5);
917 std::cout <<
"\n1) A+B:\n" << res << std::endl;
921 std::cout <<
"\n2) A+B:\n" << res2 << std::endl;
926 std::cout <<
"\n------------------------" << std::endl;
927 std::cout <<
"--- TEST vpMatrix::hadamard()" << std::endl;
928 std::cout <<
"------------------------" << std::endl;
931 for (
unsigned int i = 0; i < M1.
size(); i++) {
936 std::cout <<
"M1:\n" << M1 << std::endl;
937 std::cout <<
"\nM2:\n" << M2 << std::endl;
939 std::cout <<
"\nRes:\n" << M2 << std::endl;
942 std::cout <<
"\nAll tests succeed" << std::endl;
945 std::cout <<
"Catch an exception: " << e << std::endl;
Implementation of a matrix and operations on matrices.
static vpMatrix juxtaposeMatrices(const vpMatrix &A, const vpMatrix &B)
static bool loadMatrix(const std::string &filename, vpArray2D< double > &M, const bool binary=false, char *header=NULL)
Implementation of row vector and the associated operations.
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true, const bool recopy_=true)
static bool equal(double x, double y, double s=0.001)
void stack(const vpMatrix &A)
error that can be emited by ViSP classes.
Type * data
Address of the first element of the data array.
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getCols() const
VISP_EXPORT double measureTimeMs()
Implementation of a rotation matrix and operations on such kind of matrices.
vpRowVector getRow(const unsigned int i) const
void init(const vpMatrix &M, unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols)
void insert(const vpMatrix &A, const unsigned int r, const unsigned int c)
vpColVector getCol(const unsigned int j) const
unsigned int getRows() const
int print(std::ostream &s, unsigned int length, char const *intro=0) const
static double rad(double deg)
void resize(const unsigned int i, const bool flagNullify=true)
void vpGEMM(const vpArray2D< double > &A, const vpArray2D< double > &B, const double &alpha, const vpArray2D< double > &C, const double &beta, vpArray2D< double > &D, const unsigned int &ops=0)
Implementation of column vector and the associated operations.
int print(std::ostream &s, unsigned int length, char const *intro=0) const
static bool saveMatrixYAML(const std::string &filename, const vpArray2D< double > &M, const char *header="")
static bool saveMatrix(const std::string &filename, const vpArray2D< double > &M, const bool binary=false, const char *header="")
void resize(const unsigned int i, const bool flagNullify=true)
static bool loadMatrixYAML(const std::string &filename, vpArray2D< double > &M, char *header=NULL)
vpMatrix hadamard(const vpMatrix &m) const