endas.cov.to_matrix

endas.cov.to_matrix(C, force_dense=False, out=None)

Returns matrix representation of a covariance operator.

If the passed instance is already a covariance matrix, it is returned as-is. Compatible matrix types are

  • numpy.ndarray, numpy.matrix - returned as-is
  • subclass of scipy.sparse.spmatrix - returned as-is if force_dense=False, otherwise converted to numpy.ndarray.

If C is an instance of endas.CovarianceOperator, the result of C.to_matrix() is returned. Please note that not all covariance operators support conversion to explicit matrix form.

Parameters:
Returns:

Dense NumPy array (ndarray) or sparse SciPy array depending on C and force_dense.

Raises:
  • TypeError – if C is of unsupported type
  • ValueError – if C is a non-square matrix
  • NotImplementedError – raised by endas.CovarianceOperator.to_matrix()
  • MemoryError – if the covariance matrix array cannot be allocated