Utilities in cr.sparse module

Some checks and utilities for matrices (2D arrays)

transpose(A)

Returns the transpose of an array

hermitian(a)

Returns the conjugate transpose of an array

is_matrix(A)

Checks if an array is a matrix

is_square(A)

Checks if an array is a square matrix

is_symmetric(A)

Checks if an array is a symmetric matrix

is_hermitian(A)

Checks if an array is a Hermitian matrix

is_positive_definite(A)

Checks if an array is a symmetric positive definite matrix

has_orthogonal_columns(A)

Checks if a matrix has orthogonal columns

has_orthogonal_rows(A)

Checks if a matrix has orthogonal rows

has_unitary_columns(A)

Checks if a matrix has unitary columns

has_unitary_rows(A)

Checks if a matrix has unitary rows

Row wise and column wise norms for signal/representation matrices

norms_l1_cw(X)

Computes the l_1 norm of each column of a matrix

norms_l1_rw(X)

Computes the l_1 norm of each row of a matrix

norms_l2_cw(X)

Computes the l_2 norm of each column of a matrix

norms_l2_rw(X)

Computes the l_2 norm of each row of a matrix

norms_linf_cw(X)

Computes the l_inf norm of each column of a matrix

norms_linf_rw(X)

Computes the l_inf norm of each row of a matrix

sqr_norms_l2_cw(X)

Computes the squared l_2 norm of each column of a matrix

sqr_norms_l2_rw(X)

Computes the l_2 norm of each row of a matrix

normalize_l1_cw(X)

Normalize each column of X per l_1-norm

normalize_l1_rw(X)

Normalize each row of X per l_1-norm

normalize_l2_cw(X)

Normalize each column of X per l_2-norm

normalize_l2_rw(X)

Normalize each row of X per l_2-norm

Sparse representations

Following functions analyze or construct representation vectors which are known to be sparse.

nonzero_values(x)

Returns the values of non-zero entries in x

nonzero_indices(x)

Returns the indices of non-zero entries in x

randomize_rows(key, X)

Randomizes the rows in X

randomize_cols(key, X)

Randomizes the columns in X

largest_indices(x, K)

Returns the indices of K largest entries in x by magnitude

hard_threshold(x, K)

Returns the indices and corresponding values of largest K non-zero entries in a vector x

hard_threshold_sorted(x, K)

Returns the sorted indices and corresponding values of largest K non-zero entries in a vector x

sparse_approximation(x, K)

Keeps only largest K non-zero entries by magnitude in a vector x

build_signal_from_indices_and_values(length, …)

Builds a sparse signal from its non-zero entries (specified by their indices and values)

dynamic_range(x)

Returns the ratio of largest and smallest values (by magnitude) in x (dB)

nonzero_dynamic_range(x)

Returns the ratio of largest and smallest non-zero values (by magnitude) in x (dB)

Sparse representation matrices (row-wise)

largest_indices_rw(X, K)

Returns the indices of K largest entries by magnitude in each row of X

take_along_rows(X, indices)

Picks K entries from each row of X specified by indices matrix

sparse_approximation_rw(X, K)

Keeps only largest K non-zero entries by magnitude in each row of X

Sparse representation matrices (column-wise)

largest_indices_cw(X, K)

Returns the indices of K largest entries by magnitude in each column of X

take_along_cols(X, indices)

Picks K entries from each column of X specified by indices matrix

sparse_approximation_cw(X, K)

Keeps only largest K non-zero entries by magnitude in each column of X