Blaze 3.9
QL.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_DENSE_QL_H_
36#define _BLAZE_MATH_DENSE_QL_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <memory>
44#include <blaze/math/Aliases.h>
61#include <blaze/util/EnableIf.h>
62
63
64namespace blaze {
65
66//=================================================================================================
67//
68// QL DECOMPOSITION FUNCTIONS
69//
70//=================================================================================================
71
72//*************************************************************************************************
75template< typename MT1, bool SO1, typename MT2, bool SO2, typename MT3, bool SO3 >
76void ql( const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& Q, DenseMatrix<MT3,SO3>& L );
78//*************************************************************************************************
79
80
81//*************************************************************************************************
93template< typename MT1 > // Type of matrix A
94inline auto ql_backend( MT1& A, const ElementType_t<MT1>* tau )
95 -> EnableIf_t<IsBuiltin_v< ElementType_t<MT1> > >
96{
97 orgql( A, tau );
98}
100//*************************************************************************************************
101
102
103//*************************************************************************************************
115template< typename MT1 > // Type of matrix A
116inline auto ql_backend( MT1& A, const ElementType_t<MT1>* tau )
117 -> EnableIf_t<IsComplex_v< ElementType_t<MT1> > >
118{
119 ungql( A, tau );
120}
122//*************************************************************************************************
123
124
125//*************************************************************************************************
173template< typename MT1 // Type of matrix A
174 , bool SO1 // Storage order of matrix A
175 , typename MT2 // Type of matrix Q
176 , bool SO2 // Storage order of matrix Q
177 , typename MT3 // Type of matrix L
178 , bool SO3 > // Storage order of matrix L
180{
183
186
193
194 using ET1 = ElementType_t<MT1>;
195
196 const size_t m( (*A).rows() );
197 const size_t n( (*A).columns() );
198 const size_t mindim( min( m, n ) );
199
200 if( ( !IsResizable_v<MT2> && ( (*Q).rows() != m || (*Q).columns() != mindim ) ) ||
201 ( !IsResizable_v<MT3> && ( (*L).rows() != mindim || (*L).columns() != n ) ) ) {
202 BLAZE_THROW_INVALID_ARGUMENT( "Dimensions of fixed size matrix do not match" );
203 }
204
205 if( IsSquare_v<MT3> && mindim != n ) {
206 BLAZE_THROW_INVALID_ARGUMENT( "Square matrix cannot be resized to min(m,n)-by-n" );
207 }
208
209 const std::unique_ptr<ET1[]> tau( new ET1[mindim] );
210 decltype(auto) l( derestrict( *L ) );
211
212 if( m < n )
213 {
214 l = A;
215 geqlf( l, tau.get() );
216 (*Q) = submatrix( l, 0UL, n-m, m, m );
217 ql_backend( *Q, tau.get() );
218
219 for( size_t i=0UL; i<m; ++i ) {
220 for( size_t j=i+n-m+1UL; j<n; ++j ) {
221 reset( l(i,j) );
222 }
223 }
224 }
225 else
226 {
227 (*Q) = A;
228 geqlf( *Q, tau.get() );
229
230 resize( *L, n, n, false );
231 reset( l );
232
233 for( size_t i=0UL; i<n; ++i ) {
234 for( size_t j=0UL; j<i+1UL; ++j ) {
235 l(i,j) = (*Q)(i+m-n,j);
236 }
237 }
238
239 ql_backend( *Q, tau.get() );
240 }
241}
242//*************************************************************************************************
243
244} // namespace blaze
245
246#endif
Constraint on the data type.
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.
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the IsResizable type trait.
Header file for the IsSquare 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.
Header file for the LAPACK QL decomposition functions (geqlf)
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:1339
void ql(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO2 > &Q, DenseMatrix< MT3, SO3 > &L)
QL decomposition of the given dense matrix.
Definition: QL.h:179
void orgql(blas_int_t m, blas_int_t n, blas_int_t k, float *A, blas_int_t lda, const float *tau, float *work, blas_int_t lwork, blas_int_t *info)
LAPACK kernel for the reconstruction of the orthogonal matrix Q from a QL decomposition.
Definition: orgql.h:125
void geqlf(blas_int_t m, blas_int_t n, float *A, blas_int_t lda, float *tau, float *work, blas_int_t lwork, blas_int_t *info)
LAPACK kernel for the QL decomposition of the given dense single precision column-major matrix.
Definition: geqlf.h:152
void ungql(blas_int_t m, blas_int_t n, blas_int_t k, complex< float > *A, blas_int_t lda, const complex< float > *tau, complex< float > *work, blas_int_t lwork, blas_int_t *info)
LAPACK kernel for the reconstruction of the orthogonal matrix Q from a QL decomposition.
Definition: ungql.h:127
#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_ADAPTOR_TYPE(T)
Constraint on the data type.
Definition: Adaptor.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
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:181
#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 functions to reconstruct Q from a QL decomposition (orgql)
Header file for the LAPACK functions to reconstruct Q from a QL decomposition (ungql)
Header file for the generic min algorithm.
Header file for the implementation of the Submatrix view.