Skip to content
GitLab
Menu
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
67071b5c
Commit
67071b5c
authored
Apr 06, 2020
by
Martin Reinecke
Browse files
allow makeOp to produce ScalingOperators
parent
eac8a311
Pipeline
#72295
passed with stages
in 21 minutes and 47 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty6/linearization.py
View file @
67071b5c
...
...
@@ -162,11 +162,11 @@ class Linearization(object):
def
__truediv__
(
self
,
other
):
if
isinstance
(
other
,
Linearization
):
return
self
.
__mul__
(
other
.
one_over
(
))
return
self
.
__mul__
(
other
.
ptw
(
"reciprocal"
))
return
self
.
__mul__
(
1.
/
other
)
def
__rtruediv__
(
self
,
other
):
return
self
.
reciprocal
(
).
__mul__
(
other
)
return
self
.
ptw
(
"
reciprocal
"
).
__mul__
(
other
)
def
__pow__
(
self
,
power
):
if
not
np
.
isscalar
(
power
):
...
...
nifty6/sugar.py
View file @
67071b5c
...
...
@@ -317,7 +317,7 @@ def makeDomain(domain):
return
DomainTuple
.
make
(
domain
)
def
makeOp
(
input
):
def
makeOp
(
input
,
dom
=
None
):
"""Converts a Field or MultiField to a diagonal operator.
Parameters
...
...
@@ -331,12 +331,22 @@ def makeOp(input):
- if MultiField, a BlockDiagonalOperator with entries given by this
MultiField is returned.
dom : DomainTuple or MultiDomain
if `input` is a scalar, this is used as the operator's domain
Notes
-----
No volume factors are applied.
"""
if
input
is
None
:
return
None
if
np
.
isscalar
(
input
):
if
not
isinstance
(
dom
,
(
DomaiTuple
,
MultiDomain
)):
raise
TypeError
(
"need proper `dom` argument"
)
return
SalingOperator
(
dom
,
input
)
if
dom
is
not
None
:
if
not
dom
==
input
.
domain
:
raise
ValueError
(
"domain mismatch"
)
if
input
.
domain
is
DomainTuple
.
scalar_domain
():
return
ScalingOperator
(
input
.
domain
,
float
(
input
.
val
))
if
isinstance
(
input
,
Field
):
...
...
Write
Preview
Supports
Markdown
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