pygeoinf 1.1.6__tar.gz → 1.1.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pygeoinf
3
- Version: 1.1.6
3
+ Version: 1.1.8
4
4
  Summary: A package for solving geophysical inference and inverse problems
5
5
  License: BSD-3-Clause
6
6
  Author: David Al-Attar and Dan Heathcote
@@ -223,6 +223,8 @@ class HilbertSpace(ABC):
223
223
  # Final (Non-Overridable) Methods #
224
224
  # ------------------------------------------------------------------- #
225
225
 
226
+
227
+
226
228
  @final
227
229
  @property
228
230
  def coordinate_inclusion(self) -> LinearOperator:
@@ -172,7 +172,12 @@ class IterativeLinearSolver(LinearSolver):
172
172
  """
173
173
  Solves the adjoint linear system A*y = x for y.
174
174
  """
175
- return self.solve_linear_system(operator.adjoint, preconditioner.adjoint, x, y0)
175
+ adjoint_preconditioner = (
176
+ None
177
+ if preconditioner is None
178
+ else preconditioner.adjoint
179
+ )
180
+ return self.solve_linear_system(operator.adjoint, adjoint_preconditioner, x, y0)
176
181
 
177
182
  def __call__(
178
183
  self,
@@ -336,18 +336,21 @@ class Lebesgue(CircleHelper, HilbertModule, AbstractInvariantLebesgueSpace):
336
336
 
337
337
  return self.kmax == other.kmax and self.radius == other.radius
338
338
 
339
- def invariant_automorphism(self, f: Callable[[float], float]):
339
+ def invariant_automorphism_from_index_function(self, g: Callable[[int], float]):
340
340
  """
341
341
  Implements an invariant automorphism of the form f(Δ) using Fourier
342
342
  expansions on a circle.
343
343
 
344
+ For this method, the function f is given implicitly in terms of a
345
+ function, g, of the eigenvalue indices for the space. Letting k(λ) be
346
+ the index for eigenvalue λ, we then have f(λ) = g(k(λ)).
347
+
344
348
  Args:
345
- f: A real-valued function that is well-defined on the spectrum
346
- of the Laplacian, Δ.
349
+ g: A real-valued function of the eigenvalue index.
347
350
  """
348
351
 
349
352
  values = np.fromiter(
350
- (f(self.laplacian_eigenvalue(k)) for k in range(self.kmax + 1)),
353
+ (g(k) for k in range(self.kmax + 1)),
351
354
  dtype=float,
352
355
  )
353
356
  matrix = diags([values], [0])
@@ -160,6 +160,17 @@ class SphereHelper:
160
160
  l = k[0]
161
161
  return l * (l + 1) / self.radius**2
162
162
 
163
+ def degree_from_laplacian_eigenvalue(self, eig: float) -> float:
164
+ """
165
+ Returns the degree corresponding to a given eigenvalue.
166
+
167
+ Note that the value is returned as a float
168
+
169
+ Args:
170
+ eig: The eigenvalue.
171
+ """
172
+ return np.sqrt(self.radius**2 * eig + 0.25)
173
+
163
174
  def trace_of_invariant_automorphism(self, f: Callable[[float], float]) -> float:
164
175
  """
165
176
  Returns the trace of the automorphism of the form f(Δ) with f a function
@@ -444,10 +455,10 @@ class Lebesgue(SphereHelper, HilbertModule, AbstractInvariantLebesgueSpace):
444
455
  dtype=float,
445
456
  )
446
457
 
447
- def invariant_automorphism(self, f: Callable[[float], float]) -> LinearOperator:
448
- values = self._degree_dependent_scaling_values(
449
- lambda l: f(self.laplacian_eigenvalue((l, 0)))
450
- )
458
+ def invariant_automorphism_from_index_function(
459
+ self, g: Callable[[(int, int)], float]
460
+ ) -> LinearOperator:
461
+ values = self._degree_dependent_scaling_values(lambda l: g((l, 0)))
451
462
  matrix = diags([values], [0])
452
463
 
453
464
  def mapping(u):
@@ -30,6 +30,8 @@ AbstractInvariantSobolevSpace
30
30
  from __future__ import annotations
31
31
  from abc import ABC, abstractmethod
32
32
  from typing import Callable, Any, List
33
+
34
+
33
35
  import numpy as np
34
36
  from scipy.sparse import diags
35
37
 
@@ -98,6 +100,26 @@ class AbstractInvariantLebesgueSpace(ABC):
98
100
  """Returns a list of the norms of the eigenfunctions."""
99
101
 
100
102
  @abstractmethod
103
+ def invariant_automorphism_from_index_function(
104
+ self, g: Callable[[int | tuple[int, ...]], float]
105
+ ) -> LinearOperator:
106
+ """
107
+ Returns an automorphism of the form f(Δ) with f a function
108
+ that is well-defined on the spectrum of the Laplacian, Δ.
109
+
110
+ In order to be well-defined, the function must have appropriate
111
+ growth properties. For example, in an L² space we need f to be bounded.
112
+ In Sobolev spaces Hˢ a more complex condition holds depending on the
113
+ Sobolev order. These conditions on the function are not checked.
114
+
115
+ For this method, the function f is given implicitly in terms of a
116
+ function, g, of the eigenvalue indices for the space. Letting k(λ) be
117
+ the index for eigenvalue λ, we then have f(λ) = g(k(λ)).
118
+
119
+ Args:
120
+ g: A function that takes an eigenvalue index and returns a real value.
121
+ """
122
+
101
123
  def invariant_automorphism(self, f: Callable[[float], float]) -> LinearOperator:
102
124
  """
103
125
  Returns an automorphism of the form f(Δ) with f a function
@@ -111,7 +133,15 @@ class AbstractInvariantLebesgueSpace(ABC):
111
133
  Args:
112
134
  f: A real-valued function that is well-defined on the spectrum
113
135
  of the Laplacian.
136
+
137
+ Notes:
138
+ This method is a convenience wrapper for the more general
139
+ `invariant_automorphism_from_index_function`. It could be
140
+ overriden if computationally advantageous.
114
141
  """
142
+ return self.invariant_automorphism_from_index_function(
143
+ lambda k: f(self.laplacian_eigenvalue(k))
144
+ )
115
145
 
116
146
  @abstractmethod
117
147
  def trace_of_invariant_automorphism(self, f: Callable[[float], float]) -> float:
@@ -351,16 +381,26 @@ class AbstractInvariantSobolevSpace(AbstractInvariantLebesgueSpace):
351
381
  self, EuclideanSpace(dim), matrix, galerkin=True
352
382
  )
353
383
 
354
- def invariant_automorphism(self, f: Callable[[float], float]):
384
+ def invariant_automorphism_from_index_function(
385
+ self, g: Callable[[int | tuple[int, ...]], float]
386
+ ):
355
387
  """
356
- Returns an invariant automorphism of the form f(Δ) making use of the equivalent
357
- operator on the underlying Lebesgue space.
388
+ Returns an automorphism of the form f(Δ) with f a function
389
+ that is well-defined on the spectrum of the Laplacian, Δ.
390
+
391
+ In order to be well-defined, the function must have appropriate
392
+ growth properties. For example, in an L² space we need f to be bounded.
393
+ In Sobolev spaces Hˢ a more complex condition holds depending on the
394
+ Sobolev order. These conditions on the function are not checked.
395
+
396
+ For this method, the function f is given implicitly in terms of a
397
+ function, g, of the eigenvalue indices for the space. Letting k(λ) be
398
+ the index for eigenvalue λ, we then have f(λ) = g(k(λ)).
358
399
 
359
400
  Args:
360
- f: A real-valued function that is well-defined on the spectrum
361
- of the Laplacian, Δ.
401
+ g: A function that takes an eigenvalue index and returns a real value.
362
402
  """
363
- A = self.underlying_space.invariant_automorphism(f)
403
+ A = self.underlying_space.invariant_automorphism_from_index_function(g)
364
404
  return LinearOperator.from_formally_self_adjoint(self, A)
365
405
 
366
406
  def point_value_scaled_invariant_gaussian_measure(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pygeoinf"
3
- version = "1.1.6"
3
+ version = "1.1.8"
4
4
  description = "A package for solving geophysical inference and inverse problems"
5
5
  authors = ["David Al-Attar and Dan Heathcote"]
6
6
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes