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)
281 if (
dsize !=
static_cast<unsigned int>(list.size())) {
282 resize(1,
static_cast<unsigned int>(list.size()),
false,
false);
285 std::copy(list.begin(), list.end(),
data);
319 unsigned int nrows =
static_cast<unsigned int>(lists.size()), ncols = 0;
320 for (
auto &l : lists) {
321 if (
static_cast<unsigned int>(l.size()) > ncols) {
322 ncols =
static_cast<unsigned int>(l.size());
326 resize(nrows, ncols,
false,
false);
327 auto it = lists.begin();
328 for (
unsigned int i = 0; i <
rowNum; ++i, ++it) {
329 std::copy(it->begin(), it->end(),
rowPtrs[i]);
350 for (
unsigned int i = 0; i <
rowNum; ++i) {
351 for (
unsigned int j = 0; j <
colNum; ++j) {
360 resize(1, 1,
false,
false);
380 const unsigned int val_3 = 3;
386 for (
unsigned int j = 0; j < val_3; ++j) {
390 for (
unsigned int j = 0; j < val_3; ++j) {
392 for (
unsigned int i = 0; i < val_3; ++i) {
393 t_out[i] +=
rowPtrs[i][j] * tj;
434 const unsigned int val_3 = 3;
437 unsigned int RcolNum = R.
getCols();
438 unsigned int RrowNum = R.
getRows();
439 for (
unsigned int i = 0; i <
rowNum; ++i) {
442 for (
unsigned int j = 0; j < RcolNum; ++j) {
444 for (
unsigned int k = 0; k < RrowNum; ++k) {
445 s += rowptri[k] * R[k][j];
465 const unsigned int val_4 = 4;
468 const unsigned int McolNum = M.
getCols();
469 const unsigned int MrowNum = M.
getRows();
470 for (
unsigned int i = 0; i <
rowNum; ++i) {
471 const double *rowptri =
rowPtrs[i];
473 for (
unsigned int j = 0; j < McolNum; ++j) {
475 for (
unsigned int k = 0; k < MrowNum; ++k) {
476 s += rowptri[k] * M[k][j];
497 const unsigned int val_6 = 6;
505 bool useLapack = ((
rowNum > vpMatrix::m_lapack_min_size) || (
colNum > vpMatrix::m_lapack_min_size) ||
506 (V.
colNum > vpMatrix::m_lapack_min_size));
507 #if !(defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL))
512 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL)
513 const double alpha = 1.0;
514 const double beta = 0.0;
515 const char trans =
'n';
516 vpMatrix::blas_dgemm(trans, trans, V.
colNum,
rowNum,
colNum, alpha, V.
data, V.
colNum,
data,
colNum, beta, M.
data,
521 #if defined(VISP_HAVE_SIMDLIB)
524 unsigned int VcolNum = V.
getCols();
525 unsigned int VrowNum = V.
getRows();
526 for (
unsigned int i = 0; i <
rowNum; ++i) {
529 for (
unsigned int j = 0; j < VcolNum; ++j) {
531 for (
unsigned int k = 0; k < VrowNum; ++k) {
532 s += rowptri[k] * V[k][j];
554 const unsigned int val_6 = 6;
562 bool useLapack = ((
rowNum > vpMatrix::m_lapack_min_size) || (
colNum > vpMatrix::m_lapack_min_size) ||
563 (V.
getCols() > vpMatrix::m_lapack_min_size));
564 #if !(defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL))
569 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN) && !defined(VISP_HAVE_GSL)
570 const double alpha = 1.0;
571 const double beta = 0.0;
572 const char trans =
'n';
573 vpMatrix::blas_dgemm(trans, trans, V.
getCols(),
rowNum,
colNum, alpha, V.
data, V.
getCols(),
data,
colNum, beta,
578 #if defined(VISP_HAVE_SIMDLIB)
581 unsigned int VcolNum = V.
getCols();
582 unsigned int VrowNum = V.
getRows();
583 for (
unsigned int i = 0; i <
rowNum; ++i) {
586 for (
unsigned int j = 0; j < VcolNum; ++j) {
588 for (
unsigned int k = 0; k < VrowNum; ++k) {
589 s += rowptri[k] * V[k][j];
633 for (
unsigned int i = 0; i <
rowNum; ++i) {
634 for (
unsigned int j = 0; j <
colNum; ++j) {
635 rowPtrs[i][j] += BrowPtrs[i][j];
651 for (
unsigned int i = 0; i <
rowNum; ++i) {
652 for (
unsigned int j = 0; j <
colNum; ++j) {
653 rowPtrs[i][j] -= BrowPtrs[i][j];
674 for (
unsigned int i = 0; i <
rowNum; ++i) {
675 for (
unsigned int j = 0; j <
colNum; ++j) {
689 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
696 for (
unsigned int i = 0; i <
rowNum; ++i) {
697 for (
unsigned int j = 0; j <
colNum; ++j) {
709 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
713 if (std::fabs(x) < std::numeric_limits<double>::epsilon()) {
722 for (
unsigned int i = 0; i <
rowNum; ++i) {
723 for (
unsigned int j = 0; j <
colNum; ++j) {
724 C[i][j] =
rowPtrs[i][j] * xinv;
734 for (
unsigned int i = 0; i <
rowNum; ++i) {
735 for (
unsigned int j = 0; j <
colNum; ++j) {
746 for (
unsigned int i = 0; i <
rowNum; ++i) {
747 for (
unsigned int j = 0; j <
colNum; ++j) {
761 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
765 for (
unsigned int i = 0; i <
rowNum; ++i) {
766 for (
unsigned int j = 0; j <
colNum; ++j) {
777 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
781 if (std::fabs(x) < std::numeric_limits<double>::epsilon()) {
787 for (
unsigned int i = 0; i <
rowNum; ++i) {
788 for (
unsigned int j = 0; j <
colNum; ++j) {
802 if (std::fabs(x - 1.) < std::numeric_limits<double>::epsilon()) {
806 unsigned int Brow = B.
getRows();
807 unsigned int Bcol = B.
getCols();
809 VISP_NAMESPACE_ADDRESSING
vpMatrix C;
810 C.
resize(Brow, Bcol,
false,
false);
812 for (
unsigned int i = 0; i < Brow; ++i) {
813 for (
unsigned int j = 0; j < Bcol; ++j) {
814 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
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
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.