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
Neel Shah
NIFTy
Commits
ea082396
Commit
ea082396
authored
Jun 23, 2021
by
Neel Shah
Browse files
Fix functionality for applying to a high dimensional domain
parent
94171dce
Pipeline
#104200
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/operators/matrix_product_operator.py
View file @
ea082396
...
...
@@ -104,8 +104,8 @@ class MatrixProductOperator(EndomorphicOperator):
appl_space_shape
=
tuple
(
appl_space_shape
)
self
.
_active_axes
=
tuple
(
active_axes
)
self
.
_mat_last_n
=
tuple
([
-
appl_dim
+
i
for
i
in
range
(
appl_dim
)])
self
.
_mat_first_n
=
np
.
arange
(
appl_dim
)
self
.
_mat_last_n
=
tuple
([
-
appl_dim
+
i
for
i
in
range
(
appl_dim
)])
self
.
_mat_first_n
=
np
.
arange
(
appl_dim
)
# Test if the matrix and the array it will be applied to fit
if
matrix
.
shape
[:
appl_dim
]
!=
appl_space_shape
:
...
...
@@ -126,7 +126,13 @@ class MatrixProductOperator(EndomorphicOperator):
if
self
.
_spaces
is
None
:
if
not
self
.
_flatten
:
res
=
m
.
dot
(
x
.
val
)
if
times
:
res
=
np
.
tensordot
(
m
,
x
.
val
,
axes
=
len
(
x
.
shape
))
else
:
mat_axes
=
np
.
flip
(
self
.
_mat_last_n
)
field_axes
=
self
.
_mat_first_n
res
=
np
.
tensordot
(
m
,
x
.
val
,
axes
=
(
mat_axes
,
field_axes
))
res
=
res
.
reshape
(
np
.
flip
(
res
.
shape
))
else
:
res
=
m
.
dot
(
x
.
val
.
flatten
()).
reshape
(
self
.
_domain
.
shape
)
return
Field
(
self
.
_domain
,
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