Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
83cc5351
Commit
83cc5351
authored
May 14, 2020
by
Martin Reinecke
Browse files
Merge branch 'changelog_entry' into 'NIFTy_6'
Add changelog entry See merge request
!459
parents
8353227e
c7867d8b
Pipeline
#74922
passed with stages
in 25 minutes and 8 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
83cc5351
...
...
@@ -10,9 +10,34 @@ convention is consistent with almost all other numerical FFT libraries.
Interface change in EndomorphicOperator.draw_sample()
=====================================================
This method now requires a `dtype` argument to be passed.
As a consequence, `dtype` moves to the first place of the argument list.
(This of course applies to all derived classes as well.)
Both complex-valued and real-valued Gaussian probability distributions have
Hermitian and positive endomorphisms as covariance. Just by looking at an
endomorphic operator itself it is not clear whether it is viewed as covariance
for real or complex Gaussians when a sample of the respective distribution shall
be drawn. Therefore, we introduce the method `draw_sample_with_dtype()` which
needs to be given the data type of the probability distribution. This function
is implemented for all operators which actually draw random numbers
(`DiagonalOperator` and `ScalingOperator`). The class `SamplingDtypeSetter` acts
as a wrapper for this kind of operators in order to fix the data type of the
distribution. Samples from these operators can be drawn with `.draw_sample()`.
In order to dive into those subtleties I suggest running the following code and
playing around with the dtypes.
```
import nifty6 as ift
import numpy as np
dom = ift.UnstructuredDomain(5)
dtype = [np.float64, np.complex128][1]
invcov = ift.ScalingOperator(dom, 3)
e = ift.GaussianEnergy(mean=ift.from_random('normal', dom, dtype=dtype),
inverse_covariance=invcov)
pos = ift.from_random('normal', dom, dtype=np.complex128)
lin = e(ift.Linearization.make_var(pos, want_metric=True))
met = lin.metric
print(met)
print(met.draw_sample())
```
MPI parallelisation over samples in MetricGaussianKL
====================================================
...
...
nifty6/operators/block_diagonal_operator.py
View file @
83cc5351
...
...
@@ -46,6 +46,10 @@ class BlockDiagonalOperator(EndomorphicOperator):
for
op
,
v
in
zip
(
self
.
_ops
,
x
.
values
()))
return
MultiField
(
self
.
_domain
,
val
)
def
draw_sample
(
self
,
from_inverse
=
False
):
val
=
tuple
(
op
.
draw_sample
(
from_inverse
)
for
op
in
self
.
_ops
)
return
MultiField
(
self
.
_domain
,
val
)
def
draw_sample_with_dtype
(
self
,
dtype
,
from_inverse
=
False
):
from
..sugar
import
from_random
val
=
tuple
(
...
...
nifty6/operators/sampling_enabler.py
View file @
83cc5351
...
...
@@ -146,3 +146,9 @@ class SamplingDtypeSetter(EndomorphicOperator):
def
draw_sample
(
self
,
from_inverse
=
False
):
return
self
.
_op
.
draw_sample_with_dtype
(
self
.
_dtype
,
from_inverse
=
from_inverse
)
def
__repr__
(
self
):
from
..utilities
import
indent
return
"
\n
"
.
join
((
f
"SamplingDtypeSetter
{
self
.
_dtype
}
:"
,
indent
(
self
.
_op
.
__repr__
())))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment