Package org.flag4j.rng
Class RandomTensor
java.lang.Object
org.flag4j.rng.RandomTensor
An instance of this class is used for generating streams of pseudorandom tensors, matrices, and vectors.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final RandomCNumber
Complex pseudorandom number generator.private final RandomArray
-
Constructor Summary
ConstructorDescriptionConstructs a new pseudorandom tensor generator with a seed which is unlikely to be the same as other from any other invocation of this constructor.RandomTensor
(long seed) Constructs a pseudorandom tensor generator with a specified seed. -
Method Summary
Modifier and TypeMethodDescriptiongeRandomTrilMatrix
(int size, int min, int max) Gets a pseudorandom lower triangular matrix of the specified size.randnCMatrix
(int rows, int cols) Generates a matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.randnCMatrix
(int rows, int cols, double mean, double std) Generates a matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a specified mean and standard deviation.randnCMatrix
(Shape shape) Generates a matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.randnCMatrix
(Shape shape, double mean, double std) Generates a matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.randnCTensor
(Shape shape) Generates a tensor filled with pseudorandom values sampled from a normal distribution with mean of 0.0 and standard deviation of 1.0.randnCTensor
(Shape shape, double mean, double std) Generates a tensor filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.randnCVector
(int size) Generates a vector filled with pseudorandom values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.randnCVector
(int size, double mean, double std) Generates a vector filled with pseudorandom values with magnitudes sampled from a normal distribution with specified mean and standard deviation.randnMatrix
(int rows, int cols) Generates a matrix filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.randnMatrix
(int rows, int cols, double mean, double std) Generates a matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.randnMatrix
(Shape shape) Generates a matrix filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.randnMatrix
(Shape shape, double mean, double std) Generates a matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.randnTensor
(Shape shape) Generates a tensor filled with pseudorandom values sampled from a normal distribution with mean of 0.0 and standard deviation of 1.0.randnTensor
(Shape shape, double mean, double std) Generates a tensor filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.randnVector
(int size) Generates a vector filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.randnVector
(int size, double mean, double std) Generates a vector filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.randomCMatrix
(int rows, int cols) Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[0, 1)
.randomCMatrix
(int rows, int cols, double min, double max) Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[min, max)
.randomCMatrix
(Shape shape) Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[0, 1)
.randomCMatrix
(Shape shape, double min, double max) Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[min, max)
.randomCooMatrix
(int rows, int cols, double min, double max, double sparsity) Generates a random sparse matrix with the specified sparsity.randomCooMatrix
(int rows, int cols, double min, double max, int numNonZeroEntries) Generates a random sparse matrix with the specified number of non-zero entries.randomCooMatrix
(Shape shape, double min, double max, double sparsity) Generates a random sparse matrix with the specified sparsity.randomCooMatrix
(Shape shape, double min, double max, int numNonZeroEntries) Generates a random sparse matrix with the specified number of non-zero entries.randomCsrMatrix
(int rows, int cols, double min, double max, double sparsity) Generates a random sparse matrix with the specified sparsity.randomCsrMatrix
(int rows, int cols, double min, double max, int numNonZeroEntries) Generates a random sparse matrix with the specified number of non-zero entries.randomCsrMatrix
(Shape shape, double min, double max, double sparsity) Generates a random sparse matrix with the specified sparsity.randomCsrMatrix
(Shape shape, double min, double max, int numNonZeroEntries) Generates a random sparse matrix with the specified number of non-zero entries.randomCTensor
(Shape shape) Generates a tensor filled with pseudorandom complex values with magnitudes uniformly distributed in[0, 1)
.randomCTensor
(Shape shape, double min, double max) Generates a tensor filled with pseudorandom values with magnitudes uniformly distributed in[min, max)
.randomCVector
(int size) Generates a vector filled with pseudorandom complex values with magnitudes uniformly distributed in[0, 1)
.randomCVector
(int size, double min, double max) Generates a vector filled with pseudorandom values with magnitudes uniformly distributed in[min, max)
.randomMatrix
(int rows, int cols) Generates a matrix filled with pseudorandom values uniformly distributed in[0, 1)
.randomMatrix
(int rows, int cols, double min, double max) Generates a matrix filled with pseudorandom values uniformly distributed in[min, max)
.randomMatrix
(Shape shape) Generates a matrix filled with pseudorandom values uniformly distributed in[0, 1)
.randomMatrix
(Shape shape, double min, double max) Generates a matrix filled with pseudorandom values uniformly distributed in[min, max)
.randomOrthogonalMatrix
(int size) Gets a pseudorandom orthogonal matrix.randomSparseCMatrix
(int rows, int cols, double min, double max, double sparsity) Generates a random sparse matrix with the specified sparsity.randomSparseCMatrix
(int rows, int cols, double min, double max, int numNonZeroEntries) Generates a random sparse matrix with the specified number of non-zero entries.randomSparseCMatrix
(Shape shape, double min, double max, double sparsity) Generates a random sparse matrix with the specified sparsity.randomSparseCMatrix
(Shape shape, double min, double max, int numNonZeroEntries) Generates a random sparse matrix with the specified number of non-zero entries.randomSymmetricCooMatrix
(int size, int min, int max, double sparsity) Generates a symmetricCOO matrix
filled with pseudorandom values uniformly distributed in[min, max)
.randomSymmetricCsrMatrix
(int size, int min, int max, double sparsity) Generates a symmetricCSR matrix
filled with pseudorandom values uniformly distributed in[min, max)
.randomSymmetricMatrix
(int size) Generates a symmetric matrix filled with pseudorandom values uniformly distributed in[0, 1)
.randomTensor
(Shape shape) Generates a tensor filled with pseudorandom values uniformly distributed in[0, 1)
.randomTensor
(Shape shape, double min, double max) Generates a tensor filled with pseudorandom values uniformly distributed in[min, max)
.randomTriuMatrix
(int size, int min, int max) Gets a pseudorandom upper triangular matrix of the specified size.randomUnitaryMatrix
(int size) Gets a pseudorandom unitary matrix.randomVector
(int size) Generates a vector filled with pseudorandom values uniformly distributed in[0, 1)
.randomVector
(int size, double min, double max) Generates a vector filled with pseudorandom values uniformly distributed in[min, max)
.
-
Field Details
-
COMPLEX_RNG
Complex pseudorandom number generator. -
RAND_ARRAY
-
-
Constructor Details
-
RandomTensor
public RandomTensor()Constructs a new pseudorandom tensor generator with a seed which is unlikely to be the same as other from any other invocation of this constructor. -
RandomTensor
public RandomTensor(long seed) Constructs a pseudorandom tensor generator with a specified seed. Use this constructor for reproducible results.- Parameters:
seed
- Seed of the pseudorandom tensor generator.
-
-
Method Details
-
randomTensor
-
randomTensor
Generates a tensor filled with pseudorandom values uniformly distributed in[min, max)
.- Parameters:
shape
- Shape of the tensor.min
- Minimum value for the uniform distribution.max
- Maximum value for the uniform distribution.- Returns:
- A tensor filled with pseudorandom values uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmax
is less thanmin
.
-
randnTensor
Generates a tensor filled with pseudorandom values sampled from a normal distribution with mean of 0.0 and standard deviation of 1.0.- Parameters:
shape
- Shape of the tensor.- Returns:
- A tensor filled with pseudorandom values sampled from a normal distribution with mean of 0.0 and standard deviation of 1.0.
-
randnTensor
Generates a tensor filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.- Parameters:
shape
- Shape of the tensor.mean
- Mean of the normal distribution to sample from.std
- Standard deviation of normal distribution to sample from.- Returns:
- A tensor filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If standard deviation is negative.
-
randomCTensor
-
randomCTensor
Generates a tensor filled with pseudorandom values with magnitudes uniformly distributed in[min, max)
.- Parameters:
shape
- Shape of the tensor.min
- Minimum value for the uniform distribution from which to sample magnitude.max
- Maximum value for the uniform distribution from which to sample magnitude.- Returns:
- A tensor filled with pseudorandom values with magnitudes uniformly distributed in
[min, max)
- Throws:
IllegalArgumentException
- Ifmin
is negative or ifmax
is less thanmin
.
-
randnCTensor
Generates a tensor filled with pseudorandom values sampled from a normal distribution with mean of 0.0 and standard deviation of 1.0.- Parameters:
shape
- Shape of the tensor.- Returns:
- A tensor filled with pseudorandom values sampled from a normal distribution with mean of 0.0 and standard deviation of 1.0.
-
randnCTensor
Generates a tensor filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.- Parameters:
shape
- Shape of the tensor.mean
- Mean of the normal distribution to sample from.std
- Standard deviation of normal distribution to sample from.- Returns:
- A tensor filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If standard deviation is negative.
-
randomVector
Generates a vector filled with pseudorandom values uniformly distributed in[0, 1)
.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom values uniformly distributed in
[0, 1)
.
-
randomVector
Generates a vector filled with pseudorandom values uniformly distributed in[min, max)
.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom values uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmax
is less thanmin
.
-
randnVector
Generates a vector filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.
-
randnVector
Generates a vector filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom values sampled from a normal distribution with specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If the standard deviation is negative.
-
randomCVector
Generates a vector filled with pseudorandom complex values with magnitudes uniformly distributed in[0, 1)
.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom complex values with magnitudes uniformly distributed in
[0, 1)
.
-
randomCVector
Generates a vector filled with pseudorandom values with magnitudes uniformly distributed in[min, max)
.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom values with magnitudes uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmin
is negative or ifmax
is less thanmin
.
-
randnCVector
Generates a vector filled with pseudorandom values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.
-
randnCVector
Generates a vector filled with pseudorandom values with magnitudes sampled from a normal distribution with specified mean and standard deviation.- Parameters:
size
- Size of the vector to generate.- Returns:
- A vector filled with pseudorandom values with magnitudes sampled from a normal distribution with specified mean * and standard deviation.
- Throws:
IllegalArgumentException
- If the standard deviation is negative.
-
randomMatrix
Generates a matrix filled with pseudorandom values uniformly distributed in[0, 1)
.- Parameters:
rows
- Number of rows in the resulting matrix.cols
- Number of columns in the resulting matrix.- Returns:
- A matrix filled with pseudorandom values uniformly distributed in
[0, 1)
.
-
randomMatrix
Generates a matrix filled with pseudorandom values uniformly distributed in[0, 1)
.- Parameters:
shape
- Shape of the resulting matrix. Must be of rank 2.- Returns:
- A matrix filled with pseudorandom values uniformly distributed in
[0, 1)
. - Throws:
IllegalArgumentException
- If theshape
is not of rank 2.
-
randomMatrix
Generates a matrix filled with pseudorandom values uniformly distributed in[min, max)
.- Parameters:
rows
- Number of rows in the resulting matrix.cols
- Number of columns in the resulting matrix.min
- Minimum value of uniform distribution to sample from (inclusive).max
- Maximum value of uniform distribution to sample from (exclusive).- Returns:
- A matrix filled with pseudorandom values uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmax
is less thanmin
.
-
randomMatrix
Generates a matrix filled with pseudorandom values uniformly distributed in[min, max)
.- Parameters:
shape
- Shape of the resulting matrix. Must be of rank 2.min
- Minimum value of uniform distribution to sample from (inclusive).max
- Maximum value of uniform distribution to sample from (exclusive).- Returns:
- A matrix filled with pseudorandom values uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmax
is less thanmin
.IllegalArgumentException
- Ifshape
is not of rank 2.
-
randomCooMatrix
Generates a random sparse matrix with the specified sparsity. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
rows
- Number of rows in the sparse matrix.cols
- Number of columns in the sparse matrix.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuessparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
.- Returns:
- A sparse matrix with sparsity approximately equal to
sparsity
filled with random values uniformly distributed in[min, max)
.
-
randomCooMatrix
Generates a random sparse matrix with the specified sparsity. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
shape
- Shape of the sparse matrix to generate.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuessparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
.- Returns:
- A sparse matrix with sparsity approximately equal to
sparsity
filled with random values uniformly distributed in[min, max)
.
-
randomCooMatrix
Generates a random sparse matrix with the specified number of non-zero entries. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
rows
- Number of rows in the random sparse matrix.cols
- Number of columns in the random sparse matrix.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuesnumNonZeroEntries
- Desired number of non-zero entries int the random sparse matrix.- Returns:
- A sparse matrix filled with the specified number of non-zero entries uniformly
distributed in
[min, max)
.
-
randomCooMatrix
Generates a random sparse matrix with the specified number of non-zero entries. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
shape
- Shape of the sparse matrix to generate.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuesnumNonZeroEntries
- Desired number of non-zero entries int the random sparse matrix.- Returns:
- A sparse matrix filled with the specified number of non-zero entries uniformly
distributed in
[min, max)
.
-
randomCsrMatrix
Generates a random sparse matrix with the specified sparsity. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
rows
- Number of rows in the sparse matrix.cols
- Number of columns in the sparse matrix.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuessparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
.- Returns:
- A sparse matrix with sparsity approximately equal to
sparsity
filled with random values uniformly distributed in[min, max)
.
-
randomCsrMatrix
Generates a random sparse matrix with the specified sparsity. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
shape
- Shape of the sparse matrix to generate.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuessparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
.- Returns:
- A sparse matrix with sparsity approximately equal to
sparsity
filled with random values uniformly distributed in[min, max)
.
-
randomCsrMatrix
Generates a random sparse matrix with the specified number of non-zero entries. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
rows
- Number of rows in the random sparse matrix.cols
- Number of columns in the random sparse matrix.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuesnumNonZeroEntries
- Desired number of non-zero entries int the random sparse matrix.- Returns:
- A sparse matrix filled with the specified number of non-zero entries uniformly
distributed in
[min, max)
.
-
randomCsrMatrix
Generates a random sparse matrix with the specified number of non-zero entries. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
shape
- Shape of the sparse matrix to generate.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuesnumNonZeroEntries
- Desired number of non-zero entries int the random sparse matrix.- Returns:
- A sparse matrix filled with the specified number of non-zero entries uniformly
distributed in
[min, max)
.
-
randnMatrix
Generates a matrix filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.- Parameters:
rows
- The number of rows in the resulting matrix.cols
- The number of columns in the resulting matrix.- Returns:
- A matrix filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.
-
randnMatrix
Generates a matrix filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.- Parameters:
shape
- Shape of the resulting matrix.- Returns:
- A matrix filled with pseudorandom values sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.
-
randnMatrix
Generates a matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.- Parameters:
rows
- The number of rows in the resulting matrix.cols
- The number of columns in the resulting matrix.mean
- Mean of the normal distribution from which values are sampled.std
- Standard deviation of the normal distribution from which values are sampled.- Returns:
- A matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If the standard deviation is negative.
-
randnMatrix
Generates a matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.- Parameters:
shape
- Shape of the resulting matrix.mean
- Mean of the normal distribution from which values are sampled.std
- Standard deviation of the normal distribution from which values are sampled.- Returns:
- A matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If the standard deviation is negative.
-
randomSymmetricMatrix
Generates a symmetric matrix filled with pseudorandom values uniformly distributed in[0, 1)
.- Parameters:
size
- Number of rows and columns in the resulting matrix (the result will be a square matrix).- Returns:
- A symmetric matrix filled with pseudorandom values uniformly distributed in
[0, 1)
.
-
randomSymmetricCooMatrix
Generates a symmetricCOO matrix
filled with pseudorandom values uniformly distributed in[min, max)
.- Parameters:
size
- Number of rows and columns in the resulting matrix (the result will be a square matrix).min
- Minimum value in uniform distribution.max
- Maximum value in uniform distribution.sparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
. The true sparsity may slightly differ to ensure the matrix is symmetric.- Returns:
- A symmetric matrix filled with pseudorandom values uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifsparsity
is not in the range[0.0, 1.0]
.
-
randomSymmetricCsrMatrix
Generates a symmetricCSR matrix
filled with pseudorandom values uniformly distributed in[min, max)
.- Parameters:
size
- Number of rows and columns in the resulting matrix (the result will be a square matrix).min
- Minimum value in uniform distribution.max
- Maximum value in uniform distribution.sparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
. The true sparsity may slightly differ to ensure the matrix is symmetric.- Returns:
- A symmetric matrix filled with pseudorandom values uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifsparsity
is not in the range[0.0, 1.0]
.
-
randomOrthogonalMatrix
Gets a pseudorandom orthogonal matrix. From an implementation point of view, a pseudorandom matrix is generated as if byrandomMatrix(size, size)
. Then, aQR
decomposition is computed on this pseudorandom matrix and theQ
matrix from this decomposition is returned.- Parameters:
size
- Size of the orthogonal matrix (i.e. the number rows and columns for the square matrix).- Returns:
- A pseudorandom orthogonal matrix.
-
randomCMatrix
Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[0, 1)
.- Parameters:
rows
- Number of rows in the resulting matrix.cols
- Number of columns in the resulting matrix.- Returns:
- A matrix filled with pseudorandom complex values with magnitudes uniformly
distributed in
[0, 1)
.
-
randomCMatrix
Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[0, 1)
.- Parameters:
shape
- Shape of the resulting matrix. Must be of rank 2.- Returns:
- A matrix filled with pseudorandom complex values with magnitudes uniformly
distributed in
[0, 1)
. - Throws:
IllegalArgumentException
- If theshape
is not of rank 2.
-
randomCMatrix
Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[min, max)
.- Parameters:
rows
- Number of rows in the resulting matrix.cols
- Number of columns in the resulting matrix.min
- Minimum value of uniform distribution to sample from (inclusive).max
- Maximum value of uniform distribution to sample from (exclusive).- Returns:
- A matrix filled with pseudorandom complex values with magnitudes
uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmax
is less thanmin
.
-
randomCMatrix
Generates a matrix filled with pseudorandom complex values with magnitudes uniformly distributed in[min, max)
.- Parameters:
shape
- Shape of the resulting matrix. Must be of rank 2.min
- Minimum value of uniform distribution to sample from (inclusive).max
- Maximum value of uniform distribution to sample from (exclusive).- Returns:
- A matrix filled with pseudorandom complex values with magnitudes
uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmax
is less thanmin
.IllegalArgumentException
- Ifshape
is not of rank 2.
-
randnCMatrix
Generates a matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.- Parameters:
rows
- The number of rows in the resulting matrix.cols
- The number of columns in the resulting matrix.- Returns:
- A matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.
-
randnCMatrix
Generates a matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.- Parameters:
shape
- Shape of the resulting matrix.- Returns:
- A matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a mean of 0.0 and a standard deviation of 1.0.
-
randnCMatrix
Generates a matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a specified mean and standard deviation.- Parameters:
rows
- The number of rows in the resulting matrix.cols
- The number of columns in the resulting matrix.mean
- Mean of the normal distribution from which values are sampled.std
- Standard deviation of the normal distribution from which values are sampled.- Returns:
- A matrix filled with pseudorandom complex values with magnitudes sampled from a normal distribution with a specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If the standard deviation is negative.
-
randnCMatrix
Generates a matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.- Parameters:
shape
- Shape of the resulting matrix.mean
- Mean of the normal distribution from which values are sampled.std
- Standard deviation of the normal distribution from which values are sampled.- Returns:
- A matrix filled with pseudorandom values sampled from a normal distribution with a specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If the standard deviation is negative.
-
randomSparseCMatrix
Generates a random sparse matrix with the specified sparsity. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
rows
- Number of rows in the sparse matrix.cols
- Number of columns in the sparse matrix.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuessparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
.- Returns:
- A sparse matrix with sparsity approximately equal to
sparsity
filled with random values uniformly distributed in[min, max)
.
-
randomSparseCMatrix
Generates a random sparse matrix with the specified sparsity. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
shape
- Shape of the sparse matrix to generate.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuessparsity
- Desired sparsity of the resulting matrix. i.e. the percent of values which are zero. Must be a value in[0.0, 1.0]
.- Returns:
- A sparse matrix with sparsity approximately equal to
sparsity
filled with random values uniformly distributed in[min, max)
.
-
randomSparseCMatrix
public CooCMatrix randomSparseCMatrix(int rows, int cols, double min, double max, int numNonZeroEntries) Generates a random sparse matrix with the specified number of non-zero entries. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
rows
- Number of rows in the random sparse matrix.cols
- Number of columns in the random sparse matrix.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuesnumNonZeroEntries
- Desired number of non-zero entries int the random sparse matrix.- Returns:
- A sparse matrix filled with the specified number of non-zero entries uniformly
distributed in
[min, max)
.
-
randomSparseCMatrix
Generates a random sparse matrix with the specified number of non-zero entries. The non-zero values will have a uniform distribution in[min, max)
. Values will be uniformly distributed throughout the matrix.- Parameters:
shape
- Shape of the sparse matrix to generate.min
- Minimum value for random non-zero values in the sparse matrix.max
- Maximum value for random non-zero valuesnumNonZeroEntries
- Desired number of non-zero entries int the random sparse matrix.- Returns:
- A sparse matrix filled with the specified number of non-zero entries uniformly
distributed in
[min, max)
.
-
randomUnitaryMatrix
Gets a pseudorandom unitary matrix. From an implementation point of view, a pseudorandom complex matrix is generated as if byrandomCMatrix(size, size)
. Then, aQR
decomposition is computed on this pseudorandom matrix and theQ
matrix from this decomposition is returned.- Parameters:
size
- Size of the unitary matrix (i.e. the number rows and columns for the square matrix).- Returns:
- A pseudorandom unitary matrix.
-
randomTriuMatrix
Gets a pseudorandom upper triangular matrix of the specified size. The entries will be distributed according to a standard normal distribution with a mean of 0 and standard deviation of 1.- Parameters:
size
- Size if the upper triangular matrix.- Returns:
- A pseudorandom upper triangular matrix of the specified size.
-
geRandomTrilMatrix
Gets a pseudorandom lower triangular matrix of the specified size. The entries will be distributed according to a standard normal distribution with a mean of 0 and standard deviation of 1.- Parameters:
size
- Size if the lower triangular matrix.- Returns:
- A pseudorandom lower triangular matrix of the specified size.
-