Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
431b7ea9
Commit
431b7ea9
authored
5 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Introduce partial insert
parent
76130897
No related branches found
No related tags found
1 merge request
!394
Introduce partial insert
Pipeline
#65085
passed
5 years ago
Stage: build_docker
Stage: test
Stage: demo_runs
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty6/operators/operator.py
+29
-0
29 additions, 0 deletions
nifty6/operators/operator.py
with
29 additions
and
0 deletions
nifty6/operators/operator.py
+
29
−
0
View file @
431b7ea9
...
@@ -79,6 +79,35 @@ class Operator(metaclass=NiftyMeta):
...
@@ -79,6 +79,35 @@ class Operator(metaclass=NiftyMeta):
return
NotImplemented
return
NotImplemented
return
_OpChain
.
make
((
self
,
x
))
return
_OpChain
.
make
((
self
,
x
))
def
partial_insert
(
self
,
x
):
from
..multi_domain
import
MultiDomain
if
not
isinstance
(
x
,
Operator
):
raise
TypeError
if
not
isinstance
(
self
.
domain
,
MultiDomain
):
raise
TypeError
if
not
isinstance
(
x
.
target
,
MultiDomain
):
raise
TypeError
bigdom
=
MultiDomain
.
union
([
self
.
domain
,
x
.
target
])
k1
,
k2
=
set
(
self
.
domain
.
keys
()),
set
(
x
.
target
.
keys
())
le
,
ri
=
k2
-
k1
,
k1
-
k2
leop
,
riop
=
self
,
x
if
len
(
ri
)
>
0
:
riop
=
riop
+
self
.
identity_operator
(
MultiDomain
.
make
({
kk
:
bigdom
[
kk
]
for
kk
in
ri
}))
if
len
(
le
)
>
0
:
leop
=
leop
+
self
.
identity_operator
(
MultiDomain
.
make
({
kk
:
bigdom
[
kk
]
for
kk
in
le
}))
return
leop
@
riop
@staticmethod
def
identity_operator
(
dom
):
from
.block_diagonal_operator
import
BlockDiagonalOperator
from
.scaling_operator
import
ScalingOperator
idops
=
{
kk
:
ScalingOperator
(
dd
,
1.
)
for
kk
,
dd
in
dom
.
items
()}
return
BlockDiagonalOperator
(
dom
,
idops
)
def
__mul__
(
self
,
x
):
def
__mul__
(
self
,
x
):
if
isinstance
(
x
,
Operator
):
if
isinstance
(
x
,
Operator
):
return
_OpProd
(
self
,
x
)
return
_OpProd
(
self
,
x
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment