geometric_kernels.lab_extras¶
Custom extensions for LAB.
Package Contents¶
- geometric_kernels.lab_extras.complex_conj(x)[source]¶
Return complex conjugate.
- Parameters:
x (lab.Numeric) – Array of any backend.
- geometric_kernels.lab_extras.complex_like(reference)[source]¶
Return complex dtype of a backend based on the reference.
- Parameters:
reference (lab.Numeric) – Array of any backend.
- geometric_kernels.lab_extras.cosh(x)[source]¶
Compute hyperbolic cosine using the formula
\[\textrm{cosh}(x) = \frac{\exp(x) + \exp(-x)}{2}.\]- Parameters:
x (lab.Numeric) – Array of any backend.
- Return type:
lab.Numeric
- geometric_kernels.lab_extras.count_nonzero(x, axis=None)[source]¶
Count non-zero elements in an array.
- Parameters:
x (lab.Numeric) – Array of any backend and of any shape.
- geometric_kernels.lab_extras.create_complex(real, imag)[source]¶
Return a complex number with the given real and imaginary parts.
- Parameters:
real (lab.Numeric) – Array of any backend, real part of the complex number.
imag (lab.Numeric) – Array of any backend, imaginary part of the complex number.
- geometric_kernels.lab_extras.cumsum(a, axis=None)[source]¶
Return cumulative sum (optionally along axis).
- Parameters:
a (lab.Numeric) – Array of any backend.
axis – As in numpy.cumsum.
- geometric_kernels.lab_extras.degree(a)[source]¶
Given an adjacency matrix a, return a diagonal matrix with the col-sums of a as main diagonal - this is the degree matrix representing the number of nodes each node is connected to.
- Parameters:
a – Array of any backend or scipy.sparse array.
- geometric_kernels.lab_extras.dtype_bool(reference)[source]¶
Return bool dtype of a backend based on the reference.
- Parameters:
reference (lab.RandomState) – A random state to infer the backend from.
- geometric_kernels.lab_extras.dtype_double(reference)[source]¶
Return double dtype of a backend based on the reference.
- Parameters:
reference (lab.RandomState) – A random state to infer the backend from.
- geometric_kernels.lab_extras.dtype_integer(reference)[source]¶
Return int dtype of a backend based on the reference.
- Parameters:
reference (lab.RandomState) – A random state to infer the backend from.
- geometric_kernels.lab_extras.eigenpairs(L, k)[source]¶
Obtain the eigenpairs that correspond to the k lowest eigenvalues of a symmetric positive semi-definite matrix L.
- Parameters:
a – Array of any backend or scipy.sparse array.
k (int) – The number of eigenpairs to compute.
- geometric_kernels.lab_extras.eigvalsh(x)[source]¶
Compute the eigenvalues of a Hermitian or real symmetric matrix x.
- Parameters:
x (lab.Numeric) – Array of any backend.
- geometric_kernels.lab_extras.float_like(reference)[source]¶
Return the type of the reference if it is a floating point type. Otherwise return double dtype of a backend based on the reference.
- Parameters:
reference (lab.Numeric) – Array of any backend.
- geometric_kernels.lab_extras.from_numpy(_, b)[source]¶
Converts the array b to a tensor of the same backend as _.
- Parameters:
_ (lab.Numeric) – Array of any backend used to determine the backend.
b (plum.Union[beartype.typing.List, lab.Numeric]) – Array of any backend or list to be converted to the backend of _.
- geometric_kernels.lab_extras.get_random_state(key)[source]¶
Return the random state of a random generator.
- Parameters:
key (lab.RandomState) – The random generator.
- geometric_kernels.lab_extras.int_like(reference)[source]¶
Return the type of the reference if it is integer type. Otherwise return int32 dtype of a backend based on the reference.
- Parameters:
reference (lab.Numeric) – Array of any backend.
- geometric_kernels.lab_extras.is_complex(reference)[source]¶
Return True if reference of complex dtype.
- Parameters:
reference (lab.Numeric) – Array of any backend.
- geometric_kernels.lab_extras.logical_xor(x1, x2)[source]¶
Return logical XOR of two arrays.
- Parameters:
x1 (lab.Bool) – Array of any backend.
x2 (lab.Bool) – Array of any backend.
- geometric_kernels.lab_extras.logspace(start, stop, num=50)[source]¶
Return numbers spaced evenly on a log scale.
- Parameters:
start (lab.Numeric) – Array of any backend, as in numpy.logspace.
stop (lab.Numeric) – Array of any backend, as in numpy.logspace.
num (int) – As in numpy.logspace.
- geometric_kernels.lab_extras.qr(x, mode='reduced')[source]¶
Return a QR decomposition of a matrix x.
- Parameters:
x (lab.Numeric) – Array of any backend.
mode – As in numpy.linalg.qr.
- geometric_kernels.lab_extras.reciprocal_no_nan(x)[source]¶
Return element-wise reciprocal (1/x). Whenever x = 0 puts 1/x = 0.
- Parameters:
x (plum.Union[lab.Numeric, scipy.sparse.spmatrix]) – Array of any backend or scipy.sparse.spmatrix.
- geometric_kernels.lab_extras.restore_random_state(key, state)[source]¶
Set the random state of a random generator. Return the new random generator with state state.
- Parameters:
key (lab.RandomState) – The random generator.
state – The new random state of the random generator.
- geometric_kernels.lab_extras.set_value(a, index, value)[source]¶
Set a[index] = value. This operation is not done in place and a new array is returned.
- Parameters:
a – Array of any backend or scipy.sparse array.
index (int) – The index.
value (float) – The value to set at the given index.
- geometric_kernels.lab_extras.sinh(x)[source]¶
Compute hyperbolic sine using the formula
\[\textrm{sinh}(x) = \frac{\exp(x) - \exp(-x)}{2}.\]- Parameters:
x (lab.Numeric) – Array of any backend.
- Return type:
lab.Numeric
- geometric_kernels.lab_extras.slogdet(x)[source]¶
Return the sign and log-determinant of a matrix x.
- Parameters:
x (lab.Numeric) – Array of any backend.
- geometric_kernels.lab_extras.take_along_axis(a, index, axis=0)[source]¶
Gathers elements of a along axis at index locations.
- Parameters:
a (lab.Numeric) – Array of any backend, as in numpy.take_along_axis.
index (lab.Numeric) – Array of any backend, as in numpy.take_along_axis.
axis (int) – As in numpy.take_along_axis.
- geometric_kernels.lab_extras.trapz(y, x, dx=1.0, axis=-1)[source]¶
Integrate along the given axis using the trapezoidal rule.
- Parameters:
y (lab.Numeric) – Array of any backend, as in numpy.trapz.
x (lab.Numeric) – Array of any backend, as in numpy.trapz.
dx (lab.Numeric) – Array of any backend, as in numpy.trapz.
axis (int) – As in numpy.trapz.