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>
50 #include <blaze/math/Exception.h>
56 
57 
58 namespace blaze {
59 
60 //=================================================================================================
61 //
62 // LLH DECOMPOSITION FUNCTIONS
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
69 template< typename MT1, bool SO1, typename MT2, bool SO2 >
70 void llh( const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& L );
72 //*************************************************************************************************
73 
74 
75 //*************************************************************************************************
124 template< typename MT1 // Type of matrix A
125  , bool SO1 // Storage order of matrix A
126  , typename MT2 // Type of matrix L
127  , bool SO2 > // Storage order of matrix L
129 {
132 
138 
139  if( !isSquare( ~A ) ) {
140  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
141  }
142 
143  const size_t n( (~A).rows() );
144 
145  if( ( !IsResizable<MT2>::value && ( (~L).rows() != n || (~L).columns() != n ) ) ) {
146  BLAZE_THROW_INVALID_ARGUMENT( "Dimensions of fixed size matrix do not match" );
147  }
148 
149  DerestrictTrait_<MT2> l( derestrict( ~L ) );
150 
151  resize( ~L, n, n );
152  reset( l );
153 
155  for( size_t i=0UL; i<n; ++i ) {
156  for( size_t j=0UL; j<=i; ++j ) {
157  l(i,j) = (~A)(i,j);
158  }
159  }
160  }
161  else {
162  for( size_t j=0UL; j<n; ++j ) {
163  for( size_t i=j; i<n; ++i ) {
164  l(i,j) = (~A)(i,j);
165  }
166  }
167  }
168 
169  potrf( l, 'L' );
170 }
171 //*************************************************************************************************
172 
173 } // namespace blaze
174 
175 #endif
#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.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
Header file for the LAPACK Cholesky decomposition functions (potrf)
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
#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
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Constraint on the data type.
Constraint on the data type.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:83
Header file for the DenseMatrix base class.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
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
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:538
Header file for the DerestrictTrait class template.
Constraint on the data type.
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
#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, a compilation error is created.
Definition: Symmetric.h:79
Constraint on the data type.
#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.
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
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
Header file for the IsRowMajorMatrix type trait.
#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, a compilation error is created.
Definition: Hermitian.h:79
void potrf(char uplo, int n, float *A, int lda, int *info)
LAPACK kernel for the Cholesky decomposition of the given dense positive definite single precision co...
Definition: potrf.h:128
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:609
Header file for the IsResizable type trait.
void llh(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO2 > &L)
Cholesky (LLH) decomposition of the given dense matrix.
Definition: LLH.h:128