35 #ifndef _BLAZE_MATH_DENSE_LU_H_ 36 #define _BLAZE_MATH_DENSE_LU_H_ 74 template<
typename MT1,
bool SO1,
typename MT2,
typename MT3,
typename MT4,
bool SO2 >
75 void lu(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO1>& L,
76 DenseMatrix<MT3,SO1>& U, Matrix<MT4,SO2>& P );
94 template<
typename MT1
98 void lu( DenseMatrix<MT1,SO1>& A, Matrix<MT2,SO2>& P )
106 using ET = ElementType_t<MT2>;
108 const int m( numeric_cast<int>( (~A).
rows() ) );
109 const int n( numeric_cast<int>( (~A).
columns() ) );
110 const int mindim(
min( m, n ) );
111 const int size( SO1 ? m : n );
113 const std::unique_ptr<int[]> helper(
new int[mindim +
size] );
114 int* ipiv ( helper.get() );
115 int* permut( ipiv + mindim );
119 for(
int i=0; i<
size; ++i ) {
123 for(
int i=0; i<mindim; ++i ) {
126 swap( permut[ipiv[i]], permut[i] );
132 for(
int i=0; i<
size; ++i ) {
133 (~P)( ( SO1 ? permut[i] : i ), ( SO1 ? i : permut[i] ) ) = ET(1);
216 template<
typename MT1
241 const size_t m( (~A).
rows() );
242 const size_t n( (~A).
columns() );
243 const size_t mindim(
min( m, n ) );
244 const size_t size( SO1 ? m : n );
246 if( ( !IsResizable_v<MT2> && ( (~L).
rows() != m || (~L).
columns() != mindim ) ) ||
247 ( !IsResizable_v<MT3> && ( (~U).
rows() != mindim || (~U).
columns() != n ) ) ||
252 if( ( IsSquare_v<MT2> && n < m ) || ( IsSquare_v<MT3> && m < n ) ) {
256 decltype(
auto) l( derestrict( ~L ) );
257 decltype(
auto) u( derestrict( ~U ) );
264 resize( ~L, m, m,
false );
269 for(
size_t i=0UL; i<m; ++i )
271 for(
size_t j=0UL; j<i; ++j ) {
282 for(
size_t j=0UL; j<m; ++j )
286 for(
size_t i=j+1UL; i<m; ++i ) {
298 resize( ~U, n, n,
false );
303 for(
size_t i=0UL; i<n; ++i )
307 for(
size_t j=i+1UL; j<n; ++j ) {
315 for(
size_t j=0UL; j<n; ++j )
317 for(
size_t i=0UL; i<j; ++i ) {
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Headerfile for the generic min algorithm.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
Constraint on the data type.
Constraint on the data type.
Cast operators for numeric types.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
constexpr bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ADAPTOR_TYPE(T)
Constraint on the data type.In case the given data type T is an adaptor type (as for instance LowerMa...
Definition: Adaptor.h:81
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Constraint on the data type.
Header file for the IsSquare type trait.
Constraint on the data type.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
Header file for the DenseMatrix base class.
void lu(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO1 > &L, DenseMatrix< MT3, SO1 > &U, Matrix< MT4, SO2 > &P)
LU decomposition of the given dense matrix.
Definition: LU.h:222
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type,...
Definition: Upper.h:81
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type,...
Definition: Symmetric.h:79
void getrf(int m, int n, float *A, int lda, int *ipiv, int *info)
LAPACK kernel for the LU decomposition of the given dense general single precision column-major matri...
Definition: getrf.h:131
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type,...
Definition: Lower.h:81
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:282
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:114
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a BLAS compatible data type (i....
Definition: BLASCompatible.h:61
Constraint on the data type.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_STRICTLY_TRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a strictly lower or upper triangular mat...
Definition: StrictlyTriangular.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type,...
Definition: Hermitian.h:79
Header file for the IsResizable type trait.
Header file for the LAPACK LU decomposition functions (getrf)