Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
164e7503
Commit
164e7503
authored
Jan 23, 2019
by
Philipp Arras
Browse files
Merge remote-tracking branch 'dev/NIFTy_5' into cosm
parents
f1fe163a
e1e58be3
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
docs/generate.sh
View file @
164e7503
# rm -rf docs/build docs/source/mod
sphinx-apidoc
-e
-o
docs/source/mod nifty5
sphinx-build
-b
html docs/source/ docs/build/
docs/source/ift.rst
View file @
164e7503
This diff is collapsed.
Click to expand it.
nifty5/library/correlated_fields.py
View file @
164e7503
...
...
@@ -25,7 +25,7 @@ from ..operators.harmonic_operators import HarmonicTransformOperator
from
..operators.simple_linear_operators
import
ducktape
def
CorrelatedField
(
target
,
amplitude_operator
,
name
=
'xi'
):
def
CorrelatedField
(
target
,
amplitude_operator
,
name
=
'xi'
,
codomain
=
None
):
"""Constructs an operator which turns a white Gaussian excitation field
into a correlated field.
...
...
@@ -43,16 +43,21 @@ def CorrelatedField(target, amplitude_operator, name='xi'):
amplitude_operator: Operator
name : string
:class:`MultiField` key for the xi-field.
codomain : Domain
The codomain for target[0]. If not supplied, it is inferred.
Returns
-------
Correlated field : Operator
Operator
Correlated field
"""
tgt
=
DomainTuple
.
make
(
target
)
if
len
(
tgt
)
>
1
:
raise
ValueError
h_space
=
tgt
[
0
].
get_default_codomain
()
ht
=
HarmonicTransformOperator
(
h_space
,
tgt
[
0
])
if
codomain
is
None
:
codomain
=
tgt
[
0
].
get_default_codomain
()
h_space
=
codomain
ht
=
HarmonicTransformOperator
(
h_space
,
target
=
tgt
[
0
])
p_space
=
amplitude_operator
.
target
[
0
]
power_distributor
=
PowerDistributor
(
h_space
,
p_space
)
A
=
power_distributor
(
amplitude_operator
)
...
...
@@ -75,7 +80,7 @@ def MfCorrelatedField(target, amplitudes, name='xi'):
Parameters
----------
target : Domain, DomainTuple or tuple of Domain
Target of the operator. Must contain exactly
one
space.
Target of the operator. Must contain exactly
two
space
s
.
amplitudes: iterable of Operator
List of two amplitude operators.
name : string
...
...
@@ -83,7 +88,8 @@ def MfCorrelatedField(target, amplitudes, name='xi'):
Returns
-------
Correlated field : Operator
Operator
Correlated field
"""
tgt
=
DomainTuple
.
make
(
target
)
if
len
(
tgt
)
!=
2
:
...
...
@@ -93,7 +99,7 @@ def MfCorrelatedField(target, amplitudes, name='xi'):
hsp
=
DomainTuple
.
make
([
tt
.
get_default_codomain
()
for
tt
in
tgt
])
ht1
=
HarmonicTransformOperator
(
hsp
,
target
=
tgt
[
0
],
space
=
0
)
ht2
=
HarmonicTransformOperator
(
ht1
.
target
,
space
=
1
)
ht2
=
HarmonicTransformOperator
(
ht1
.
target
,
target
=
tgt
[
1
],
space
=
1
)
ht
=
ht2
@
ht1
psp
=
[
aa
.
target
[
0
]
for
aa
in
amplitudes
]
...
...
nifty5/library/dynamic_operator.py
View file @
164e7503
...
...
@@ -43,7 +43,8 @@ def _make_dynamic_operator(target,
causal
,
minimum_phase
,
sigc
=
None
,
quant
=
None
):
quant
=
None
,
codomain
=
None
):
if
not
isinstance
(
target
,
RGSpace
):
raise
TypeError
(
"RGSpace required"
)
if
not
target
.
harmonic
:
...
...
@@ -64,7 +65,9 @@ def _make_dynamic_operator(target,
if
cone
and
(
sigc
is
None
or
quant
is
None
):
raise
RuntimeError
dom
=
DomainTuple
.
make
(
target
.
get_default_codomain
())
if
codomain
is
None
:
codomain
=
target
.
get_default_codomain
()
dom
=
DomainTuple
.
make
(
codomain
)
ops
=
{}
FFT
=
FFTOperator
(
dom
)
Real
=
Realizer
(
dom
)
...
...
nifty5/operators/energy_operators.py
View file @
164e7503
...
...
@@ -37,7 +37,7 @@ class EnergyOperator(Operator):
Examples
--------
- Information Hamiltonian, i.e. negative-log-probabilities.
- Gibbs free energy, i.e. an averaged Hamiltonian, aka Kullbac
h
-Leibler
- Gibbs free energy, i.e. an averaged Hamiltonian, aka Kullbac
k
-Leibler
divergence.
"""
_target
=
DomainTuple
.
scalar_domain
()
...
...
@@ -330,8 +330,8 @@ class AveragedEnergy(EnergyOperator):
Note
----
Having symmetrized residual samples, with both v_i and -v_i being
present ensures that the distribution mean is exactly represented.
Having symmetrized residual samples, with both v_i and -v_i being
present
,
ensures that the distribution mean is exactly represented.
:class:`AveragedEnergy(h)` approximates
:math:`
\\
left< H(f)
\\
right>_{G(f-m,D)}` if the residuals
...
...
nifty5/operators/field_zero_padder.py
View file @
164e7503
...
...
@@ -25,6 +25,29 @@ from .linear_operator import LinearOperator
class
FieldZeroPadder
(
LinearOperator
):
"""Operator which applies zero-padding to one of the subdomains of its
input field
Parameters
----------
domain : Domain, DomainTuple or tuple of Domain
The operator's input domain.
new_shape : list or tuple of int
The new dimensions of the subdomain which is zero-padded.
No entry must be smaller than the corresponding dimension in the
operator's domain.
space : int
The index of the subdomain to be zero-padded. If None, it is set to 0
if domain contains exactly one space. domain[space] must be an RGSpace.
central : bool
If `False`, padding is performed at the end of the domain axes,
otherwise in the middle.
Notes
-----
When doing central padding on an axis with an even length, the "central"
entry should in principle be split up; this is currently not done.
"""
def
__init__
(
self
,
domain
,
new_shape
,
space
=
0
,
central
=
False
):
self
.
_domain
=
DomainTuple
.
make
(
domain
)
self
.
_space
=
utilities
.
infer_space
(
self
.
_domain
,
space
)
...
...
nifty5/operators/qht_operator.py
View file @
164e7503
...
...
@@ -37,9 +37,11 @@ class QHTOperator(LinearOperator):
space : int
The index of the domain on which the operator acts.
target[space] must be a non-harmonic LogRGSpace.
codomain : Domain
The codomain for target[space]. If not supplied, it is inferred.
"""
def
__init__
(
self
,
target
,
space
=
0
):
def
__init__
(
self
,
target
,
space
=
0
,
codomain
=
None
):
self
.
_target
=
DomainTuple
.
make
(
target
)
self
.
_space
=
infer_space
(
self
.
_target
,
space
)
...
...
@@ -51,8 +53,9 @@ class QHTOperator(LinearOperator):
raise
TypeError
(
"target[space] must be a nonharmonic space"
)
self
.
_domain
=
[
dom
for
dom
in
self
.
_target
]
self
.
_domain
[
self
.
_space
]
=
\
self
.
_target
[
self
.
_space
].
get_default_codomain
()
if
codomain
is
None
:
codomain
=
self
.
_target
[
self
.
_space
].
get_default_codomain
()
self
.
_domain
[
self
.
_space
]
=
codomain
self
.
_domain
=
DomainTuple
.
make
(
self
.
_domain
)
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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