diff --git a/include/numerics/dense_matrix.h b/include/numerics/dense_matrix.h index c7fd1802f58..6b9e0b42455 100644 --- a/include/numerics/dense_matrix.h +++ b/include/numerics/dense_matrix.h @@ -24,6 +24,12 @@ #include "libmesh/libmesh_common.h" #include "libmesh/dense_matrix_base.h" +// For the definition of PetscBLASInt. +#if (LIBMESH_HAVE_PETSC) +# include "libmesh/petsc_macro.h" +# include +#endif + // C++ includes #include #include @@ -646,11 +652,16 @@ class DenseMatrix : public DenseMatrixBase DenseMatrix * VR = libmesh_nullptr); /** - * This array is used to store pivot indices. May be used - * by whatever factorization is currently active, clients of - * the class should not rely on it for any reason. + * Array used to store pivot indices. May be used by whatever + * factorization is currently active, clients of the class should + * not rely on it for any reason. */ - std::vector _pivots; +#if (LIBMESH_HAVE_PETSC && LIBMESH_USE_REAL_NUMBERS) + typedef PetscBLASInt pivot_index_t; +#else + typedef int pivot_index_t; +#endif + std::vector _pivots; /** * Companion function to _lu_decompose_lapack(). Do not use @@ -733,8 +744,7 @@ DenseMatrix::DenseMatrix(const unsigned int new_m, use_blas_lapack(false), #endif _val(), - _decomposition_type(NONE), - _pivots() + _decomposition_type(NONE) { this->resize(new_m,new_n); } diff --git a/src/numerics/dense_matrix.C b/src/numerics/dense_matrix.C index e087b679546..d4b27513208 100644 --- a/src/numerics/dense_matrix.C +++ b/src/numerics/dense_matrix.C @@ -665,7 +665,7 @@ void DenseMatrix::_lu_back_substitute (const DenseVector & b, for (unsigned int i=0; i(i)) + if (_pivots[i] != static_cast(i)) std::swap( z(i), z(_pivots[i]) ); x(i) = z(i); @@ -731,7 +731,7 @@ void DenseMatrix::_lu_decompose () // If the max was found in a different row, interchange rows. // Here we interchange the *entire* row, in Gaussian elimination // you would only interchange the subrows A(i,j) and A(p(i),j), for j>i - if (_pivots[i] != static_cast(i)) + if (_pivots[i] != static_cast(i)) { for (unsigned int j=0; j::det () for (unsigned int i=0; im(); i++) { if (this->_decomposition_type==LU) - if (_pivots[i] != static_cast(i)) + if (_pivots[i] != static_cast(i)) n_interchanges++; // Lapack pivots are 1-based! if (this->_decomposition_type==LU_BLAS_LAPACK) - if (_pivots[i] != static_cast(i+1)) + if (_pivots[i] != static_cast(i+1)) n_interchanges++; determinant *= (*this)(i,i);