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