Utilities in cr.sparse module

Array data type utilities

promote_arg_dtypes(*args)

Promotes args to a common inexact type.

check_shapes_are_equal(array1, array2)

Raise an error if the shapes of the two arrays do not match.

Metrics for measuring signal and error levels

These functions are available under cr.sparse.metrics.

mean_squared(array)

Returns the mean squared value of an array

mean_squared_error(array1, array2)

Returns the mean square error between two arrays

root_mean_squared(array)

Returns the root mean squared value of an array

root_mse(array1, array2)

Returns the root mean square error between two arrays

normalized_root_mse(reference_arr, test_arr)

Returns the root mean square error between two arrays

peak_signal_noise_ratio(reference_arr, test_arr)

Returns the Peak Signal to Noie Ratio between two arrays

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[, atol])

Checks if a matrix has orthogonal columns

has_orthogonal_rows(A[, atol])

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