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
40a9d52f
Commit
40a9d52f
authored
May 19, 2020
by
Martin Reinecke
Browse files
try less ambiguous parameter name
parent
f3195322
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty6/operators/contraction_operator.py
View file @
40a9d52f
...
...
@@ -36,19 +36,19 @@ class ContractionOperator(LinearOperator):
spaces : None, int or tuple of int
The elements of "domain" which are contracted.
If `None`, everything is contracted
weight
: int, default=0
power
: int, default=0
If nonzero, the fields defined on self.domain are weighted with the
specified power along the submdomains which are contracted.
"""
def
__init__
(
self
,
domain
,
spaces
,
weight
=
0
):
def
__init__
(
self
,
domain
,
spaces
,
power
=
0
):
self
.
_domain
=
DomainTuple
.
make
(
domain
)
self
.
_spaces
=
utilities
.
parse_spaces
(
spaces
,
len
(
self
.
_domain
))
self
.
_target
=
[
dom
for
i
,
dom
in
enumerate
(
self
.
_domain
)
if
i
not
in
self
.
_spaces
]
self
.
_target
=
DomainTuple
.
make
(
self
.
_target
)
self
.
_
weight
=
weight
self
.
_
power
=
power
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
def
apply
(
self
,
x
,
mode
):
...
...
@@ -61,12 +61,12 @@ class ContractionOperator(LinearOperator):
shp
+=
tmp
if
i
not
in
self
.
_spaces
else
(
1
,)
*
len
(
dom
.
shape
)
ldat
=
np
.
broadcast_to
(
ldat
.
reshape
(
shp
),
self
.
_domain
.
shape
)
res
=
Field
(
self
.
_domain
,
ldat
)
if
self
.
_
weight
!=
0
:
res
=
res
.
weight
(
self
.
_
weight
,
spaces
=
self
.
_spaces
)
if
self
.
_
power
!=
0
:
res
=
res
.
weight
(
self
.
_
power
,
spaces
=
self
.
_spaces
)
return
res
else
:
if
self
.
_
weight
!=
0
:
x
=
x
.
weight
(
self
.
_
weight
,
spaces
=
self
.
_spaces
)
if
self
.
_
power
!=
0
:
x
=
x
.
weight
(
self
.
_
power
,
spaces
=
self
.
_spaces
)
res
=
x
.
sum
(
self
.
_spaces
)
return
res
if
isinstance
(
res
,
Field
)
else
Field
.
scalar
(
res
)
...
...
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