Blaze 3.9
LLH.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_DENSE_LLH_H_
36#define _BLAZE_MATH_DENSE_LLH_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
55
56
57namespace blaze {
58
59//=================================================================================================
60//
61// LLH DECOMPOSITION FUNCTIONS
62//
63//=================================================================================================
64
65//*************************************************************************************************
68template< typename MT1, bool SO1, typename MT2, bool SO2 >
69void llh( const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& L );
71//*************************************************************************************************
72
73
74//*************************************************************************************************
123template< typename MT1 // Type of matrix A
124 , bool SO1 // Storage order of matrix A
125 , typename MT2 // Type of matrix L
126 , bool SO2 > // Storage order of matrix L
128{
131
137
138 if( !isSquare( *A ) ) {
139 BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
140 }
141
142 const size_t n( (*A).rows() );
143
144 if( ( !IsResizable_v<MT2> && ( (*L).rows() != n || (*L).columns() != n ) ) ) {
145 BLAZE_THROW_INVALID_ARGUMENT( "Dimensions of fixed size matrix do not match" );
146 }
147
148 decltype(auto) l( derestrict( *L ) );
149
150 resize( *L, n, n, false );
151 reset( l );
152
153 if( IsRowMajorMatrix_v<MT2> ) {
154 for( size_t i=0UL; i<n; ++i ) {
155 for( size_t j=0UL; j<=i; ++j ) {
156 l(i,j) = (*A)(i,j);
157 }
158 }
159 }
160 else {
161 for( size_t j=0UL; j<n; ++j ) {
162 for( size_t i=j; i<n; ++i ) {
163 l(i,j) = (*A)(i,j);
164 }
165 }
166 }
167
168 potrf( l, 'L' );
169}
170//*************************************************************************************************
171
172} // namespace blaze
173
174#endif
Header file for auxiliary alias declarations.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Constraint on the data type.
Constraint on the data type.
Header file for the IsResizable type trait.
Header file for the IsRowMajorMatrix type trait.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Header file for the DenseMatrix base class.
void llh(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO2 > &L)
Cholesky (LLH) decomposition of the given dense matrix.
Definition: LLH.h:127
void potrf(char uplo, blas_int_t n, float *A, blas_int_t lda, blas_int_t *info)
LAPACK kernel for the Cholesky decomposition of the given dense positive definite single precision co...
Definition: potrf.h:137
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.
Definition: BLASCompatible.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Hermitian.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_STRICTLY_TRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: StrictlyTriangular.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: UniTriangular.h:81
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:1383
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for the LAPACK Cholesky decomposition functions (potrf)