Einsums/TensorUtilities/CreateRandomSemidefinite.hpp#
Defined in header Einsums/TensorUtilities/CreateRandomSemidefinite.hpp.
See Overview for a list of names and headers that are part of the public Einsums API.
-
namespace einsums
-
Functions
-
template<typename T = double, bool Normalize = false>
Tensor<T, 2> create_random_semidefinite(std::string const &name, int rows, int cols, T mean = T{1.0}, int force_zeros = 1)# Create a random positive or negative semi-definite matrix. A positive semi-definite matrix is a symmetric matrix whose eigenvalues are all non-negative. Similarly for negative semi-definite matrices.
This function first generates a set of random eigenvectors, making sure they are non-singular. Then, it uses these to form an orthonormal eigenbasis for the new matrix. Then, it generates the eigenvalues. The eigenvalues are distributed using a Maxwell-Boltzmann distribution with the given mean, defaulting to 1. If desired, a number of eigenvalues can be forced to be zero. Then, the returned matrix is formed by computing \(P^TDP\).
- Parameters:
name – The name for the matrix.
rows – The number of rows.
cols – The number of columns. Should equal the number of rows.
mean – The mean for the eigenvalues. Defaults to 1. If negative, the result is a negative semi-definite matrix.
force_zeros – The number of elements to force to be zero. Defaults to 1.
- Returns:
A new positive or negative semi-definite matrix.
-
template<typename T = double, bool Normalize = false>