Vectors

Predicates

is_scalar(x)

Returns if x is a scalar

is_vec(x)

Returns if x is a line vector or row vector or column vector

is_line_vec(x)

Returns if x is a line vector

is_row_vec(x)

Returns if x is a row vector

is_col_vec(x)

Returns if x is a column vector

is_increasing_vec(x)

Returns if x is a vector with (strictly) increasing values

is_decreasing_vec(x)

Returns if x is a vector with (strictly) decreasing values

is_nonincreasing_vec(x)

Returns if x is a vector with non-increasing values

is_nondecreasing_vec(x)

Returns if x is a vector with non-decreasing values

has_equal_values_vec(x)

Returns if x is a vector with equal values

Unary Operations

to_row_vec(x)

Converts a line vector to a row vector

to_col_vec(x)

Converts a line vector to a column vector

vec_unit(n, i)

Returns a unit vector in i-th dimension for the standard coordinate system

vec_shift_right(x)

Right shift the contents of the vector

vec_rotate_right(x)

Circular right shift the contents of the vector

vec_shift_left(x)

Left shift the contents of the vector

vec_rotate_left(x)

Circular left shift the contents of the vector

vec_shift_right_n(x, n)

Right shift the contents of the vector by n places

vec_rotate_right_n(x, n)

Circular right shift the contents of the vector by n places

vec_shift_left_n(x, n)

Left shift the contents of the vector by n places

vec_rotate_left_n(x, n)

Circular left shift the contents of the vector by n places

vec_repeat_at_end(x, p)

Extends a vector by repeating it at the end (periodic extension)

vec_repeat_at_start(x, p)

Extends a vector by repeating it at the start (periodic extension)

vec_centered(x, length)

Returns the central part of a vector of a specified length

vec_unit_jit(n, i)

Returns a unit vector in i-th dimension for the standard coordinate system

vec_repeat_at_end_jit(x, p)

Extends a vector by repeating it at the end (periodic extension)

vec_repeat_at_start_jit(x, p)

Extends a vector by repeating it at the start (periodic extension)

vec_centered_jit(x, length)

Returns the central part of a vector of a specified length

vec_swap_entries(x, i, j)

Swaps two entries in a vector

Norm

norm_l1(x)

Computes the l_1 norm of a vector

norm_l2(x)

Computes the l_2 norm of a vector

norm_linf(x)

Computes the l_inf norm of a vector

sqr_norm_l2(x)

Computes the squared l_2 norm of a vector

normalize_l1(x)

Normalizes a vector by its l_1-norm

normalize_l2(x)

Normalizes a vector by its l_2-norm

normalize_linf(x)

Normalizes a vector by its l_inf-norm

Circular Buffer

cbuf_push_left(buf, val)

Left shift the contents of the vector

cbuf_push_right(buf, val)

Left shift the contents of the vector

Binary Heap

is_min_heap(x)

Checks if x is a min heap

is_max_heap(x)

Checks if x is a max heap

left_child_idx(idx)

Returns the index of the left child

right_child_idx(idx)

Returns the index of the right child

parent_idx(idx)

Returns the parent index for an index

build_max_heap(x)

Converts x into a max heap

largest_plr(x, idx)

Return the index of the largest value between a parent and its children

heapify_subtree(x, idx)

Heapifies a subtree starting from a given node

delete_top_from_max_heap(x)

Removes the top element from a max heap retaining its heap structure

Miscellaneous

vec_mag_desc(a)

Returns the coefficients in the descending order of magnitude

vec_to_pmf(a)

Computes a probability mass function from a given vector

vec_to_cmf(a)

Computes a cumulative mass function from a given vector

cmf_find_quantile_index(a, q)

Returns the index of a given quantile in a CMF

num_largest_coeffs_for_energy_percent(a, p)

Returns the number of largest components containing a given percentage of energy