34 #include <visp3/core/vpConfig.h>
35 #include <visp3/core/vpMatrix.h>
37 #if defined(VISP_HAVE_SIMDLIB)
38 #include <Simd/SimdLib.h>
242 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
245 if (
this != &other) {
261 other.rowPtrs =
nullptr;
263 other.data =
nullptr;
301 if (
dsize !=
static_cast<unsigned int>(list.size())) {
302 resize(1,
static_cast<unsigned int>(list.size()),
false,
false);
305 std::copy(list.begin(), list.end(),
data);
339 unsigned int nrows =
static_cast<unsigned int>(lists.size()), ncols = 0;
340 for (
auto &l : lists) {
341 if (
static_cast<unsigned int>(l.size()) > ncols) {
342 ncols =
static_cast<unsigned int>(l.size());
346 resize(nrows, ncols,
false,
false);
347 auto it = lists.begin();
348 for (
unsigned int i = 0; i <
rowNum; ++i, ++it) {
349 std::copy(it->begin(), it->end(),
rowPtrs[i]);
370 for (
unsigned int i = 0; i <
rowNum; ++i) {
371 for (
unsigned int j = 0; j <
colNum; ++j) {
380 resize(1, 1,
false,
false);
405 const unsigned int val_3 = 3;
406 for (
unsigned int j = 0; j < val_3; ++j) {
410 for (
unsigned int j = 0; j < val_3; ++j) {
412 for (
unsigned int i = 0; i < val_3; ++i) {
413 t_out[i] +=
rowPtrs[i][j] * tj;
456 unsigned int RcolNum = R.
getCols();
457 unsigned int RrowNum = R.
getRows();
458 for (
unsigned int i = 0; i <
rowNum; ++i) {
461 for (
unsigned int j = 0; j < RcolNum; ++j) {
463 for (
unsigned int k = 0; k < RrowNum; ++k) {
464 s += rowptri[k] * R[k][j];
486 const unsigned int McolNum = M.
getCols();
487 const unsigned int MrowNum = M.
getRows();
488 for (
unsigned int i = 0; i <
rowNum; ++i) {
489 const double *rowptri =
rowPtrs[i];
491 for (
unsigned int j = 0; j < McolNum; ++j) {
493 for (
unsigned int k = 0; k < MrowNum; ++k) {
494 s += rowptri[k] * M[k][j];
522 bool useLapack = ((
rowNum > vpMatrix::m_lapack_min_size) || (
colNum > vpMatrix::m_lapack_min_size) ||
523 (V.
colNum > vpMatrix::m_lapack_min_size));
524 #if !(defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL))
529 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL)
530 const double alpha = 1.0;
531 const double beta = 0.0;
532 const char trans =
'n';
533 vpMatrix::blas_dgemm(trans, trans, V.
colNum,
rowNum,
colNum, alpha, V.
data, V.
colNum,
data,
colNum, beta, M.
data,
538 #if defined(VISP_HAVE_SIMDLIB)
541 unsigned int VcolNum = V.
getCols();
542 unsigned int VrowNum = V.
getRows();
543 for (
unsigned int i = 0; i <
rowNum; ++i) {
546 for (
unsigned int j = 0; j < VcolNum; ++j) {
548 for (
unsigned int k = 0; k < VrowNum; ++k) {
549 s += rowptri[k] * V[k][j];
578 bool useLapack = ((
rowNum > vpMatrix::m_lapack_min_size) || (
colNum > vpMatrix::m_lapack_min_size) ||
579 (V.
getCols() > vpMatrix::m_lapack_min_size));
580 #if !(defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL))
585 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL)
586 const double alpha = 1.0;
587 const double beta = 0.0;
588 const char trans =
'n';
589 vpMatrix::blas_dgemm(trans, trans, V.
getCols(),
rowNum,
colNum, alpha, V.
data, V.
getCols(),
data,
colNum, beta,
594 #if defined(VISP_HAVE_SIMDLIB)
597 unsigned int VcolNum = V.
getCols();
598 unsigned int VrowNum = V.
getRows();
599 for (
unsigned int i = 0; i <
rowNum; ++i) {
602 for (
unsigned int j = 0; j < VcolNum; ++j) {
604 for (
unsigned int k = 0; k < VrowNum; ++k) {
605 s += rowptri[k] * V[k][j];
649 for (
unsigned int i = 0; i <
rowNum; ++i) {
650 for (
unsigned int j = 0; j <
colNum; ++j) {
651 rowPtrs[i][j] += BrowPtrs[i][j];
667 for (
unsigned int i = 0; i <
rowNum; ++i) {
668 for (
unsigned int j = 0; j <
colNum; ++j) {
669 rowPtrs[i][j] -= BrowPtrs[i][j];
690 for (
unsigned int i = 0; i <
rowNum; ++i) {
691 for (
unsigned int j = 0; j <
colNum; ++j) {
705 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
712 for (
unsigned int i = 0; i <
rowNum; ++i) {
713 for (
unsigned int j = 0; j <
colNum; ++j) {
725 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
729 if (std::fabs(x) < std::numeric_limits<double>::epsilon()) {
738 for (
unsigned int i = 0; i <
rowNum; ++i) {
739 for (
unsigned int j = 0; j <
colNum; ++j) {
740 C[i][j] =
rowPtrs[i][j] * xinv;
750 for (
unsigned int i = 0; i <
rowNum; ++i) {
751 for (
unsigned int j = 0; j <
colNum; ++j) {
762 for (
unsigned int i = 0; i <
rowNum; ++i) {
763 for (
unsigned int j = 0; j <
colNum; ++j) {
777 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
781 for (
unsigned int i = 0; i <
rowNum; ++i) {
782 for (
unsigned int j = 0; j <
colNum; ++j) {
793 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
797 if (std::fabs(x) < std::numeric_limits<double>::epsilon()) {
803 for (
unsigned int i = 0; i <
rowNum; ++i) {
804 for (
unsigned int j = 0; j <
colNum; ++j) {
818 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
822 unsigned int Brow = B.
getRows();
823 unsigned int Bcol = B.
getCols();
825 VISP_NAMESPACE_ADDRESSING
vpMatrix C;
826 C.
resize(Brow, Bcol,
false,
false);
828 for (
unsigned int i = 0; i < Brow; ++i) {
829 for (
unsigned int j = 0; j < Bcol; ++j) {
830 C[i][j] = B[i][j] * x;
unsigned int getCols() const
double * data
Address of the first element of the data array.
double ** rowPtrs
Address of the first element of each rows.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int rowNum
Number of rows in the array.
unsigned int dsize
Current array size (rowNum * colNum)
unsigned int getRows() const
unsigned int colNum
Number of columns in the array.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
@ divideByZeroError
Division by zero.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
vpMatrix operator-() const
vpMatrix & operator/=(double x)
Divide all the element of the matrix by x : Aij = Aij / x.
vpMatrix operator*(const vpMatrix &B) const
vpMatrix operator/(double x) const
Cij = Aij / x (A is unchanged)
vpMatrix & operator-=(const vpMatrix &B)
Operation A = A - B.
vpMatrix & operator*=(double x)
Multiply all the element of the matrix by x : Aij = Aij * x.
vpMatrix operator*(const double &x, const vpMatrix &B)
vpMatrix & operator<<(double *p)
static void sub2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
vpMatrix operator+(const vpMatrix &B) const
vpMatrix & operator+=(const vpMatrix &B)
Operation A = A + B.
vpMatrix & operator,(double val)
static void multMatrixVector(const vpMatrix &A, const vpColVector &v, vpColVector &w)
vpMatrix & operator=(const vpArray2D< double > &A)
static void add2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
static void negateMatrix(const vpMatrix &A, vpMatrix &C)
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Class that consider the case of a translation vector.