pygeoinf 1.2.7__py3-none-any.whl → 1.2.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pygeoinf/__init__.py CHANGED
@@ -9,6 +9,7 @@ from .random_matrix import (
9
9
  random_svd,
10
10
  random_eig,
11
11
  random_cholesky,
12
+ random_diagonal,
12
13
  )
13
14
 
14
15
  from .hilbert_space import (
@@ -32,7 +33,14 @@ from .linear_forms import (
32
33
 
33
34
  from .nonlinear_operators import NonLinearOperator
34
35
 
35
- from .linear_operators import LinearOperator, DiagonalLinearOperator, NormalSumOperator
36
+ from .linear_operators import (
37
+ LinearOperator,
38
+ MatrixLinearOperator,
39
+ DenseMatrixLinearOperator,
40
+ SparseMatrixLinearOperator,
41
+ DiagonalSparseMatrixLinearOperator,
42
+ NormalSumOperator,
43
+ )
36
44
 
37
45
 
38
46
  from .gaussian_measure import (
@@ -28,11 +28,11 @@ from scipy.sparse import diags
28
28
  from scipy.stats import multivariate_normal
29
29
 
30
30
 
31
- from .hilbert_space import EuclideanSpace, HilbertModule
31
+ from .hilbert_space import EuclideanSpace, HilbertModule, Vector
32
32
 
33
33
  from .linear_operators import (
34
34
  LinearOperator,
35
- DiagonalLinearOperator,
35
+ DiagonalSparseMatrixLinearOperator,
36
36
  )
37
37
 
38
38
  from .direct_sum import (
@@ -40,17 +40,6 @@ from .direct_sum import (
40
40
  )
41
41
 
42
42
 
43
- # This block only runs for type checkers, not at runtime, to prevent
44
- # circular import errors while still allowing type hints.
45
- if TYPE_CHECKING:
46
- from .hilbert_space import HilbertSpace, EuclideanSpace
47
- from .operators import LinearOperator, DiagonalLinearOperator
48
- from .direct_sum import BlockDiagonalLinearOperator
49
-
50
- # Define a generic type for vectors in a Hilbert space
51
- Vector = TypeVar("Vector")
52
-
53
-
54
43
  class GaussianMeasure:
55
44
  """
56
45
  Represents a Gaussian measure on a Hilbert space.
@@ -76,29 +65,29 @@ class GaussianMeasure:
76
65
  inverse_covariance_factor: LinearOperator = None,
77
66
  ) -> None:
78
67
  """
79
- Initializes the GaussianMeasure.
68
+ Initializes the GaussianMeasure.
80
69
 
81
70
  The measure can be defined in several ways, primarily by providing
82
- either a covariance operator or a covariance factor.
83
-
84
- Args:
85
- covariance (LinearOperator, optional): A self-adjoint and positive
86
- semi-definite linear operator on the domain.
87
- covariance_factor (LinearOperator, optional): A linear operator L
88
- such that the covariance C = L @ L*.
89
- expectation (vector, optional): The expectation (mean) of the
90
- measure. Defaults to the zero vector of the space.
91
- sample (callable, optional): A function that returns a random
92
- sample from the measure. If a `covariance_factor` is given,
93
- a default sampler is created.
94
- inverse_covariance (LinearOperator, optional): The inverse of the
95
- covariance operator (the precision operator).
96
- inverse_covariance_factor (LinearOperator, optional): A factor Li
97
- of the inverse covariance, such that C_inv = Li.T @ Li.
98
-
99
- Raises:
100
- ValueError: If neither `covariance` nor `covariance_factor`
101
- is provided.
71
+ either a covariance operator or a covariance factor.
72
+
73
+ Args:
74
+ covariance (LinearOperator, optional): A self-adjoint and positive
75
+ semi-definite linear operator on the domain.
76
+ covariance_factor (LinearOperator, optional): A linear operator L
77
+ such that the covariance C = L @ L*.
78
+ expectation (vector, optional): The expectation (mean) of the
79
+ measure. Defaults to the zero vector of the space.
80
+ sample (callable, optional): A function that returns a random
81
+ sample from the measure. If a `covariance_factor` is given,
82
+ a default sampler is created.
83
+ inverse_covariance (LinearOperator, optional): The inverse of the
84
+ covariance operator (the precision operator).
85
+ inverse_covariance_factor (LinearOperator, optional): A factor Li
86
+ of the inverse covariance, such that C_inv = Li.T @ Li.
87
+
88
+ Raises:
89
+ ValueError: If neither `covariance` nor `covariance_factor`
90
+ is provided.
102
91
  """
103
92
  if covariance is None and covariance_factor is None:
104
93
  raise ValueError(
@@ -186,7 +175,7 @@ class GaussianMeasure:
186
175
  "Standard deviation vector does not have the correct length"
187
176
  )
188
177
  euclidean = EuclideanSpace(domain.dim)
189
- covariance_factor = DiagonalLinearOperator(
178
+ covariance_factor = DiagonalSparseMatrixLinearOperator.from_diagonal_values(
190
179
  euclidean, domain, standard_deviations
191
180
  )
192
181
  return GaussianMeasure(