-
Notifications
You must be signed in to change notification settings - Fork 121
Discrete convolution #1230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kohr-h
wants to merge
17
commits into
odlgroup:master
Choose a base branch
from
kohr-h:issue-209__convolution
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Discrete convolution #1230
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
86dc321
MAINT: rename ufunc_ops->oplib as place for "advanced" operators
68f8b70
STY: fix pep8 issue in ufunc_ops example
061453e
MAINT: fix bad oplib/__init__.py
a1689a3
ENH: add DiscreteConvolution operator
d499e13
TST: add tests for DiscreteConvolution init and 1d and 2d eval
edbfe65
ENH: add auto_weighting decorator for adjoints
dcc585d
ENH: add auto_weighting example
d810538
TST: add tests for auto_weighting decorator
b849f94
MAINT: catch and test real vs complex issues
e37cc53
ENH: implement adjoint of DiscreteConvolution
0db25e2
TST: add discrete convolution adjoint tests
d17c530
ENH: use out efficiently for pyfftw and no padding in convolution
913ffa3
TST: be less strict in convolution adjoint tests
72d0c9a
ENH: add backport of np.roll for multiple axes
kohr-h 3993bae
ENH: add utility function for convolution
kohr-h ad80169
ENH: add correlate helper for cross-correlation
kohr-h 7c89f67
DOC: add Return section to convolve doc
kohr-h File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| """Example demonstrating the usage of the ``auto_weighting`` decorator.""" | ||
|
|
||
| import odl | ||
| from odl.space.space_utils import auto_weighting | ||
|
|
||
|
|
||
| class ScalingOp(odl.Operator): | ||
|
|
||
| """Operator that scales input by a constant.""" | ||
|
|
||
| def __init__(self, dom, ran, c): | ||
| super(ScalingOp, self).__init__(dom, ran, linear=True) | ||
| self.c = c | ||
|
|
||
| def _call(self, x): | ||
| return self.c * x | ||
|
|
||
| @property | ||
| @auto_weighting | ||
| def adjoint(self): | ||
| return ScalingOp(self.range, self.domain, self.c) | ||
|
|
||
|
|
||
| rn = odl.rn(2) # Constant weight 1 | ||
| discr = odl.uniform_discr(0, 4, 2) # Constant weight 2 | ||
| print('*** Spaces ***') | ||
| print('Rn =', rn, '- weight =', rn.weighting.const) | ||
| print('discr =', discr, '- weight =', discr.weighting.const) | ||
| print('') | ||
|
|
||
| op1 = ScalingOp(rn, rn, 2) # Same weightings, no scaling in adjoint | ||
| op2 = ScalingOp(discr, discr, 2) # Same weightings, no scaling in adjoint | ||
| op3 = ScalingOp(rn, discr, 2) # Different weightings, adjoint scales | ||
|
|
||
| # Look at output of ajoint | ||
| print('*** Ajoint evaluation ***') | ||
| print('Rn -> Rn adjoint at one :', op1.adjoint(op1.range.one())) | ||
| print('discr -> discr adjoint at one:', op2.adjoint(op2.range.one())) | ||
| print('Rn -> discr adjoint at one :', op3.adjoint(op3.range.one())) | ||
| print('') | ||
|
|
||
| # Check adjointness | ||
| print('*** Check adjointness ***') | ||
| inner1_dom = op1.domain.one().inner(op1.adjoint(op1.range.one())) | ||
| inner1_ran = op1(op1.domain.one()).inner(op1.range.one()) | ||
| print('Rn -> Rn: <Sx, y> = {}, <x, S^*y> = {}' | ||
| ''.format(inner1_ran, inner1_dom)) | ||
|
|
||
| inner2_dom = op2.domain.one().inner(op2.adjoint(op2.range.one())) | ||
| inner2_ran = op2(op2.domain.one()).inner(op2.range.one()) | ||
| print('discr -> discr: <Sx, y> = {}, <x, S^*y> = {}' | ||
| ''.format(inner2_ran, inner2_dom)) | ||
|
|
||
| inner3_dom = op3.domain.one().inner(op3.adjoint(op3.range.one())) | ||
| inner3_ran = op3(op3.domain.one()).inner(op3.range.one()) | ||
| print('Rn -> discr: <Sx, y> = {}, <x, S^*y> = {}' | ||
| ''.format(inner3_ran, inner3_dom)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Copyright 2014-2017 The ODL contributors | ||
| # | ||
| # This file is part of ODL. | ||
| # | ||
| # This Source Code Form is subject to the terms of the Mozilla Public License, | ||
| # v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
| # obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| """Library of operators. | ||
|
|
||
| This submodule is a place for operators that either do not fit in any other | ||
| places or require "advanced" features of ODL that would make them hard | ||
| to put into any other submodule due to circular dependencies. | ||
| """ | ||
|
|
||
| from __future__ import absolute_import | ||
|
|
||
| __all__ = ('convolution', 'ufunc_ops') | ||
|
|
||
| from .convolution import * | ||
| __all__ += convolution.__all__ | ||
|
|
||
| from .ufunc_ops import * | ||
| __all__ += ufunc_ops.__all__ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads more like a test than an example, is it possible to make it easier on the eyes?