45 #include "ac/lapack.h"
79 for (
integer i = 1; i <= nr; i++) {
80 for (
integer ii = 1; ii <= nc; ii++) {
94 return SubMH.
AddTo(*
this);
108 return SubMH.
AddTo(*
this);
124 for (
integer i = 1; i <= nr; i++) {
125 for (
integer j = 1; j <= nc; j++) {
159 silent_cerr(
"MatrixHandler::MatMatMul_base: size mismatch "
160 "out(" << out_nr <<
", " << out_nc <<
") "
162 "* in(" << in_nr <<
", " << in.
iGetNumCols() <<
")"
168 for (
integer r = 1; r <= out_nr; r++) {
171 for (
integer k = 1; k <= in_nr; k++) {
207 silent_cerr(
"MatrixHandler::MatTMatMul_base: size mismatch "
208 "out(" << out_nr <<
", " << out_nc <<
") "
210 "* in(" << in_nr <<
", " << in.
iGetNumCols() <<
")"
217 for (
integer r = 1; r <= out_nr; r++) {
220 for (
integer k = 1; k <= in_nr; k++) {
283 silent_cerr(
"MatrixHandler::MatVecMul_base(): size mismatch "
285 "= this(" << nr <<
", " << nc <<
") "
286 "* in(" << in.
iGetSize() <<
", 1)" << std::endl);
290 for (
integer r = 1; r <= nr; r++) {
312 silent_cerr(
"MatrixHandler::MatVecMul_base(): size mismatch "
314 "= this(" << nr <<
", " << nc <<
")^T "
315 "* in(" << in.
iGetSize() <<
", 1)" << std::endl);
319 for (
integer r = 1; r <= nc; r++) {
393 #define HAVE_CONDITION_NUMBER ((defined(HAVE_DGETRF_) || defined(HAVE_DGETRF)) && (defined(HAVE_DGECON_) || defined(HAVE_DGECON)))
402 for (
int i = 0; i < M; ++i) {
403 for (
int j = 0; j < N; ++j) {
404 A[j * M + i] = MH(i + 1, j + 1);
415 for (
int j = 0; j < N; ++j) {
418 for (
int i = 0; i < M; ++i) {
419 csum += std::abs(A[j * M + i]);
428 for (
int i = 0; i < N; ++i) {
431 for (
int j = 0; j < M; ++j) {
432 rsum += std::abs(A[j * M + i]);
453 #if HAVE_CONDITION_NUMBER
456 std::vector<doublereal> A;
458 LapackCopyMatrix(*
this, A, M, N);
460 const doublereal ANORM = LapackMatrixNorm(A, M, N, eNorm);
463 std::cerr <<
"ANORM=" << ANORM << std::endl;
464 std::cerr <<
"A=" << std::endl;
465 for (
int i = 0; i < M; ++i) {
466 for (
int j = 0; j < N; ++j) {
467 std::cerr << A[j * M + i] <<
'\t';
469 std::cerr << std::endl;
474 std::vector<integer> IPIV(std::min(M,N));
476 __FC_DECL__(dgetrf)(&M, &N, &A[0], &M, &IPIV[0], &INFO);
480 std::vector<doublereal> WORK(4*N);
481 std::vector<integer> IWORK(N);
497 __FC_DECL__(dgecon)(&norm, &N, &A[0], &M, &ANORM, &RCOND, &WORK[0], &IWORK[0], &INFO);
502 std::cerr <<
"RCOND=" << RCOND << std::endl;
506 #else // ! HAVE_CONDITION_NUMBER
507 silent_cerr(
"Condition number is not available in this version of MBDyn" << std::endl);
509 #endif // ! HAVE_CONDITION_NUMBER
516 std::vector<doublereal> A;
518 LapackCopyMatrix(*
this, A, M, N);
520 return LapackMatrixNorm(A, M, N, eNorm);
529 for (
integer i = 1; i <= nr; i++) {
530 for (
integer j = 1; j <= nc; j++) {
531 out << std::setw(16) << MH(i, j) <<
' ';
virtual void Reset(void)=0
virtual MatrixHandler & MatMatIncMul(MatrixHandler &out, const MatrixHandler &in) const
virtual integer iGetNumCols(void) const =0
virtual const doublereal & dGetCoef(integer iRow, integer iCol) const
virtual void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
#define MBDYN_EXCEPT_ARGS
virtual MatrixHandler & MatMatDecMul(MatrixHandler &out, const MatrixHandler &in) const
virtual VectorHandler & MatVecMul_base(void(VectorHandler::*op)(integer iRow, const doublereal &dCoef), VectorHandler &out, const VectorHandler &in) const
virtual integer PacMat(void)
virtual VectorHandler & MatVecIncMul(VectorHandler &out, const VectorHandler &in) const
std::ostream & operator<<(std::ostream &out, const MatrixHandler &MH)
virtual MatrixHandler & AddTo(MatrixHandler &MH) const =0
virtual VectorHandler & MatTVecDecMul(VectorHandler &out, const VectorHandler &in) const
virtual MatrixHandler & operator-=(const SubMatrixHandler &SubMH)
virtual void IncCoef(integer iRow, const doublereal &dCoef)=0
virtual void DecCoef(integer iRow, integer iCol, const doublereal &dCoef)
virtual VectorHandler & MatTVecIncMul(VectorHandler &out, const VectorHandler &in) const
virtual doublereal Norm(enum Norm_t eNorm=NORM_1) const
virtual integer iGetSize(void) const =0
virtual VectorHandler & MatVecDecMul(VectorHandler &out, const VectorHandler &in) const
virtual doublereal ConditionNumber(enum Norm_t eNorm=NORM_1) const
virtual void Reset(void)=0
virtual void DecCoef(integer iRow, const doublereal &dCoef)=0
virtual MatrixHandler & MatTMatMul_base(void(MatrixHandler::*op)(integer iRow, integer iCol, const doublereal &dCoef), MatrixHandler &out, const MatrixHandler &in) const
virtual MatrixHandler & SubFrom(MatrixHandler &MH) const =0
virtual MatrixHandler & operator+=(const SubMatrixHandler &SubMH)
virtual const doublereal & operator()(integer iRow, integer iCol) const =0
MatrixHandler & AddTo(MatrixHandler &MH) const
virtual ~MatrixHandler(void)
virtual void PutCoef(integer iRow, integer iCol, const doublereal &dCoef)
#define ASSERT(expression)
virtual VectorHandler & MatTVecMul_base(void(VectorHandler::*op)(integer iRow, const doublereal &dCoef), VectorHandler &out, const VectorHandler &in) const
virtual MatrixHandler & MatMatMul_base(void(MatrixHandler::*op)(integer iRow, integer iCol, const doublereal &dCoef), MatrixHandler &out, const MatrixHandler &in) const
virtual void ResizeReset(integer, integer)
MatrixHandler & SubFrom(MatrixHandler &MH) const
virtual MatrixHandler & MatTMatIncMul(MatrixHandler &out, const MatrixHandler &in) const
static std::stack< cleanup * > c
virtual void Resize(integer, integer)=0
virtual MatrixHandler & MatTMatDecMul(MatrixHandler &out, const MatrixHandler &in) const
virtual VectorHandler & MatTVecMul(VectorHandler &out, const VectorHandler &in) const
virtual MatrixHandler & MatMatMul(MatrixHandler &out, const MatrixHandler &in) const
virtual MatrixHandler & MatTMatMul(MatrixHandler &out, const MatrixHandler &in) const
virtual VectorHandler & MatVecMul(VectorHandler &out, const VectorHandler &in) const
virtual MatrixHandler & operator=(const MatrixHandler &MH)
virtual integer iGetNumRows(void) const =0
virtual MatrixHandler & ScalarMul(const doublereal &d)