Perform QR decomposition. More...

Functions

AFAPI void qr (array &out, array &tau, const array &in)
 C++ Interface for QR decomposition in packed format. More...
 
AFAPI void qr (array &q, array &r, array &tau, const array &in)
 C++ Interface for QR decomposition. More...
 
AFAPI void qrInPlace (array &tau, array &in)
 C++ Interface for QR decomposition. More...
 
AFAPI af_err af_qr (af_array *q, af_array *r, af_array *tau, const af_array in)
 C Interface for QR decomposition. More...
 
AFAPI af_err af_qr_inplace (af_array *tau, af_array in)
 C Interface for QR decomposition. More...
 

Detailed Description

Perform QR decomposition.

This function decomposes input matrix A into an orthogonal matrix Q and an upper triangular matrix R such that

 \f$A = Q * R\f$

 \f$Q * Q^T = I\f$

Where I is an identity matrix. The matrix Q is a square matrix of size max(M, N) where M and N are rows and columns of A respectively. The matrix R is the same size as **A*.

This operation can be performed in ArrayFire using the following code snippet.

array q, r, tau;
qr(q, r, tau, in);

The additional parameter Tau can be used to speed up solving over and under determined system of equations.

The original matrix can be reconstructed using the following code snippet.

array re = matmul(q, r);

When memory is a concern, users can perform QR decomposition in place as shown below.

array out = in.copy();
array tau2;
qrInPlace(tau2, out);

Function Documentation

◆ af_qr()

AFAPI af_err af_qr ( af_array q,
af_array r,
af_array tau,
const af_array  in 
)

C Interface for QR decomposition.

Parameters
[out]qis the orthogonal matrix from QR decomposition
[out]ris the upper triangular matrix from QR decomposition
[out]tauwill contain additional information needed for solving a least squares problem using q and r
[in]inis the input matrix

◆ af_qr_inplace()

AFAPI af_err af_qr_inplace ( af_array tau,
af_array  in 
)

C Interface for QR decomposition.

Parameters
[out]tauwill contain additional information needed for unpacking the data
[in,out]inis the input matrix on entry. It contains packed QR decomposition on exit

◆ qr() [1/2]

AFAPI void af::qr ( array out,
array tau,
const array in 
)

C++ Interface for QR decomposition in packed format.

Parameters
[out]outis the output array containing the packed QR decomposition
[out]tauwill contain additional information needed for unpacking the data
[in]inis the input matrix
Note
This function is not supported in GFOR
Examples
lin_algebra/qr.cpp.

◆ qr() [2/2]

AFAPI void af::qr ( array q,
array r,
array tau,
const array in 
)

C++ Interface for QR decomposition.

Parameters
[out]qis the orthogonal matrix from QR decomposition
[out]ris the upper triangular matrix from QR decomposition
[out]tauwill contain additional information needed for solving a least squares problem using q and r
[in]inis the input matrix
Note
This function is not supported in GFOR

◆ qrInPlace()

AFAPI void af::qrInPlace ( array tau,
array in 
)

C++ Interface for QR decomposition.

Parameters
[out]tauwill contain additional information needed for unpacking the data
[in,out]inis the input matrix on entry. It contains packed QR decomposition on exit
Note
This function is not supported in GFOR
Examples
lin_algebra/qr.cpp.
af::matmul
AFAPI array matmul(const array &lhs, const array &rhs, const matProp optLhs=AF_MAT_NONE, const matProp optRhs=AF_MAT_NONE)
Matrix multiply of two arrays.
afcl::array
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:327
af::qr
AFAPI void qr(array &out, array &tau, const array &in)
C++ Interface for QR decomposition in packed format.
af::array::copy
array copy() const
Perform deep copy of the array.
af::qrInPlace
AFAPI void qrInPlace(array &tau, array &in)
C++ Interface for QR decomposition.