naginterfaces.library.rnla.randproj_dct_real(trans, a, k, statecomm)[source]

randproj_dct_real computes a fast random projection of a real matrix using a Discrete Cosine Transform (DCT). The function can be used as a building block in Randomised Numerical Linear Algebra (RNLA) algorithms, such as decompositions, Singular Value Decompositions (SVDs), and (approximate) least squares solvers.

For full information please refer to the NAG Library document for f10da

transstr, length 1

Specifies whether the operation pre-multiplies or post-multiplies .

Random projection is done by post-multiplication, .

Random projection is done by pre-multiplication, .

afloat, array-like, shape

The matrix .


, number of columns in the random projection, .

statecommdict, RNG communication object, modified in place

RNG communication structure.

This argument must have been initialized by a prior call to rand.init_repeat or rand.init_nonrepeat.

afloat, ndarray, shape

If , the random projection of .

If , the random projection of .

(errno )

On entry, .

Constraint: or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: if , , if , .

(errno )

On entry, [‘state’] vector has been corrupted or not initialized.


A random projection is written as either


where is a real matrix, is an matrix in the first case, and a matrix in the second case. These cases are referred to as random projection by post-multiplication and random projection by pre-multiplication, respectively.

When a random projection by post-multiplication uses the DCT, it is written as

where is a diagonal matrix whose values are uniformly distributed on the set , is a DCT, and is a matrix that selects a subset of columns, uniformly at random.

When a random projection by pre-multiplication uses the DCT, it is written as

The operators and are as above and is a matrix that selects a subset of rows, again uniformly at random.

None of these matrix operators require a full matrix-matrix product to be computed. The computational complexity of applying this type of random projection is . More details of the DCT-based random projection can be found in Avron et al. (2010).

The DCT-based random projection is closely related to the Subsampled Random Fourier Transform (SRFT) presented in Section 4.6 of Halko et al. (2011).


Avron, H, Maymounkov, P and Toledo, S, 2010, Blendenpik: Supercharging LAPACK’s least-squares solver, SIAM J. Sci. Comput. (32(3)), 1217–1236

Halko, N, 2012, Randomized methods for computing low-rank approximations of matrices, PhD thesis

Halko, N, Martinsson, P G and Tropp, J A, 2011, Finding structure with randomness: Probabilistic algorithms for constructing approximate matrix decompositions, SIAM Rev. (53(2)), 217–288,