gels (USM Version)#
Finds the least squares solution of an overdetermined linear system or the minimum norm solution of an underdetermined system. This routine belongs to the oneapi::mkl::lapack
namespace.
Description#
Uses the QR factorization to solve a linear system with full rank matrices. Each linear system is solved according to the following:
If m ≥ n and trans = transpose::nontrans
, the least squares solution to the
overdetermined system is computed:
min ||A*X - B||
If m ≥ n and trans = (transpose::trans or tranpose::conjtrans)
, the minimal
norm solution to the underdetermined system is computed:
min ||X||
s.t. A
H* X
= B
m < n
is not supported.
On exit, the contents of B
is overwritten with the solution vectors X
.
API#
Syntax#
namespace oneapi::mkl::lapack {
sycl::event gels(sycl::queue &queue,
mkl::transpose trans,
int64_t m,
int64_t n,
int64_t nrhs,
T *a,
int64_t lda,
T *b,
int64_t ldb,
T *scratchpad,
int64_t scratchpad_size,
const std::vector<sycl::event> &events = {})
}
gels
(USM version) supports the following precisions and
devices:
T |
Devices supported |
---|---|
|
CPU and GPU |
|
CPU and GPU |
|
CPU and GPU |
|
CPU and GPU |
Input Parameters#
- queue
Device queue where calculations will be performed.
- trans
Operation applied to matrix
A
. Real precisions:mkl::tranpose::nontrans
ormkl::transpose::trans
Complex precisions:mkl::tranpose::nontrans
ormkl::transpose::conjtrans
- m
The number of rows of the matrix
A
(m ≥ n ≥ 0
).- n
The number of columns of the matrix
A
(m ≥ n ≥ 0
).- nrhs
The number of right-hand sides: the number of columns in
B
(nrhs ≥ 0
).- a
Pointer to the memory holding input matrix
A
.- lda
The leading dimension of
a
(lda ≥ max(1,m)
).- b
Pointer to the memory holding input matrix
B
of right hand side vectors.B
must be allocated enough space to store the solution vectorsX
, i.e.max(m,n)
-by-nrhs
If
trans = transpose::nontrans
thenB
ism
-by-nrhs
, otherwiseB
isn
-by-nrhs
.- ldb
The leading dimension of
b
(ldb ≥ max(1, max(m,n))
).- scratchpad
Pointer to scratchpad memory to be used by the routine for storing intermediate results.
- scratchpad_size
Size of scratchpad memory as a number of floating point elements of type
T
. Size must not be less than the value returned by the gels_scratchpad_size function.- events
List of events to wait for before starting computation. Defaults to empty list.
Output Parameters#
- a
Overwritten by the factorization data as follows: contains triangular matrix R obtained on the basis of
A
used in least squares computation.- b
Overwritten by least squares solutions of the problem.
Exceptions#
Exception |
Description |
---|---|
|
This exception is thrown when problems occur during calculations. You can obtain the info code of the problem using the info() method of the exception object: If If |
Return Values#
Output event to wait on to ensure computation is complete.