Beispiel #1
0
def _generate_metrics(rng, size, eigval_scale=0.1):
    eigval, eigvec = _generate_rand_eigval_eigvec(rng, size, eigval_scale)
    return [
        matrices.IdentityMatrix(),
        matrices.IdentityMatrix(size),
        matrices.PositiveDiagonalMatrix(eigval),
        matrices.DensePositiveDefiniteMatrix((eigvec * eigval) @ eigvec.T),
        matrices.EigendecomposedPositiveDefiniteMatrix(eigvec, eigval)
    ]
Beispiel #2
0
def metric_list(rng, size):
    eigval = np.exp(0.1 * rng.standard_normal(size))
    eigvec = np.linalg.qr(rng.standard_normal((size, size)))[0]
    return [
        matrices.IdentityMatrix(),
        matrices.IdentityMatrix(size),
        matrices.PositiveDiagonalMatrix(eigval),
        matrices.DensePositiveDefiniteMatrix((eigvec * eigval) @ eigvec.T),
        matrices.EigendecomposedPositiveDefiniteMatrix(eigvec, eigval),
    ]
Beispiel #3
0
 def __init__(self):
     super().__init__()
     for sz in SIZES:
         self.matrices[sz] = matrices.IdentityMatrix(sz)
         self.np_matrices[sz] = np.identity(sz)
Beispiel #4
0
 def __init__(self):
     super().__init__({
         sz: (matrices.IdentityMatrix(sz), np.identity(sz))
         for sz in SIZES
     })
Beispiel #5
0
 def matrix_pair(self, size):
     return matrices.IdentityMatrix(size), np.identity(size)
Beispiel #6
0
 def test_invalid_shape_matmul(self, matrix):
     with pytest.raises(ValueError, match="Inconsistent dimensions"):
         matrix @ matrices.IdentityMatrix(matrix.shape[1] + 1)
     with pytest.raises(ValueError, match="Inconsistent dimensions"):
         matrices.IdentityMatrix(matrix.shape[0] + 1) @ matrix
Beispiel #7
0
 def test_matrix_inequality_different_shapes(self, matrix):
     different_shape_matrix = matrices.IdentityMatrix(matrix.shape[0] + 1)
     assert matrix != different_shape_matrix
     assert hash(matrix) != hash(different_shape_matrix)