Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
73012d6e
Commit
73012d6e
authored
Nov 12, 2019
by
Philipp Arras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out logvol
parent
02558ec9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
nifty5/library/correlated_fields.py
nifty5/library/correlated_fields.py
+21
-15
No files found.
nifty5/library/correlated_fields.py
View file @
73012d6e
...
...
@@ -83,6 +83,14 @@ def _logkl(power_space):
return
logkl
def
_log_vol
(
power_space
):
power_space
=
DomainTuple
.
make
(
power_space
)
assert
isinstance
(
power_space
[
0
],
PowerSpace
)
assert
len
(
power_space
)
==
1
logk_lengths
=
_log_k_lengths
(
power_space
[
0
])
return
logk_lengths
[
1
:]
-
logk_lengths
[:
-
1
]
class
_SlopeRemover
(
EndomorphicOperator
):
def
__init__
(
self
,
domain
):
self
.
_domain
=
makeDomain
(
domain
)
...
...
@@ -114,8 +122,7 @@ class _TwoLogIntegrations(LinearOperator):
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
if
not
isinstance
(
self
.
_target
[
0
],
PowerSpace
):
raise
TypeError
logk_lengths
=
_log_k_lengths
(
self
.
_target
[
0
])
self
.
_logvol
=
logk_lengths
[
1
:]
-
logk_lengths
[:
-
1
]
self
.
_log_vol
=
_log_vol
(
self
.
_target
[
0
])
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
...
...
@@ -125,7 +132,7 @@ class _TwoLogIntegrations(LinearOperator):
res
[
0
]
=
0
res
[
1
]
=
0
res
[
2
:]
=
np
.
cumsum
(
x
[
1
])
res
[
2
:]
=
(
res
[
2
:]
+
res
[
1
:
-
1
])
/
2
*
self
.
_logvol
+
x
[
0
]
res
[
2
:]
=
(
res
[
2
:]
+
res
[
1
:
-
1
])
/
2
*
self
.
_log
_
vol
+
x
[
0
]
res
[
2
:]
=
np
.
cumsum
(
res
[
2
:])
return
from_global_data
(
self
.
_target
,
res
)
else
:
...
...
@@ -133,7 +140,7 @@ class _TwoLogIntegrations(LinearOperator):
res
=
np
.
zeros
(
self
.
_domain
.
shape
)
x
[
2
:]
=
np
.
cumsum
(
x
[
2
:][::
-
1
])[::
-
1
]
res
[
0
]
+=
x
[
2
:]
x
[
2
:]
*=
self
.
_logvol
/
2.
x
[
2
:]
*=
self
.
_log
_
vol
/
2.
x
[
1
:
-
1
]
+=
x
[
2
:]
res
[
1
]
+=
np
.
cumsum
(
x
[
2
:][::
-
1
])[::
-
1
]
return
from_global_data
(
self
.
_domain
,
res
)
...
...
@@ -189,23 +196,22 @@ class _Amplitude(Operator):
assert
isinstance
(
target
[
0
],
PowerSpace
)
twolog
=
_TwoLogIntegrations
(
target
)
dt
=
twolog
.
_logvol
sc
=
np
.
zeros
(
twolog
.
domain
.
shape
)
sc
[
0
]
=
sc
[
1
]
=
np
.
sqrt
(
dt
)
sc
[
0
]
=
sc
[
1
]
=
np
.
sqrt
(
_log_vol
(
target
)
)
sc
=
from_global_data
(
twolog
.
domain
,
sc
)
expander
=
VdotOperator
(
sc
).
adjoint
sig
masq
=
expander
@
flexibility
sig
_flex
=
expander
@
flexibility
dist
=
np
.
zeros
(
twolog
.
domain
.
shape
,
dtype
=
np
.
float64
)
dist
[
0
]
+=
1
s
cale
=
VdotOperator
(
from_global_data
(
twolog
.
domain
,
s
ig_asp
=
VdotOperator
(
from_global_data
(
twolog
.
domain
,
dist
)).
adjoint
@
asperity
shift
=
np
.
ones
(
scale
.
target
.
shape
)
shift
[
0
]
=
dt
**
2
/
12.
shift
=
from_global_data
(
scale
.
target
,
shift
)
s
cale
=
sigmasq
*
(
Adder
(
shift
)
@
scale
).
sqrt
()
smooth
=
twolog
@
(
s
cale
*
ducktape
(
scale
.
target
,
None
,
key
))
shift
=
np
.
ones
(
twolog
.
domain
.
shape
)
shift
[
0
]
=
_log_vol
(
target
)
**
2
/
12.
shift
=
from_global_data
(
twolog
.
domain
,
shift
)
s
igma
=
sig_flex
*
(
Adder
(
shift
)
@
sig_asp
).
sqrt
()
smooth
=
twolog
@
(
s
igma
*
ducktape
(
twolog
.
domain
,
None
,
key
))
tg
=
smooth
.
target
noslope
=
_SlopeRemover
(
tg
)
@
smooth
...
...
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