Commit 4e671932 authored by Martin Reinecke's avatar Martin Reinecke

Merge remote-tracking branch 'upstream/NIFTy_5' into simplify_for_const

parents 0fd92060 eba1fd40
image: $CONTAINER_TEST_IMAGE image: $CONTAINER_TEST_IMAGE
variables: variables:
CONTAINER_TEST_IMAGE: gitlab-registry.mpcdf.mpg.de/ift/nifty-dev:$CI_BUILD_REF_NAME CONTAINER_TEST_IMAGE: gitlab-registry.mpcdf.mpg.de/$CI_PROJECT_PATH:$CI_BUILD_REF_NAME
OMP_NUM_THREADS: 1 OMP_NUM_THREADS: 1
stages: stages:
...@@ -39,9 +39,9 @@ test_serial: ...@@ -39,9 +39,9 @@ test_serial:
script: script:
- pytest-3 -q --cov=nifty5 test - pytest-3 -q --cov=nifty5 test
- > - >
python3 -m coverage report --omit "*plot*,*distributed_do*" python3 -m coverage report --omit "*plot*,*distributed_do*" | tee coverage.txt
- > - >
python3 -m coverage report --omit "*plot*,*distributed_do*" | grep TOTAL | awk '{ print "TOTAL: "$4; }' grep TOTAL coverage.txt | awk '{ print "TOTAL: "$4; }'
test_mpi: test_mpi:
stage: test stage: test
...@@ -52,17 +52,15 @@ test_mpi: ...@@ -52,17 +52,15 @@ test_mpi:
pages: pages:
stage: release stage: release
before_script:
- ls
script: script:
- python3 setup.py install --user -f
- sh docs/generate.sh - sh docs/generate.sh
- mv docs/build/ public/ - mv docs/build/ public/
artifacts: artifacts:
paths: paths:
- public - public
only: only:
- NIFTy_4 - NIFTy_5
before_script: before_script:
- python3 setup.py install --user -f - python3 setup.py install --user -f
......
...@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y \ ...@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y \
# Packages needed for NIFTy # Packages needed for NIFTy
python3-scipy \ python3-scipy \
# Documentation build dependencies # Documentation build dependencies
python3-sphinx-rtd-theme \ python3-sphinx-rtd-theme dvipng texlive-latex-base texlive-latex-extra \
# Testing dependencies # Testing dependencies
python3-pytest-cov jupyter \ python3-pytest-cov jupyter \
# Optional NIFTy dependencies # Optional NIFTy dependencies
......
NIFTy - Numerical Information Field Theory NIFTy - Numerical Information Field Theory
========================================== ==========================================
[![build status](https://gitlab.mpcdf.mpg.de/ift/nifty-dev/badges/NIFTy_5/build.svg)](https://gitlab.mpcdf.mpg.de/ift/nifty-dev/commits/NIFTy_5) [![build status](https://gitlab.mpcdf.mpg.de/ift/NIFTy/badges/NIFTy_5/build.svg)](https://gitlab.mpcdf.mpg.de/ift/NIFTy/commits/NIFTy_5)
[![coverage report](https://gitlab.mpcdf.mpg.de/ift/nifty-dev/badges/NIFTy_5/coverage.svg)](https://gitlab.mpcdf.mpg.de/ift/nifty-dev/commits/NIFTy_5) [![coverage report](https://gitlab.mpcdf.mpg.de/ift/NIFTy/badges/NIFTy_5/coverage.svg)](https://gitlab.mpcdf.mpg.de/ift/NIFTy/commits/NIFTy_5)
**NIFTy** project homepage: **NIFTy** project homepage:
[http://ift.pages.mpcdf.de/NIFTy](http://ift.pages.mpcdf.de/NIFTy) [http://ift.pages.mpcdf.de/nifty](http://ift.pages.mpcdf.de/nifty)
Summary Summary
------- -------
...@@ -13,23 +13,31 @@ Summary ...@@ -13,23 +13,31 @@ Summary
**NIFTy**, "**N**umerical **I**nformation **F**ield **T**heor<strong>y</strong>", is **NIFTy**, "**N**umerical **I**nformation **F**ield **T**heor<strong>y</strong>", is
a versatile library designed to enable the development of signal a versatile library designed to enable the development of signal
inference algorithms that operate regardless of the underlying spatial inference algorithms that operate regardless of the underlying grids
grid and its resolution. Its object-oriented framework is written in (spatial, spectral, temporal, …) and their resolutions.
Python, although it accesses libraries written in C++ and C for Its object-oriented framework is written in Python, although it accesses
efficiency. libraries written in C++ and C for efficiency.
NIFTy offers a toolkit that abstracts discretized representations of NIFTy offers a toolkit that abstracts discretized representations of
continuous spaces, fields in these spaces, and operators acting on continuous spaces, fields in these spaces, and operators acting on
fields into classes. The correct normalization of operations on these fields into classes.
fields is taken care of automatically without concerning the user. This This allows for an abstract formulation and programming of inference
allows for an abstract formulation and programming of inference
algorithms, including those derived within information field theory. algorithms, including those derived within information field theory.
Thus, NIFTy permits its user to rapidly prototype algorithms in 1D, and NIFTy's interface is designed to resemble IFT formulae in the sense
then apply the developed code in higher-dimensional settings of real that the user implements algorithms in NIFTy independent of the topology
world problems. The set of spaces on which NIFTy operates comprises of the underlying spaces and the discretization scheme.
point sets, *n*-dimensional regular grids, spherical spaces, their Thus, the user can develop algorithms on subsets of problems and on
harmonic counterparts, and product spaces constructed as combinations of spaces where the detailed performance of the algorithm can be properly
those. evaluated and then easily generalize them to other, more complex spaces
and the full problem, respectively.
The set of spaces on which NIFTy operates comprises point sets,
*n*-dimensional regular grids, spherical spaces, their harmonic
counterparts, and product spaces constructed as combinations of those.
NIFTy takes care of numerical subtleties like the normalization of
operations on fields and the numerical representation of model
components, allowing the user to focus on formulating the abstract
inference procedures and process-specific model properties.
Installation Installation
...@@ -52,7 +60,7 @@ Optional dependencies: ...@@ -52,7 +60,7 @@ Optional dependencies:
The current version of Nifty5 can be obtained by cloning the repository and The current version of Nifty5 can be obtained by cloning the repository and
switching to the NIFTy_5 branch: switching to the NIFTy_5 branch:
git clone https://gitlab.mpcdf.mpg.de/ift/NIFTy.git git clone https://gitlab.mpcdf.mpg.de/ift/nifty.git
### Installation ### Installation
...@@ -62,18 +70,19 @@ distributions, the "apt" lines will need slight changes. ...@@ -62,18 +70,19 @@ distributions, the "apt" lines will need slight changes.
NIFTy5 and its mandatory dependencies can be installed via: NIFTy5 and its mandatory dependencies can be installed via:
sudo apt-get install git python3 python3-pip python3-dev sudo apt-get install git python3 python3-pip python3-dev
pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/NIFTy.git@NIFTy_5 pip3 install --user git+https://gitlab.mpcdf.mpg.de/ift/nifty.git@NIFTy_5
Plotting support is added via: Plotting support is added via:
pip3 install --user matplotlib sudo apt-get install python3-matplotlib
FFTW support is added via: NIFTy uses Numpy's FFT implementation by default. For large problems FFTW may be
used because of its higher performance. It can be installed via:
sudo apt-get install libfftw3-dev sudo apt-get install libfftw3-dev
pip3 install --user pyfftw pip3 install --user pyfftw
To actually use FFTW in your Nifty calculations, you need to call To enable FFTW usage in NIFTy, call
nifty5.fft.enable_fftw() nifty5.fft.enable_fftw()
...@@ -90,14 +99,13 @@ Support for spherical harmonic transforms is added via: ...@@ -90,14 +99,13 @@ Support for spherical harmonic transforms is added via:
MPI support is added via: MPI support is added via:
sudo apt-get install openmpi-bin libopenmpi-dev sudo apt-get install python3-mpi4py
pip3 install --user mpi4py
### Running the tests ### Running the tests
To run the tests, additional packages are required: To run the tests, additional packages are required:
sudo apt-get install python3-coverage python3-pytest python3-pytest-cov sudo apt-get install python3-pytest-cov
Afterwards the tests (including a coverage report) can be run using the Afterwards the tests (including a coverage report) can be run using the
following command in the repository root: following command in the repository root:
...@@ -108,13 +116,13 @@ following command in the repository root: ...@@ -108,13 +116,13 @@ following command in the repository root:
### First Steps ### First Steps
For a quick start, you can browse through the [informal For a quick start, you can browse through the [informal
introduction](http://ift.pages.mpcdf.de/NIFTy/code.html) or introduction](http://ift.pages.mpcdf.de/nifty/code.html) or
dive into NIFTy by running one of the demonstrations, e.g.: dive into NIFTy by running one of the demonstrations, e.g.:
python3 demos/getting_started_1.py python3 demos/getting_started_1.py
### Acknowledgement ### Acknowledgements
Please acknowledge the use of NIFTy in your publication(s) by using a Please acknowledge the use of NIFTy in your publication(s) by using a
phrase such as the following: phrase such as the following:
...@@ -122,10 +130,10 @@ phrase such as the following: ...@@ -122,10 +130,10 @@ phrase such as the following:
> "Some of the results in this publication have been derived using the > "Some of the results in this publication have been derived using the
> NIFTy package [(https://gitlab.mpcdf.mpg.de/ift/NIFTy)](https://gitlab.mpcdf.mpg.de/ift/NIFTy)" > NIFTy package [(https://gitlab.mpcdf.mpg.de/ift/NIFTy)](https://gitlab.mpcdf.mpg.de/ift/NIFTy)"
and a citation to one of the [publications](http://ift.pages.mpcdf.de/NIFTy/citations.html). and a citation to one of the [publications](http://ift.pages.mpcdf.de/nifty/citations.html).
### Release Notes ### Licensing terms
The NIFTy package is licensed under the terms of the The NIFTy package is licensed under the terms of the
[GPLv3](https://www.gnu.org/licenses/gpl.html) and is distributed [GPLv3](https://www.gnu.org/licenses/gpl.html) and is distributed
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
# 1D (set mode=0), 2D (mode=1), or on the sphere (mode=2) # 1D (set mode=0), 2D (mode=1), or on the sphere (mode=2)
############################################################################### ###############################################################################
import sys
import numpy as np import numpy as np
import nifty5 as ift import nifty5 as ift
...@@ -54,7 +56,11 @@ if __name__ == '__main__': ...@@ -54,7 +56,11 @@ if __name__ == '__main__':
np.random.seed(42) np.random.seed(42)
# Choose space on which the signal field is defined # Choose space on which the signal field is defined
mode = 1 if len(sys.argv) == 2:
mode = int(sys.argv[1])
else:
mode = 1
if mode == 0: if mode == 0:
# One-dimensional regular grid # One-dimensional regular grid
position_space = ift.RGSpace([1024]) position_space = ift.RGSpace([1024])
...@@ -135,6 +141,7 @@ if __name__ == '__main__': ...@@ -135,6 +141,7 @@ if __name__ == '__main__':
# Plotting # Plotting
rg = isinstance(position_space, ift.RGSpace) rg = isinstance(position_space, ift.RGSpace)
plot = ift.Plot() plot = ift.Plot()
filename = "getting_started_1_mode_{}.png".format(mode)
if rg and len(position_space.shape) == 1: if rg and len(position_space.shape) == 1:
plot.add( plot.add(
[HT(MOCK_SIGNAL), GR.adjoint(data), [HT(MOCK_SIGNAL), GR.adjoint(data),
...@@ -142,10 +149,11 @@ if __name__ == '__main__': ...@@ -142,10 +149,11 @@ if __name__ == '__main__':
label=['Mock signal', 'Data', 'Reconstruction'], label=['Mock signal', 'Data', 'Reconstruction'],
alpha=[1, .3, 1]) alpha=[1, .3, 1])
plot.add(mask_to_nan(mask, HT(m - MOCK_SIGNAL)), title='Residuals') plot.add(mask_to_nan(mask, HT(m - MOCK_SIGNAL)), title='Residuals')
plot.output(nx=2, ny=1, xsize=10, ysize=4, title="getting_started_1") plot.output(nx=2, ny=1, xsize=10, ysize=4, name=filename)
else: else:
plot.add(HT(MOCK_SIGNAL), title='Mock Signal') plot.add(HT(MOCK_SIGNAL), title='Mock Signal')
plot.add(mask_to_nan(mask, (GR(Mask)).adjoint(data)), title='Data') plot.add(mask_to_nan(mask, (GR(Mask)).adjoint(data)), title='Data')
plot.add(HT(m), title='Reconstruction') plot.add(HT(m), title='Reconstruction')
plot.add(mask_to_nan(mask, HT(m - MOCK_SIGNAL)), title='Residuals') plot.add(mask_to_nan(mask, HT(m - MOCK_SIGNAL)), title='Residuals')
plot.output(nx=2, ny=2, xsize=10, ysize=10, title="getting_started_1") plot.output(nx=2, ny=2, xsize=10, ysize=10, name=filename)
print("Saved results as '{}'.".format(filename))
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
# 1D (set mode=0), 2D (mode=1), or on the sphere (mode=2) # 1D (set mode=0), 2D (mode=1), or on the sphere (mode=2)
############################################################################### ###############################################################################
import sys
import numpy as np import numpy as np
import nifty5 as ift import nifty5 as ift
...@@ -42,23 +44,26 @@ def exposure_2d(): ...@@ -42,23 +44,26 @@ def exposure_2d():
if __name__ == '__main__': if __name__ == '__main__':
# FIXME All random seeds to 42 np.random.seed(42)
np.random.seed(41)
# Choose space on which the signal field is defined # Choose space on which the signal field is defined
mode = 2 if len(sys.argv) == 2:
mode = int(sys.argv[1])
else:
mode = 1
if mode == 0: if mode == 0:
# One-dimensional regular grid with uniform exposure # One-dimensional regular grid with uniform exposure of 10
position_space = ift.RGSpace(1024) position_space = ift.RGSpace(1024)
exposure = ift.Field.full(position_space, 1.) exposure = ift.Field.full(position_space, 10.)
elif mode == 1: elif mode == 1:
# Two-dimensional regular grid with inhomogeneous exposure # Two-dimensional regular grid with inhomogeneous exposure
position_space = ift.RGSpace([512, 512]) position_space = ift.RGSpace([512, 512])
exposure = exposure_2d() exposure = exposure_2d()
else: else:
# Sphere with uniform exposure # Sphere with uniform exposure of 100
position_space = ift.HPSpace(128) position_space = ift.HPSpace(128)
exposure = ift.Field.full(position_space, 1.) exposure = ift.Field.full(position_space, 100.)
# Define harmonic space and harmonic transform # Define harmonic space and harmonic transform
harmonic_space = position_space.get_default_codomain() harmonic_space = position_space.get_default_codomain()
...@@ -107,9 +112,11 @@ if __name__ == '__main__': ...@@ -107,9 +112,11 @@ if __name__ == '__main__':
# Plotting # Plotting
signal = sky(mock_position) signal = sky(mock_position)
reconst = sky(H.position) reconst = sky(H.position)
filename = "getting_started_2_mode_{}.png".format(mode)
plot = ift.Plot() plot = ift.Plot()
plot.add(signal, title='Signal') plot.add(signal, title='Signal')
plot.add(GR.adjoint(data), title='Data') plot.add(GR.adjoint(data), title='Data')
plot.add(reconst, title='Reconstruction') plot.add(reconst, title='Reconstruction')
plot.add(reconst - signal, title='Residuals') plot.add(reconst - signal, title='Residuals')
plot.output(name='getting_started_2.pdf', xsize=16, ysize=16) plot.output(xsize=12, ysize=10, name=filename)
print("Saved results as '{}'.".format(filename))
...@@ -17,10 +17,16 @@ ...@@ -17,10 +17,16 @@
############################################################ ############################################################
# Non-linear tomography # Non-linear tomography
# The data is integrated lines of sight #
# Random lines (set mode=0), radial lines (mode=1) # The signal is a sigmoid-normal distributed field.
# The data is the field integrated along lines of sight that are
# randomly (set mode=0) or radially (mode=1) distributed
#
# Demo takes a while to compute
############################################################# #############################################################
import sys
import numpy as np import numpy as np
import nifty5 as ift import nifty5 as ift
...@@ -28,22 +34,26 @@ import nifty5 as ift ...@@ -28,22 +34,26 @@ import nifty5 as ift
def random_los(n_los): def random_los(n_los):
starts = list(np.random.uniform(0, 1, (n_los, 2)).T) starts = list(np.random.uniform(0, 1, (n_los, 2)).T)
ends = list(0.5 + 0*np.random.uniform(0, 1, (n_los, 2)).T) ends = list(np.random.uniform(0, 1, (n_los, 2)).T)
return starts, ends return starts, ends
def radial_los(n_los): def radial_los(n_los):
starts = list(np.random.uniform(0, 1, (n_los, 2)).T) starts = list(np.random.uniform(0, 1, (n_los, 2)).T)
ends = list(np.random.uniform(0, 1, (n_los, 2)).T) ends = list(0.5 + 0*np.random.uniform(0, 1, (n_los, 2)).T)
return starts, ends return starts, ends
if __name__ == '__main__': if __name__ == '__main__':
np.random.seed(420) np.random.seed(420)
# Choose between random line-of-sight response (mode=1) and radial lines # Choose between random line-of-sight response (mode=0) and radial lines
# of sight (mode=2) # of sight (mode=1)
mode = 1 if len(sys.argv) == 2:
mode = int(sys.argv[1])
else:
mode = 0
filename = "getting_started_3_mode_{}_".format(mode) + "{}.png"
position_space = ift.RGSpace([128, 128]) position_space = ift.RGSpace([128, 128])
harmonic_space = position_space.get_default_codomain() harmonic_space = position_space.get_default_codomain()
...@@ -62,8 +72,8 @@ if __name__ == '__main__': ...@@ -62,8 +72,8 @@ if __name__ == '__main__':
# Power-law part of spectrum: # Power-law part of spectrum:
'sm': -5, # preferred power-law slope 'sm': -5, # preferred power-law slope
'sv': .5, # low variance of power-law slope 'sv': .5, # low variance of power-law slope
'im': .4, # y-intercept mean 'im': 0, # y-intercept mean, in-/decrease for more/less contrast
'iv': .3 # relatively high y-intercept variance 'iv': .3 # y-intercept variance
} }
A = ift.SLAmplitude(**dct) A = ift.SLAmplitude(**dct)
...@@ -79,7 +89,7 @@ if __name__ == '__main__': ...@@ -79,7 +89,7 @@ if __name__ == '__main__':
signal = ift.sigmoid(correlated_field) signal = ift.sigmoid(correlated_field)
# Build the line-of-sight response and define signal response # Build the line-of-sight response and define signal response
LOS_starts, LOS_ends = random_los(100) if mode == 1 else radial_los(100) LOS_starts, LOS_ends = random_los(100) if mode == 0 else radial_los(100)
R = ift.LOSResponse(position_space, starts=LOS_starts, ends=LOS_ends) R = ift.LOSResponse(position_space, starts=LOS_starts, ends=LOS_ends)
signal_response = R(signal) signal_response = R(signal)
...@@ -109,7 +119,7 @@ if __name__ == '__main__': ...@@ -109,7 +119,7 @@ if __name__ == '__main__':
plot.add(signal(mock_position), title='Ground Truth') plot.add(signal(mock_position), title='Ground Truth')
plot.add(R.adjoint_times(data), title='Data') plot.add(R.adjoint_times(data), title='Data')
plot.add([A.force(mock_position)], title='Power Spectrum') plot.add([A.force(mock_position)], title='Power Spectrum')
plot.output(ny=1, nx=3, xsize=24, ysize=6, name="setup.png") plot.output(ny=1, nx=3, xsize=24, ysize=6, name=filename.format("setup"))
# number of samples used to estimate the KL # number of samples used to estimate the KL
N_samples = 20 N_samples = 20
...@@ -125,7 +135,8 @@ if __name__ == '__main__': ...@@ -125,7 +135,8 @@ if __name__ == '__main__':
plot = ift.Plot() plot = ift.Plot()
plot.add(signal(KL.position), title="reconstruction") plot.add(signal(KL.position), title="reconstruction")
plot.add([A.force(KL.position), A.force(mock_position)], title="power") plot.add([A.force(KL.position), A.force(mock_position)], title="power")
plot.output(ny=1, ysize=6, xsize=16, name="loop-{:02}.png".format(i)) plot.output(ny=1, ysize=6, xsize=16,
name=filename.format("loop_{:02d}".format(i)))
# Draw posterior samples # Draw posterior samples
KL = ift.MetricGaussianKL(mean, H, N_samples) KL = ift.MetricGaussianKL(mean, H, N_samples)
...@@ -134,6 +145,7 @@ if __name__ == '__main__': ...@@ -134,6 +145,7 @@ if __name__ == '__main__':
sc.add(signal(sample + KL.position)) sc.add(signal(sample + KL.position))
# Plotting # Plotting
filename_res = filename.format("results")
plot = ift.Plot() plot = ift.Plot()
plot.add(sc.mean, title="Posterior Mean") plot.add(sc.mean, title="Posterior Mean")
plot.add(ift.sqrt(sc.var), title="Posterior Standard Deviation") plot.add(ift.sqrt(sc.var), title="Posterior Standard Deviation")
...@@ -144,4 +156,5 @@ if __name__ == '__main__': ...@@ -144,4 +156,5 @@ if __name__ == '__main__':
A.force(mock_position)], A.force(mock_position)],
title="Sampled Posterior Power Spectrum", title="Sampled Posterior Power Spectrum",
linewidth=[1.]*len(powers) + [3., 3.]) linewidth=[1.]*len(powers) + [3., 3.])
plot.output(ny=1, nx=3, xsize=24, ysize=6, name="results.png") plot.output(ny=1, nx=3, xsize=24, ysize=6, name=filename_res)
print("Saved results as '{}'.".format(filename_res))
...@@ -44,7 +44,8 @@ def polynomial(coefficients, sampling_points): ...@@ -44,7 +44,8 @@ def polynomial(coefficients, sampling_points):
class PolynomialResponse(ift.LinearOperator): class PolynomialResponse(ift.LinearOperator):
"""Calculates values of a polynomial parameterized by input at sampling points. """Calculates values of a polynomial parameterized by input at sampling
points.
Parameters Parameters
---------- ----------
......
# rm -rf docs/build docs/source/mod rm -rf docs/build docs/source/mod
sphinx-apidoc -e -o docs/source/mod nifty5 sphinx-apidoc -e -o docs/source/mod nifty5
sphinx-build -b html docs/source/ docs/build/ sphinx-build -b html docs/source/ docs/build/
...@@ -41,7 +41,6 @@ Abstract base class ...@@ -41,7 +41,6 @@ Abstract base class
One of the fundamental building blocks of the NIFTy5 framework is the *domain*. One of the fundamental building blocks of the NIFTy5 framework is the *domain*.
Its required capabilities are expressed by the abstract :py:class:`Domain` class. Its required capabilities are expressed by the abstract :py:class:`Domain` class.
A domain must be able to answer the following queries: A domain must be able to answer the following queries:
m
- its total number of data entries (pixels), which is accessible via the - its total number of data entries (pixels), which is accessible via the
:attr:`~Domain.size` property :attr:`~Domain.size` property
...@@ -129,7 +128,7 @@ specify full field domains. In principle, a :class:`~domain_tuple.DomainTuple` ...@@ -129,7 +128,7 @@ specify full field domains. In principle, a :class:`~domain_tuple.DomainTuple`
can even be empty, which implies that the field living on it is a scalar. can even be empty, which implies that the field living on it is a scalar.
A :class:`~domain_tuple.DomainTuple` supports iteration and indexing, and also A :class:`~domain_tuple.DomainTuple` supports iteration and indexing, and also
provides the properties :attr:`~domain_tuple.DomainTuple.shape`, provides the properties :attr:`~domain_tuple.DomainTuple.shape` and
:attr:`~domain_tuple.DomainTuple.size` in analogy to the elementary :attr:`~domain_tuple.DomainTuple.size` in analogy to the elementary
:class:`~domains.domain.Domain`. :class:`~domains.domain.Domain`.
...@@ -159,10 +158,11 @@ Contractions (like summation, integration, minimum/maximum, computation of ...@@ -159,10 +158,11 @@ Contractions (like summation, integration, minimum/maximum, computation of
statistical moments) can be carried out either over an entire field (producing statistical moments) can be carried out either over an entire field (producing
a scalar result) or over sub-domains (resulting in a field defined on a smaller a scalar result) or over sub-domains (resulting in a field defined on a smaller
domain). Scalar products of two fields can also be computed easily. domain). Scalar products of two fields can also be computed easily.
See the documentation of :class:`~field.Field` for details.
There is also a set of convenience functions to generate fields with constant There is also a set of convenience functions to generate fields with constant
values or fields filled with random numbers according to a user-specified values or fields filled with random numbers according to a user-specified
distribution. distribution: :attr:`~sugar.full`, :attr:`~sugar.from_random`.
Like almost all NIFTy objects, fields are immutable: their value or any other Like almost all NIFTy objects, fields are immutable: their value or any other
attribute cannot be modified after construction. To manipulate a field in ways attribute cannot be modified after construction. To manipulate a field in ways
...@@ -311,11 +311,15 @@ and ``f1`` and ``f2`` are of type :class:`~field.Field`, writing:: ...@@ -311,11 +311,15 @@ and ``f1`` and ``f2`` are of type :class:`~field.Field`, writing::
will perform the operation suggested intuitively by the notation, checking will perform the operation suggested intuitively by the notation, checking
domain compatibility while building the composed operator. domain compatibility while building the composed operator.
The combined operator infers its domain and target from its constituents,
as well as the set of operations it can support.
The properties :attr:`~LinearOperator.adjoint` and The properties :attr:`~LinearOperator.adjoint` and
:attr:`~LinearOperator.inverse` return a new operator which behaves as if it :attr:`~LinearOperator.inverse` return a new operator which behaves as if it
were the original operator's adjoint or inverse, respectively. were the original operator's adjoint or inverse, respectively.
The combined operator infers its domain and target from its constituents,
as well as the set of operations it can support.
Instantiating operator adjoints or inverses by :attr:`~LinearOperator.adjoint`
and similar methods is to be distinguished from the instant application of
operators performed by :attr:`~LinearOperator.adjoint_times` and similar
methods.
.. _minimization: .. _minimization:
...@@ -368,8 +372,8 @@ failure. ...@@ -368,8 +372,8 @@ failure.
Sensible stopping criteria can vary significantly with the problem being Sensible stopping criteria can vary significantly with the problem being
solved; NIFTy provides one concrete sub-class of :class:`IterationController` solved; NIFTy provides one concrete sub-class of :class:`IterationController`