55 #include <visp3/core/vpConfig.h> 58 #include <gsl/gsl_linalg.h> 61 #include <visp3/core/vpCPUFeatures.h> 62 #include <visp3/core/vpColVector.h> 63 #include <visp3/core/vpDebug.h> 64 #include <visp3/core/vpException.h> 65 #include <visp3/core/vpMath.h> 66 #include <visp3/core/vpMatrix.h> 67 #include <visp3/core/vpTranslationVector.h> 69 #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) 70 #include <emmintrin.h> 71 #define VISP_HAVE_SSE2 1 75 #include <immintrin.h> 76 #define VISP_HAVE_AVX 1 81 void transpose4x4(
const vpMatrix& a,
vpMatrix& b,
unsigned int i,
unsigned int j)
83 __m256d a0 = _mm256_loadu_pd(&a[i][j]);
84 __m256d a1 = _mm256_loadu_pd(&a[i + 1][j]);
85 __m256d a2 = _mm256_loadu_pd(&a[i + 2][j]);
86 __m256d a3 = _mm256_loadu_pd(&a[i + 3][j]);
88 __m256d T0 = _mm256_shuffle_pd(a0, a1, 15);
89 __m256d T1 = _mm256_shuffle_pd(a0, a1, 0);
90 __m256d T2 = _mm256_shuffle_pd(a2, a3, 15);
91 __m256d T3 = _mm256_shuffle_pd(a2, a3, 0);
93 a1 = _mm256_permute2f128_pd(T0, T2, 32);
94 a3 = _mm256_permute2f128_pd(T0, T2, 49);
95 a0 = _mm256_permute2f128_pd(T1, T3, 32);
96 a2 = _mm256_permute2f128_pd(T1, T3, 49);
98 _mm256_storeu_pd(&b[j][i], a0);
99 _mm256_storeu_pd(&b[j + 1][i], a1);
100 _mm256_storeu_pd(&b[j + 2][i], a2);
101 _mm256_storeu_pd(&b[j + 3][i], a3);
104 void transpose16x16(
const vpMatrix& a,
vpMatrix& b,
unsigned int i,
unsigned int j)
106 transpose4x4(a, b, i, j);
107 transpose4x4(a, b, i, j + 4);
108 transpose4x4(a, b, i, j + 8);
109 transpose4x4(a, b, i, j + 12);
111 transpose4x4(a, b, i + 4, j);
112 transpose4x4(a, b, i + 4, j + 4);
113 transpose4x4(a, b, i + 4, j + 8);
114 transpose4x4(a, b, i + 4, j + 12);
116 transpose4x4(a, b, i + 8, j);
117 transpose4x4(a, b, i + 8, j + 4);
118 transpose4x4(a, b, i + 8, j + 8);
119 transpose4x4(a, b, i + 8, j + 12);
121 transpose4x4(a, b, i + 12, j);
122 transpose4x4(a, b, i + 12, j + 4);
123 transpose4x4(a, b, i + 12, j + 8);
124 transpose4x4(a, b, i + 12, j + 12);
133 unsigned int ncols,
unsigned int nrows_orig,
unsigned int ncols_orig,
double svThreshold,
137 a1.
resize(ncols, nrows,
false,
false);
141 for (
unsigned int i = 0; i < ncols; i++) {
142 if (fabs(sv[i]) > maxsv)
148 for (
unsigned int i = 0; i < ncols; i++) {
149 if (fabs(sv[i]) > maxsv * svThreshold) {
153 for (
unsigned int j = 0; j < nrows; j++) {
156 for (
unsigned int k = 0; k < ncols; k++) {
157 if (fabs(sv[k]) > maxsv * svThreshold) {
158 a1[i][j] += v[i][k] * a[j][k] / sv[k];
163 if (nrows_orig >= ncols_orig)
170 unsigned int ncols_orig,
double svThreshold,
vpMatrix &Ap,
unsigned int &rank,
173 Ap.
resize(ncols_orig, nrows_orig,
true);
176 double maxsv = fabs(sv[0]);
180 for (
unsigned int i = 0; i < ncols_orig; i++) {
181 if (fabs(sv[i]) > maxsv * svThreshold) {
185 for (
unsigned int j = 0; j < nrows_orig; j++) {
188 for (
unsigned int k = 0; k < ncols_orig; k++) {
189 if (fabs(sv[k]) > maxsv * svThreshold) {
190 Ap[i][j] += V[i][k] * U[j][k] / sv[k];
197 imA.
resize(nrows_orig, rank);
198 imAt.
resize(ncols_orig, rank);
200 for (
unsigned int i = 0; i < nrows_orig; i++) {
201 for (
unsigned int j = 0; j < rank; j++) {
206 for (
unsigned int i = 0; i < ncols_orig; i++) {
207 for (
unsigned int j = 0; j < rank; j++) {
208 imAt[i][j] = V[i][j];
212 kerAt.
resize(ncols_orig - rank, ncols_orig);
213 if (rank != ncols_orig) {
214 for (
unsigned int j = 0, k = 0; j < ncols_orig; j++) {
216 if ((fabs(sv[j]) <= maxsv * svThreshold) &&
217 (std::fabs(V.
getCol(j).
sumSquare()) > std::numeric_limits<double>::epsilon())) {
218 for (
unsigned int i = 0; i < V.
getRows(); i++) {
219 kerAt[k][i] = V[i][j];
235 if (((r + nrows) > M.
rowNum) || ((c + ncols) > M.
colNum)) {
237 "Cannot construct a sub matrix (%dx%d) starting at " 238 "position (%d,%d) that is not contained in the " 239 "original matrix (%dx%d)",
243 init(M, r, c, nrows, ncols);
246 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 314 vpMatrix::vpMatrix(
unsigned int nrows,
unsigned int ncols,
const std::initializer_list<double> &list)
315 :
vpArray2D<double>(nrows, ncols, list) {}
391 unsigned int rnrows = r + nrows;
392 unsigned int cncols = c + ncols;
400 resize(nrows, ncols,
false,
false);
404 for (
unsigned int i = 0; i < nrows; i++) {
405 memcpy((*
this)[i], &M[i + r][c], ncols *
sizeof(
double));
452 unsigned int rnrows = r + nrows;
453 unsigned int cncols = c + ncols;
463 M.
resize(nrows, ncols,
false,
false);
464 for (
unsigned int i = 0; i < nrows; i++) {
465 memcpy(M[i], &(*
this)[i + r][c], ncols *
sizeof(
double));
494 for (
unsigned int i = 0; i <
rowNum; i++) {
495 for (
unsigned int j = 0; j <
colNum; j++) {
534 for (
unsigned int i = 0; i <
rowNum; i++) {
535 for (
unsigned int j = 0; j <
colNum; j++) {
536 At[j][i] = (*this)[i][j];
549 const int nrows =
static_cast<int>(
rowNum);
550 const int ncols =
static_cast<int>(
colNum);
551 const int tileSize = 16;
553 for (
int i = 0; i < nrows;) {
554 for (; i <= nrows - tileSize; i += tileSize) {
556 for (; j <= ncols - tileSize; j += tileSize) {
557 transpose16x16(*
this, At, i, j);
560 for (
int k = i; k < i + tileSize; k++) {
561 for (
int l = j; l < ncols; l++) {
562 At[l][k] = (*this)[k][l];
567 for (; i < nrows; i++) {
568 for (
int j = 0; j < ncols; j++) {
569 At[j][i] = (*this)[i][j];
578 const int tileSize = 32;
579 for (
unsigned int i = 0; i <
rowNum; i += tileSize) {
580 for (
unsigned int j = 0; j <
colNum; j++) {
581 for (
unsigned int b = 0; b < static_cast<unsigned int>(tileSize) && i + b < rowNum; b++) {
582 At[j][i + b] = (*this)[i + b][j];
621 for (
unsigned int i = 0; i <
rowNum; i++) {
622 for (
unsigned int j = i; j <
rowNum; j++) {
628 for (
unsigned int k = 0; k <
colNum; k++)
629 ssum += *(pi++) * *(pj++);
654 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) 660 vpMatrix::blas_dgemm(transa, transb,
colNum,
colNum,
rowNum, alpha,
data,
colNum,
data,
colNum, beta, B.
data,
colNum);
662 unsigned int i, j, k;
665 for (i = 0; i <
colNum; i++) {
667 for (j = 0; j < i; j++) {
670 for (k = 0; k <
rowNum; k++) {
671 s += (*(ptr + i)) * (*(ptr + j));
679 for (k = 0; k <
rowNum; k++) {
680 s += (*(ptr + i)) * (*(ptr + i));
729 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 743 if (
this != &other) {
755 other.rowPtrs = NULL;
789 if (
dsize != static_cast<unsigned int>(list.size())) {
790 resize(1, static_cast<unsigned int>(list.size()),
false,
false);
793 std::copy(list.begin(), list.end(),
data);
823 unsigned int nrows =
static_cast<unsigned int>(lists.size()), ncols = 0;
824 for (
auto& l : lists) {
825 if (static_cast<unsigned int>(l.size()) > ncols) {
826 ncols =
static_cast<unsigned int>(l.size());
830 resize(nrows, ncols,
false,
false);
831 auto it = lists.begin();
832 for (
unsigned int i = 0; i <
rowNum; i++, ++it) {
833 std::copy(it->begin(), it->end(),
rowPtrs[i]);
854 for (
unsigned int i = 0; i <
rowNum; i++) {
855 for (
unsigned int j = 0; j <
colNum; j++) {
864 resize(1, 1,
false,
false);
913 unsigned int rows = A.
getRows();
917 for (
unsigned int i = 0; i < rows; i++)
918 (*
this)[i][i] = A[i];
955 for (
unsigned int i = 0; i < min_; i++)
972 unsigned int rows = A.
getRows();
973 DA.
resize(rows, rows,
true);
975 for (
unsigned int i = 0; i < rows; i++)
992 for (
unsigned int j = 0; j < 3; j++)
995 for (
unsigned int j = 0; j < 3; j++) {
997 for (
unsigned int i = 0; i < 3; i++) {
998 t_out[i] +=
rowPtrs[i][j] * tj;
1033 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) 1039 vpMatrix::blas_dgemv(trans, A.
colNum, A.
rowNum, alpha, A.
data, A.
colNum, v.
data, incr, beta, w.
data, incr);
1042 for (
unsigned int j = 0; j < A.
colNum; j++) {
1044 for (
unsigned int i = 0; i < A.
rowNum; i++) {
1074 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) 1079 vpMatrix::blas_dgemm(trans, trans, B.
colNum, A.
rowNum, A.
colNum, alpha, B.
data, B.
colNum, A.
data, A.
colNum, beta,
1083 unsigned int BcolNum = B.
colNum;
1084 unsigned int BrowNum = B.
rowNum;
1085 unsigned int i, j, k;
1086 double **BrowPtrs = B.
rowPtrs;
1087 for (i = 0; i < A.
rowNum; i++) {
1088 double *rowptri = A.
rowPtrs[i];
1090 for (j = 0; j < BcolNum; j++) {
1092 for (k = 0; k < BrowNum; k++)
1093 s += rowptri[k] * BrowPtrs[k][j];
1117 "Cannot multiply (%dx%d) matrix by (%dx%d) matrix as a " 1123 unsigned int BcolNum = B.
colNum;
1124 unsigned int BrowNum = B.
rowNum;
1125 unsigned int i, j, k;
1126 double **BrowPtrs = B.
rowPtrs;
1127 for (i = 0; i < A.
rowNum; i++) {
1128 double *rowptri = A.
rowPtrs[i];
1130 for (j = 0; j < BcolNum; j++) {
1132 for (k = 0; k < BrowNum; k++)
1133 s += rowptri[k] * BrowPtrs[k][j];
1156 "Cannot multiply (%dx%d) matrix by (%dx%d) matrix as a " 1162 unsigned int BcolNum = B.
colNum;
1163 unsigned int BrowNum = B.
rowNum;
1164 unsigned int i, j, k;
1165 double **BrowPtrs = B.
rowPtrs;
1166 for (i = 0; i < A.
rowNum; i++) {
1167 double *rowptri = A.
rowPtrs[i];
1169 for (j = 0; j < BcolNum; j++) {
1171 for (k = 0; k < BrowNum; k++)
1172 s += rowptri[k] * BrowPtrs[k][j];
1221 unsigned int RcolNum = R.
getCols();
1222 unsigned int RrowNum = R.
getRows();
1223 for (
unsigned int i = 0; i <
rowNum; i++) {
1226 for (
unsigned int j = 0; j < RcolNum; j++) {
1228 for (
unsigned int k = 0; k < RrowNum; k++)
1229 s += rowptri[k] * R[k][j];
1249 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) 1254 vpMatrix::blas_dgemm(trans, trans, V.
colNum,
rowNum,
colNum, alpha, V.
data, V.
colNum,
data,
colNum, beta, M.
data,
1265 V_trans.
resize(6, 6,
false,
false);
1266 for (
unsigned int i = 0; i < 6; i++) {
1267 for (
unsigned int j = 0; j < 6; j++) {
1268 V_trans[i][j] = V[j][i];
1272 for (
unsigned int i = 0; i <
rowNum; i++) {
1276 for (
int j = 0; j < 6; j++) {
1277 __m128d v_mul = _mm_setzero_pd();
1278 for (
int k = 0; k < 6; k += 2) {
1279 v_mul = _mm_add_pd(v_mul, _mm_mul_pd(_mm_loadu_pd(&rowptri[k]), _mm_loadu_pd(&V_trans[j][k])));
1283 _mm_storeu_pd(v_tmp, v_mul);
1284 ci[j] = v_tmp[0] + v_tmp[1];
1289 unsigned int VcolNum = V.
getCols();
1290 unsigned int VrowNum = V.
getRows();
1291 for (
unsigned int i = 0; i <
rowNum; i++) {
1294 for (
unsigned int j = 0; j < VcolNum; j++) {
1296 for (
unsigned int k = 0; k < VrowNum; k++)
1297 s += rowptri[k] * V[k][j];
1319 unsigned int VcolNum = V.
getCols();
1320 unsigned int VrowNum = V.
getRows();
1321 for (
unsigned int i = 0; i <
rowNum; i++) {
1324 for (
unsigned int j = 0; j < VcolNum; j++) {
1326 for (
unsigned int k = 0; k < VrowNum; k++)
1327 s += rowptri[k] * V[k][j];
1356 double **ArowPtrs = A.
rowPtrs;
1357 double **BrowPtrs = B.
rowPtrs;
1358 double **CrowPtrs = C.
rowPtrs;
1360 for (
unsigned int i = 0; i < A.
rowNum; i++)
1361 for (
unsigned int j = 0; j < A.
colNum; j++)
1362 CrowPtrs[i][j] = wB * BrowPtrs[i][j] + wA * ArowPtrs[i][j];
1384 double **ArowPtrs = A.
rowPtrs;
1385 double **BrowPtrs = B.
rowPtrs;
1386 double **CrowPtrs = C.
rowPtrs;
1388 for (
unsigned int i = 0; i < A.
rowNum; i++) {
1389 for (
unsigned int j = 0; j < A.
colNum; j++) {
1390 CrowPtrs[i][j] = BrowPtrs[i][j] + ArowPtrs[i][j];
1417 double **ArowPtrs = A.
rowPtrs;
1418 double **BrowPtrs = B.
rowPtrs;
1419 double **CrowPtrs = C.
rowPtrs;
1421 for (
unsigned int i = 0; i < A.
rowNum; i++) {
1422 for (
unsigned int j = 0; j < A.
colNum; j++) {
1423 CrowPtrs[i][j] = BrowPtrs[i][j] + ArowPtrs[i][j];
1464 double **ArowPtrs = A.
rowPtrs;
1465 double **BrowPtrs = B.
rowPtrs;
1466 double **CrowPtrs = C.
rowPtrs;
1468 for (
unsigned int i = 0; i < A.
rowNum; i++) {
1469 for (
unsigned int j = 0; j < A.
colNum; j++) {
1470 CrowPtrs[i][j] = ArowPtrs[i][j] - BrowPtrs[i][j];
1497 double **ArowPtrs = A.
rowPtrs;
1498 double **BrowPtrs = B.
rowPtrs;
1499 double **CrowPtrs = C.
rowPtrs;
1501 for (
unsigned int i = 0; i < A.
rowNum; i++) {
1502 for (
unsigned int j = 0; j < A.
colNum; j++) {
1503 CrowPtrs[i][j] = ArowPtrs[i][j] - BrowPtrs[i][j];
1528 double **BrowPtrs = B.
rowPtrs;
1530 for (
unsigned int i = 0; i <
rowNum; i++)
1531 for (
unsigned int j = 0; j <
colNum; j++)
1532 rowPtrs[i][j] += BrowPtrs[i][j];
1545 double **BrowPtrs = B.
rowPtrs;
1546 for (
unsigned int i = 0; i <
rowNum; i++)
1547 for (
unsigned int j = 0; j <
colNum; j++)
1548 rowPtrs[i][j] -= BrowPtrs[i][j];
1567 double **ArowPtrs = A.
rowPtrs;
1568 double **CrowPtrs = C.
rowPtrs;
1571 for (
unsigned int i = 0; i < A.
rowNum; i++)
1572 for (
unsigned int j = 0; j < A.
colNum; j++)
1573 CrowPtrs[i][j] = -ArowPtrs[i][j];
1590 for (
unsigned int i = 0; i <
rowNum; i++) {
1591 for (
unsigned int j = 0; j <
colNum; j++) {
1613 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
1617 unsigned int Brow = B.
getRows();
1618 unsigned int Bcol = B.
getCols();
1621 C.
resize(Brow, Bcol,
false,
false);
1623 for (
unsigned int i = 0; i < Brow; i++)
1624 for (
unsigned int j = 0; j < Bcol; j++)
1625 C[i][j] = B[i][j] * x;
1636 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
1643 for (
unsigned int i = 0; i <
rowNum; i++)
1644 for (
unsigned int j = 0; j <
colNum; j++)
1653 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
1657 if (std::fabs(x) < std::numeric_limits<double>::epsilon()) {
1664 double xinv = 1 / x;
1666 for (
unsigned int i = 0; i <
rowNum; i++)
1667 for (
unsigned int j = 0; j <
colNum; j++)
1668 C[i][j] =
rowPtrs[i][j] * xinv;
1676 for (
unsigned int i = 0; i <
rowNum; i++)
1677 for (
unsigned int j = 0; j <
colNum; j++)
1686 for (
unsigned int i = 0; i <
rowNum; i++)
1687 for (
unsigned int j = 0; j <
colNum; j++)
1699 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
1703 for (
unsigned int i = 0; i <
rowNum; i++)
1704 for (
unsigned int j = 0; j <
colNum; j++)
1713 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
1717 if (std::fabs(x) < std::numeric_limits<double>::epsilon())
1720 double xinv = 1 / x;
1722 for (
unsigned int i = 0; i <
rowNum; i++)
1723 for (
unsigned int j = 0; j <
colNum; j++)
1742 double *optr = out.
data;
1743 for (
unsigned int j = 0; j <
colNum; j++) {
1744 for (
unsigned int i = 0; i <
rowNum; i++) {
1802 for (; i <=
dsize - 2; i += 2) {
1803 __m128d vout = _mm_mul_pd(_mm_loadu_pd(
data + i), _mm_loadu_pd(m.
data + i));
1804 _mm_storeu_pd(out.
data + i, vout);
1809 for (; i <
dsize; i++) {
1824 unsigned int r1 = m1.
getRows();
1825 unsigned int c1 = m1.
getCols();
1826 unsigned int r2 = m2.
getRows();
1827 unsigned int c2 = m2.
getCols();
1829 out.
resize(r1*r2, c1*c2,
false,
false);
1831 for (
unsigned int r = 0; r < r1; r++) {
1832 for (
unsigned int c = 0; c < c1; c++) {
1833 double alpha = m1[r][c];
1834 double *m2ptr = m2[0];
1835 unsigned int roffset = r * r2;
1836 unsigned int coffset = c * c2;
1837 for (
unsigned int rr = 0; rr < r2; rr++) {
1838 for (
unsigned int cc = 0; cc < c2; cc++) {
1839 out[roffset + rr][coffset + cc] = alpha * *(m2ptr++);
1862 unsigned int r1 = m1.
getRows();
1863 unsigned int c1 = m1.
getCols();
1864 unsigned int r2 = m2.
getRows();
1865 unsigned int c2 = m2.
getCols();
1868 out.
resize(r1 * r2, c1 * c2,
false,
false);
1870 for (
unsigned int r = 0; r < r1; r++) {
1871 for (
unsigned int c = 0; c < c1; c++) {
1872 double alpha = m1[r][c];
1873 double *m2ptr = m2[0];
1874 unsigned int roffset = r * r2;
1875 unsigned int coffset = c * c2;
1876 for (
unsigned int rr = 0; rr < r2; rr++) {
1877 for (
unsigned int cc = 0; cc < c2; cc++) {
1878 out[roffset + rr][coffset + cc] = alpha * *(m2ptr++);
2068 #if defined(VISP_HAVE_LAPACK) 2070 #elif defined(VISP_HAVE_EIGEN3) 2072 #elif (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1 2074 #elif defined(VISP_HAVE_GSL) 2139 #if defined(VISP_HAVE_LAPACK) 2141 #elif defined(VISP_HAVE_EIGEN3) 2143 #elif (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1 2145 #elif defined(VISP_HAVE_GSL) 2151 "Install Lapack, Eigen3, OpenCV " 2152 "or GSL 3rd party"));
2208 #if defined(VISP_HAVE_LAPACK) 2210 #elif defined(VISP_HAVE_EIGEN3) 2212 #elif (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1 2214 #elif defined(VISP_HAVE_GSL) 2219 "Install Lapack, Eigen3, OpenCV " 2220 "or GSL 3rd party"));
2224 #ifndef DOXYGEN_SHOULD_SKIP_THIS 2225 #if defined(VISP_HAVE_LAPACK) 2264 unsigned int nrows, ncols;
2265 unsigned int nrows_orig =
getRows();
2266 unsigned int ncols_orig =
getCols();
2269 Ap.
resize(ncols_orig, nrows_orig,
false,
false);
2271 if (nrows_orig >= ncols_orig) {
2280 U.
resize(nrows, ncols,
false,
false);
2281 V.
resize(ncols, ncols,
false,
false);
2285 if (nrows_orig >= ncols_orig)
2293 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
2340 unsigned int nrows, ncols;
2341 unsigned int nrows_orig =
getRows();
2342 unsigned int ncols_orig =
getCols();
2345 Ap.
resize(ncols_orig, nrows_orig,
false,
false);
2347 if (nrows_orig >= ncols_orig) {
2356 U.
resize(nrows, ncols,
false,
false);
2357 V.
resize(ncols, ncols,
false,
false);
2361 if (nrows_orig >= ncols_orig)
2368 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
2421 unsigned int nrows, ncols;
2422 unsigned int nrows_orig =
getRows();
2423 unsigned int ncols_orig =
getCols();
2426 Ap.
resize(ncols_orig, nrows_orig,
false,
false);
2428 if (nrows_orig >= ncols_orig) {
2437 U.
resize(nrows, ncols,
false,
false);
2438 V.
resize(ncols, ncols,
false,
false);
2441 if (nrows_orig >= ncols_orig)
2448 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
2563 unsigned int nrows =
getRows();
2564 unsigned int ncols =
getCols();
2569 if (nrows < ncols) {
2570 U.
resize(ncols, ncols,
true);
2573 U.
resize(nrows, ncols,
false);
2580 compute_pseudo_inverse(U, sv_, V, nrows, ncols, svThreshold, Ap, rank, imA, imAt, kerA);
2584 for (
unsigned int i = 0; i < sv.
size(); i++)
2590 #if defined(VISP_HAVE_EIGEN3) 2629 unsigned int nrows, ncols;
2630 unsigned int nrows_orig =
getRows();
2631 unsigned int ncols_orig =
getCols();
2634 Ap.
resize(ncols_orig, nrows_orig,
false);
2636 if (nrows_orig >= ncols_orig) {
2645 U.
resize(nrows, ncols,
false);
2646 V.
resize(ncols, ncols,
false);
2650 if (nrows_orig >= ncols_orig)
2658 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
2705 unsigned int nrows, ncols;
2706 unsigned int nrows_orig =
getRows();
2707 unsigned int ncols_orig =
getCols();
2710 Ap.
resize(ncols_orig, nrows_orig,
false);
2712 if (nrows_orig >= ncols_orig) {
2721 U.
resize(nrows, ncols,
false);
2722 V.
resize(ncols, ncols,
false);
2726 if (nrows_orig >= ncols_orig)
2733 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
2786 unsigned int nrows, ncols;
2787 unsigned int nrows_orig =
getRows();
2788 unsigned int ncols_orig =
getCols();
2791 Ap.
resize(ncols_orig, nrows_orig,
false);
2793 if (nrows_orig >= ncols_orig) {
2802 U.
resize(nrows, ncols,
false);
2803 V.
resize(ncols, ncols,
false);
2806 if (nrows_orig >= ncols_orig)
2813 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
2928 unsigned int nrows =
getRows();
2929 unsigned int ncols =
getCols();
2934 if (nrows < ncols) {
2935 U.
resize(ncols, ncols,
true);
2938 U.
resize(nrows, ncols,
false);
2945 compute_pseudo_inverse(U, sv_, V, nrows, ncols, svThreshold, Ap, rank, imA, imAt, kerA);
2949 for (
unsigned int i = 0; i < sv.
size(); i++)
2955 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101) 2994 unsigned int nrows, ncols;
2995 unsigned int nrows_orig =
getRows();
2996 unsigned int ncols_orig =
getCols();
2999 Ap.
resize(ncols_orig, nrows_orig,
false);
3001 if (nrows_orig >= ncols_orig) {
3010 U.
resize(nrows, ncols,
false);
3011 V.
resize(ncols, ncols,
false);
3015 if (nrows_orig >= ncols_orig)
3023 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
3070 unsigned int nrows, ncols;
3071 unsigned int nrows_orig =
getRows();
3072 unsigned int ncols_orig =
getCols();
3075 Ap.
resize(ncols_orig, nrows_orig,
false);
3077 if (nrows_orig >= ncols_orig) {
3086 U.
resize(nrows, ncols,
false);
3087 V.
resize(ncols, ncols,
false);
3091 if (nrows_orig >= ncols_orig)
3098 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
3151 unsigned int nrows, ncols;
3152 unsigned int nrows_orig =
getRows();
3153 unsigned int ncols_orig =
getCols();
3156 Ap.
resize(ncols_orig, nrows_orig);
3158 if (nrows_orig >= ncols_orig) {
3167 U.
resize(nrows, ncols,
false);
3168 V.
resize(ncols, ncols,
false);
3171 if (nrows_orig >= ncols_orig)
3178 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
3293 unsigned int nrows =
getRows();
3294 unsigned int ncols =
getCols();
3299 if (nrows < ncols) {
3300 U.
resize(ncols, ncols,
true);
3303 U.
resize(nrows, ncols,
false);
3310 compute_pseudo_inverse(U, sv_, V, nrows, ncols, svThreshold, Ap, rank, imA, imAt, kerA);
3314 for (
unsigned int i = 0; i < sv.
size(); i++)
3320 #if defined(VISP_HAVE_GSL) 3359 unsigned int nrows, ncols;
3360 unsigned int nrows_orig =
getRows();
3361 unsigned int ncols_orig =
getCols();
3364 Ap.
resize(ncols_orig, nrows_orig,
false);
3366 if (nrows_orig >= ncols_orig) {
3375 U.
resize(nrows, ncols,
false);
3376 V.
resize(ncols, ncols,
false);
3380 if (nrows_orig >= ncols_orig)
3388 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
3435 unsigned int nrows, ncols;
3436 unsigned int nrows_orig =
getRows();
3437 unsigned int ncols_orig =
getCols();
3440 Ap.
resize(ncols_orig, nrows_orig,
false);
3442 if (nrows_orig >= ncols_orig) {
3451 U.
resize(nrows, ncols,
false);
3452 V.
resize(ncols, ncols,
false);
3456 if (nrows_orig >= ncols_orig)
3463 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
3516 unsigned int nrows, ncols;
3517 unsigned int nrows_orig =
getRows();
3518 unsigned int ncols_orig =
getCols();
3521 Ap.
resize(ncols_orig, nrows_orig,
false);
3523 if (nrows_orig >= ncols_orig) {
3532 U.
resize(nrows, ncols,
false);
3533 V.
resize(ncols, ncols,
false);
3536 if (nrows_orig >= ncols_orig)
3543 compute_pseudo_inverse(U, sv, V, nrows, ncols, nrows_orig, ncols_orig, svThreshold, Ap, rank);
3657 unsigned int nrows =
getRows();
3658 unsigned int ncols =
getCols();
3663 if (nrows < ncols) {
3664 U.
resize(ncols, ncols,
true);
3667 U.
resize(nrows, ncols,
false);
3674 compute_pseudo_inverse(U, sv_, V, nrows, ncols, svThreshold, Ap, rank, imA, imAt, kerA);
3678 for (
unsigned int i = 0; i < sv.
size(); i++)
3684 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 3749 #if defined(VISP_HAVE_LAPACK) 3751 #elif defined(VISP_HAVE_EIGEN3) 3753 #elif (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1 3755 #elif defined(VISP_HAVE_GSL) 3762 "Install Lapack, Eigen3, OpenCV " 3763 "or GSL 3rd party"));
3845 return pseudoInverse(Ap, sv, svThreshold, imA, imAt, kerAt);
3985 #if defined(VISP_HAVE_LAPACK) 3987 #elif defined(VISP_HAVE_EIGEN3) 3989 #elif (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1 3991 #elif defined(VISP_HAVE_GSL) 4001 "Install Lapack, Eigen3, OpenCV " 4002 "or GSL 3rd party"));
4052 for (
unsigned int i = 0; i < column_size; i++)
4053 c[i] = (*
this)[i_begin + i][j];
4186 if (r.
data != NULL &&
data != NULL) {
4187 memcpy(r.
data, (*
this)[i] + j_begin, row_size*
sizeof(
double));
4234 diag.
resize(min_size,
false);
4236 for (
unsigned int i = 0; i < min_size; i++) {
4237 diag[i] = (*this)[i][i];
4276 unsigned int nra = A.
getRows();
4277 unsigned int nrb = B.
getRows();
4287 std::cerr <<
"A and C must be two different objects!" << std::endl;
4292 std::cerr <<
"B and C must be two different objects!" << std::endl;
4298 if (C.
data != NULL && A.
data != NULL && A.
size() > 0) {
4303 if (C.
data != NULL && B.
data != NULL && B.
size() > 0) {
4340 std::cerr <<
"A and C must be two different objects!" << std::endl;
4379 std::cerr <<
"A and C must be two different objects!" << std::endl;
4426 for (
unsigned int i = 0; i < A.
getRows(); i++) {
4427 for (
unsigned int j = 0; j < A.
getCols(); j++) {
4428 if (i >= r && i < (r + B.
getRows()) && j >= c && j < (c + B.
getCols())) {
4429 C[i][j] = B[i - r][j - c];
4475 unsigned int nca = A.
getCols();
4476 unsigned int ncb = B.
getCols();
4485 if (B.
getRows() == 0 || nca + ncb == 0) {
4486 std::cerr <<
"B.getRows() == 0 || nca+ncb == 0" << std::endl;
4521 typedef std::string::size_type size_type;
4526 std::vector<std::string> values(m * n);
4527 std::ostringstream oss;
4528 std::ostringstream ossFixed;
4529 std::ios_base::fmtflags original_flags = oss.flags();
4532 ossFixed.setf(std::ios::fixed, std::ios::floatfield);
4534 size_type maxBefore = 0;
4535 size_type maxAfter = 0;
4537 for (
unsigned int i = 0; i < m; ++i) {
4538 for (
unsigned int j = 0; j < n; ++j) {
4540 oss << (*this)[i][j];
4541 if (oss.str().find(
"e") != std::string::npos) {
4543 ossFixed << (*this)[i][j];
4544 oss.str(ossFixed.str());
4547 values[i * n + j] = oss.str();
4548 size_type thislen = values[i * n + j].size();
4549 size_type p = values[i * n + j].find(
'.');
4551 if (p == std::string::npos) {
4561 size_type totalLength = length;
4565 maxAfter = (std::min)(maxAfter, totalLength - maxBefore);
4572 if (! intro.empty())
4574 s <<
"[" << m <<
"," << n <<
"]=\n";
4576 for (
unsigned int i = 0; i < m; i++) {
4578 for (
unsigned int j = 0; j < n; j++) {
4579 size_type p = values[i * n + j].find(
'.');
4580 s.setf(std::ios::right, std::ios::adjustfield);
4581 s.width((std::streamsize)maxBefore);
4582 s << values[i * n + j].substr(0, p).c_str();
4585 s.setf(std::ios::left, std::ios::adjustfield);
4586 if (p != std::string::npos) {
4587 s.width((std::streamsize)maxAfter);
4588 s << values[i * n + j].substr(p, maxAfter).c_str();
4590 assert(maxAfter > 1);
4591 s.width((std::streamsize)maxAfter);
4601 s.flags(original_flags);
4603 return (
int)(maxBefore + maxAfter);
4645 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
4646 for (
unsigned int j = 0; j < this->
getCols(); ++j) {
4647 os << (*this)[i][j] <<
", ";
4649 if (this->
getRows() != i + 1) {
4650 os <<
";" << std::endl;
4652 os <<
"]" << std::endl;
4688 os <<
"([ " << std::endl;
4689 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
4691 for (
unsigned int j = 0; j < this->
getCols(); ++j) {
4692 os << (*this)[i][j] <<
", ";
4694 os <<
"]," << std::endl;
4696 os <<
"])" << std::endl;
4729 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
4730 for (
unsigned int j = 0; j < this->
getCols(); ++j) {
4731 os << (*this)[i][j];
4732 if (!(j == (this->
getCols() - 1)))
4778 os <<
"vpMatrix " << matrixName <<
" (" << this->
getRows() <<
", " << this->
getCols() <<
"); " << std::endl;
4780 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
4781 for (
unsigned int j = 0; j < this->
getCols(); ++j) {
4783 os << matrixName <<
"[" << i <<
"][" << j <<
"] = " << (*this)[i][j] <<
"; " << std::endl;
4785 for (
unsigned int k = 0; k <
sizeof(double); ++k) {
4786 os <<
"((unsigned char*)&(" << matrixName <<
"[" << i <<
"][" << j <<
"]) )[" << k <<
"] = 0x" << std::hex
4787 << (
unsigned int)((
unsigned char *)&((*this)[i][j]))[k] <<
"; " << std::endl;
4810 unsigned int rowNumOld =
rowNum;
4841 if (r.
size() == 0) {
4845 unsigned int oldSize =
size();
4850 memcpy(
data + oldSize, r.
data,
sizeof(
double) * r.
size());
4881 if (c.
size() == 0) {
4886 unsigned int oldColNum =
colNum;
4891 for (
unsigned int i = 0; i <
rowNum; i++) {
4892 memcpy(
data + i*
colNum, tmp.
data + i*oldColNum,
sizeof(
double) * oldColNum);
4915 for (
unsigned int i = r; i < (r + A.
getRows()); i++) {
4970 #ifdef VISP_HAVE_GSL 4974 for (
unsigned int i = 0; i <
rowNum; i++) {
4975 for (
unsigned int j = 0; j <
rowNum; j++) {
4977 if (std::fabs(At_A[i][j]) > std::numeric_limits<double>::epsilon()) {
4985 gsl_vector *eval = gsl_vector_alloc(rowNum);
4986 gsl_matrix *evec = gsl_matrix_alloc(rowNum,
colNum);
4988 gsl_eigen_symmv_workspace *w = gsl_eigen_symmv_alloc(rowNum);
4989 gsl_matrix *m = gsl_matrix_alloc(rowNum,
colNum);
4991 unsigned int Atda = (
unsigned int)m->tda;
4992 for (
unsigned int i = 0; i <
rowNum; i++) {
4993 unsigned int k = i * Atda;
4994 for (
unsigned int j = 0; j <
colNum; j++)
4995 m->data[k + j] = (*
this)[i][j];
4997 gsl_eigen_symmv(m, eval, evec, w);
4999 gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_ASC);
5001 for (
unsigned int i = 0; i <
rowNum; i++) {
5002 evalue[i] = gsl_vector_get(eval, i);
5005 gsl_eigen_symmv_free(w);
5006 gsl_vector_free(eval);
5008 gsl_matrix_free(evec);
5015 "should install GSL rd party"));
5073 #ifdef VISP_HAVE_GSL 5084 #ifdef VISP_HAVE_GSL 5088 for (
unsigned int i = 0; i <
rowNum; i++) {
5089 for (
unsigned int j = 0; j <
rowNum; j++) {
5091 if (std::fabs(At_A[i][j]) > std::numeric_limits<double>::epsilon()) {
5099 evector.resize(rowNum,
colNum);
5101 gsl_vector *eval = gsl_vector_alloc(rowNum);
5102 gsl_matrix *evec = gsl_matrix_alloc(rowNum,
colNum);
5104 gsl_eigen_symmv_workspace *w = gsl_eigen_symmv_alloc(rowNum);
5105 gsl_matrix *m = gsl_matrix_alloc(rowNum,
colNum);
5107 unsigned int Atda = (
unsigned int)m->tda;
5108 for (
unsigned int i = 0; i <
rowNum; i++) {
5109 unsigned int k = i * Atda;
5110 for (
unsigned int j = 0; j <
colNum; j++)
5111 m->data[k + j] = (*
this)[i][j];
5113 gsl_eigen_symmv(m, eval, evec, w);
5115 gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_ASC);
5117 for (
unsigned int i = 0; i <
rowNum; i++) {
5118 evalue[i] = gsl_vector_get(eval, i);
5120 Atda = (
unsigned int)evec->tda;
5121 for (
unsigned int i = 0; i <
rowNum; i++) {
5122 unsigned int k = i * Atda;
5123 for (
unsigned int j = 0; j <
rowNum; j++) {
5124 evector[i][j] = evec->data[k + j];
5128 gsl_eigen_symmv_free(w);
5129 gsl_vector_free(eval);
5131 gsl_matrix_free(evec);
5136 "should install GSL rd party"));
5162 unsigned int nbline =
getRows();
5163 unsigned int nbcol =
getCols();
5168 V.
resize(nbcol, nbcol,
false);
5175 U.
resize(nbcol, nbcol,
true);
5177 U.
resize(nbline, nbcol,
false);
5185 for (
unsigned int i = 0; i < nbcol; i++) {
5186 if (fabs(sv[i]) > maxsv) {
5187 maxsv = fabs(sv[i]);
5191 unsigned int rank = 0;
5192 for (
unsigned int i = 0; i < nbcol; i++) {
5193 if (fabs(sv[i]) > maxsv * svThreshold) {
5198 kerAt.
resize(nbcol - rank, nbcol);
5199 if (rank != nbcol) {
5200 for (
unsigned int j = 0, k = 0; j < nbcol; j++) {
5202 if ((fabs(sv[j]) <= maxsv * svThreshold) &&
5203 (std::fabs(V.
getCol(j).
sumSquare()) > std::numeric_limits<double>::epsilon())) {
5204 for (
unsigned int i = 0; i < V.
getRows(); i++) {
5205 kerAt[k][i] = V[i][j];
5270 #ifdef VISP_HAVE_GSL 5272 double *b =
new double[size_];
5273 for (
size_t i = 0; i < size_; i++)
5275 gsl_matrix_view m = gsl_matrix_view_array(this->
data,
rowNum, colNum);
5276 gsl_matrix_view em = gsl_matrix_view_array(b,
rowNum, colNum);
5277 gsl_linalg_exponential_ss(&m.matrix, &em.matrix, 0);
5281 memcpy(expA.
data, b, size_ *
sizeof(
double));
5302 for (
unsigned int i = 0; i <
rowNum; i++) {
5304 for (
unsigned int j = 0; j <
colNum; j++) {
5305 sum += fabs((*
this)[i][j]);
5307 if (sum > nA || i == 0) {
5316 double sca = 1.0 / pow(2.0, s);
5319 _expE = c * exp + _eye;
5320 _expD = -c * exp + _eye;
5321 for (
int k = 2; k <= q; k++) {
5322 c = c * ((double)(q - k + 1)) / ((
double)(k * (2 * q - k + 1)));
5323 _expcX = exp * _expX;
5326 _expE = _expE + _expcX;
5328 _expD = _expD + _expcX;
5330 _expD = _expD - _expcX;
5334 exp = _expX * _expE;
5335 for (
int k = 1; k <= s; k++) {
5368 for (
unsigned int i = 0; i < col; i++) {
5369 for (
unsigned int j = 0; j <
row; j++)
5370 M_comp[i][j] = M[i][j];
5371 for (
unsigned int j = row + 1; j < M.
getRows(); j++)
5372 M_comp[i][j - 1] = M[i][j];
5374 for (
unsigned int i = col + 1; i < M.
getCols(); i++) {
5375 for (
unsigned int j = 0; j <
row; j++)
5376 M_comp[i - 1][j] = M[i][j];
5377 for (
unsigned int j = row + 1; j < M.
getRows(); j++)
5378 M_comp[i - 1][j - 1] = M[i][j];
5394 unsigned int nbline =
getRows();
5395 unsigned int nbcol =
getCols();
5400 V.
resize(nbcol, nbcol,
false);
5407 U.
resize(nbcol, nbcol,
true);
5409 U.
resize(nbline, nbcol,
false);
5417 for (
unsigned int i = 0; i < nbcol; i++) {
5418 if (fabs(sv[i]) > maxsv) {
5419 maxsv = fabs(sv[i]);
5424 unsigned int rank = 0;
5425 for (
unsigned int i = 0; i < nbcol; i++) {
5426 if (fabs(sv[i]) > maxsv * svThreshold) {
5432 double minsv = maxsv;
5433 for (
unsigned int i = 0; i < rank; i++) {
5434 if (fabs(sv[i]) < minsv) {
5435 minsv = fabs(sv[i]);
5439 if (std::fabs(minsv) > std::numeric_limits<double>::epsilon()) {
5440 return maxsv / minsv;
5443 return std::numeric_limits<double>::infinity();
5461 for (
unsigned int i = 0; i < H.
getCols(); i++) {
5462 HLM[i][i] += alpha * H[i][i];
5490 for (
unsigned int i = 0; i <
dsize; i++) {
5491 double x = *(
data + i);
5508 if(this->
dsize != 0){
5517 unsigned int maxRank = std::min(this->
getCols(), this->
getRows());
5520 unsigned int boundary = std::min(maxRank, w.
size());
5525 for (
unsigned int i = 0; i < boundary; i++) {
5550 for (
unsigned int i = 0; i <
rowNum; i++) {
5552 for (
unsigned int j = 0; j <
colNum; j++) {
5553 x += fabs(*(*(
rowPtrs + i) + j));
5570 double sum_square = 0.0;
5573 for (
unsigned int i = 0; i <
rowNum; i++) {
5574 for (
unsigned int j = 0; j <
colNum; j++) {
5576 sum_square += x * x;
5597 conv2(M, kernel, res, mode);
5618 if (mode ==
"valid") {
5625 if (mode ==
"full" || mode ==
"same") {
5626 const unsigned int pad_x = kernel.
getCols()-1;
5627 const unsigned int pad_y = kernel.
getRows()-1;
5629 M_padded.
insert(M, pad_y, pad_x);
5631 if (mode ==
"same") {
5637 }
else if (mode ==
"valid") {
5644 if (mode ==
"same") {
5645 for (
unsigned int i = 0; i < res_same.
getRows(); i++) {
5646 for (
unsigned int j = 0; j < res_same.
getCols(); j++) {
5647 for (
unsigned int k = 0; k < kernel.
getRows(); k++) {
5648 for (
unsigned int l = 0; l < kernel.
getCols(); l++) {
5649 res_same[i][j] += M_padded[i+k][j+l] * kernel[kernel.
getRows()-k-1][kernel.
getCols()-l-1];
5655 const unsigned int start_i = kernel.
getRows()/2;
5656 const unsigned int start_j = kernel.
getCols()/2;
5657 for (
unsigned int i = 0; i < M.
getRows(); i++) {
5661 for (
unsigned int i = 0; i < res.
getRows(); i++) {
5662 for (
unsigned int j = 0; j < res.
getCols(); j++) {
5663 for (
unsigned int k = 0; k < kernel.
getRows(); k++) {
5664 for (
unsigned int l = 0; l < kernel.
getCols(); l++) {
5665 res[i][j] += M_padded[i+k][j+l] * kernel[kernel.
getRows()-k-1][kernel.
getCols()-l-1];
5673 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 5710 for (
unsigned int j = 0; j <
getCols(); j++)
5711 c[j] = (*
this)[i - 1][j];
5736 for (
unsigned int i = 0; i <
getRows(); i++)
5737 c[i] = (*
this)[i][j - 1];
5749 for (
unsigned int i = 0; i <
rowNum; i++)
5750 for (
unsigned int j = 0; j <
colNum; j++)
5752 (*this)[i][j] = val;
5757 #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) void solveBySVD(const vpColVector &B, vpColVector &x) const
void svd(vpColVector &w, vpMatrix &V)
vpMatrix operator*(const double &x, const vpMatrix &B)
vpMatrix extract(unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols) const
Implementation of a matrix and operations on matrices.
vpMatrix pseudoInverse(double svThreshold=1e-6) const
static vpMatrix juxtaposeMatrices(const vpMatrix &A, const vpMatrix &B)
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
vpColVector getDiag() const
double det(vpDetMethod method=LU_DECOMPOSITION) const
static vpMatrix conv2(const vpMatrix &M, const vpMatrix &kernel, const std::string &mode="full")
void kron(const vpMatrix &m1, vpMatrix &out) const
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpMatrix operator-() const
Implementation of row vector and the associated operations.
std::ostream & csvPrint(std::ostream &os) const
static void add2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
void stack(const vpMatrix &A)
vp_deprecated vpColVector column(unsigned int j)
vpMatrix inverseByLU() const
vpMatrix & operator/=(double x)
Divide all the element of the matrix by x : Aij = Aij / x.
error that can be emited by ViSP classes.
VISP_EXPORT bool checkAVX()
unsigned int getRows() const
double * data
Address of the first element of the data array.
vp_deprecated void stackMatrices(const vpMatrix &A)
Implementation of a generic 2D array used as base class for matrices and vectors. ...
static void sub2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
unsigned int size() const
Return the number of elements of the 2D array.
vpMatrix pseudoInverseLapack(double svThreshold=1e-6) const
vpMatrix & operator+=(const vpMatrix &B)
Operation A = A + B.
vpMatrix operator/(double x) const
Cij = Aij / x (A is unchanged)
double infinityNorm() const
void svdLapack(vpColVector &w, vpMatrix &V)
double cond(double svThreshold=1e-6) const
vpMatrix & operator-=(const vpMatrix &B)
Operation A = A - B.
vpMatrix operator+(const vpMatrix &B) const
vpMatrix pseudoInverseEigen3(double svThreshold=1e-6) const
static Type maximum(const Type &a, const Type &b)
Implementation of a rotation matrix and operations on such kind of matrices.
vpMatrix & operator*=(double x)
Multiply all the element of the matrix by x : Aij = Aij * x.
unsigned int getCols() const
std::ostream & maplePrint(std::ostream &os) const
unsigned int rowNum
Number of rows in the array.
vpMatrix hadamard(const vpMatrix &m) const
vp_deprecated void setIdentity(const double &val=1.0)
std::ostream & matlabPrint(std::ostream &os) const
unsigned int kernel(vpMatrix &kerAt, double svThreshold=1e-6) const
void diag(const double &val=1.0)
vp_deprecated void init()
static void add2WeightedMatrices(const vpMatrix &A, const double &wA, const vpMatrix &B, const double &wB, vpMatrix &C)
VISP_EXPORT bool checkSSE2()
vpMatrix pseudoInverseOpenCV(double svThreshold=1e-6) const
vpMatrix pseudoInverseGsl(double svThreshold=1e-6) const
vpRowVector getRow(unsigned int i) const
static void multMatrixVector(const vpMatrix &A, const vpColVector &v, vpColVector &w)
static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
std::ostream & cppPrint(std::ostream &os, const std::string &matrixName="A", bool octet=false) const
vpColVector eigenValues() const
double euclideanNorm() const
void svdOpenCV(vpColVector &w, vpMatrix &V)
int print(std::ostream &s, unsigned int length, const std::string &intro="") const
vpColVector getCol(unsigned int j) const
vpMatrix transpose() const
unsigned int colNum
Number of columns in the array.
double inducedL2Norm() const
void svdGsl(vpColVector &w, vpMatrix &V)
vpMatrix operator*(const vpMatrix &B) const
vp_deprecated vpRowVector row(unsigned int i)
void resize(unsigned int i, bool flagNullify=true)
Implementation of column vector and the associated operations.
static void createDiagonalMatrix(const vpColVector &A, vpMatrix &DA)
vpColVector stackColumns()
unsigned int dsize
Current array size (rowNum * colNum)
void insert(const vpMatrix &A, unsigned int r, unsigned int c)
static void negateMatrix(const vpMatrix &A, vpMatrix &C)
static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM)
vpMatrix & operator,(double val)
double frobeniusNorm() const
Function not implemented.
void resize(unsigned int i, bool flagNullify=true)
Class that consider the case of a translation vector.
double ** rowPtrs
Address of the first element of each rows.
void svdEigen3(vpColVector &w, vpMatrix &V)
vpMatrix & operator=(const vpArray2D< double > &A)
vpMatrix & operator<<(double *)