gels_batch (Buffer Strided Version)

gels_batch (Buffer Strided Version)#

Finds the least squares solutions for a batch of overdetermined linear systems. This routine belongs to the oneapi::mkl::lapack namespace.

Description#

Uses the QR factorization to solve a batch of linear systems 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. AH *X = B

On exit, the contents of B is overwritten with the solution vectors X.

Currently only the m n and trans = transpose::nontrans case is supported.

API#

Syntax#

namespace oneapi::mkl::lapack {
  void gels_batch(sycl::queue &queue,
  mkl::transpose trans,
  int64_t m,
  int64_t n,
  int64_t nrhs,
  sycl::buffer<T> &a,
  int64_t lda,
  int64_t stride_a,
  sycl::buffer<T> &b,
  int64_t ldb,
  int64_t stride_b,
  int64_t batch_size,
  sycl::buffer<T> &scratchpad,
  int64_t scratchpad_size)
}

This function supports the following precisions and devices:

T

Devices supported

float

GPU

double

GPU

std::complex<float>

GPU

std::complex<double>

GPU

Input Parameters#

queue

Device queue where calculations will be performed.

trans

Operation applied to matrices Ai. Real precisions: mkl::tranpose::nontrans or mkl::transpose::trans Complex precisions: mkl::tranpose::nontrans or mkl::transpose::conjtrans

m

The number of rows of the matrices Ai (m n 0).

n

The number of columns of the matrices Ai (m n 0).

nrhs

The number of right-hand sides: the number of columns in Bi (nrhs 0).

a

Contains batch_size m-by-n matrices Ai

lda

The leading dimension of Ai (ldamax(1,m)).

stride_a

The stride between the beginnings of matrices Ai inside the batch array a (stride_amax(1, lda * n)).

b

Contains the matrices Bi of right hand side vectors. Each matrix Bi must be allocated enough space to store the solution vectors Xi, i.e. max(m,n)-by-nrhs

If trans = transpose::nontrans, then Bi is m-by-nrhs; otherwise, Bi is n-by-nrhs.

ldb

The leading dimensions of Bi (ldbmax(1,max(m,n))).

stride_b

The stride between the beginnings of matrices Bi inside the batch array b (stride_bmax(1, ldb * nrhs)).

batch_size

The number of problems in a batch (batch_size ≥ 0).

scratchpad

Scratchpad memory to be used by routine for storing intermediate results.

scratchpad_size

Size of scratchpad memory as a number of floating point elements of type T. Size should not be less than the value returned by stride version of gels_batch_scratchpad_size (Strided Version).

Output Parameters#

a

Overwritten by the factorization data as follows: Contains triangular matrix R obtained on the basis of Ai used in least squares computation. The tau vectors are not recorded.

b

Overwritten by least squares solutions of the batch of problems.

Exceptions#

Exception

Description

mkl::lapack::batch_exception

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 info = -i, the i-th parameter had an illegal value.

If info equals the value passed as scratchpad size, and detail() returns non-zero, then the passed scratchpad is of insufficient size, and the required size should be not less then value returned by the detail() method of the exception object.

If info is zero, then Ai does not have full rank, and the solve could not be completed. The indexes of such matrices in the batch can be obtained with the ids() method of the exception object. You can obtain the indexes of the first zero diagonal elements in these matrices using the infos() method of the exception object.