Skip to content

Commit da13bd8

Browse files
committed
Fix determinant for cyclic Homogeneous correlations.
Non-cyclic homogeneous correlations are still broken. I still can't figure out how to get those working.
1 parent 5644bba commit da13bd8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/atmos_flux_inversion/correlations.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from numpy import sum as array_sum
2222
from scipy.special import gamma, kv as K_nu
2323
from scipy.sparse.linalg.interface import LinearOperator
24+
from scipy.fftpack import dctn, fftn
2425

2526
import pyfftw.interfaces.cache
2627
from pyfftw import next_fast_len
@@ -450,13 +451,14 @@ def det(self):
450451
-------
451452
float
452453
"""
454+
correlations = self._ifft(self._corr_fourier)
453455
if self._is_cyclic:
454-
return prod(self._corr_fourier.real)
455-
index = tuple(
456-
slice(1, None, 2)
457-
for _ in self._underlying_shape
458-
)
459-
return prod(self._corr_fourier[index].real)
456+
spectrum = fftn(correlations, shape=self._underlying_shape).real
457+
# The order is different from la.eigvalsh, but that
458+
# doesn't matter
459+
return prod(spectrum)
460+
spectrum = dctn(correlations, type=1, shape=self._underlying_shape)
461+
return prod(spectrum)
460462

461463

462464
def make_matrix(corr_func, shape):

0 commit comments

Comments
 (0)