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
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
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
6e6b4f76
Commit
6e6b4f76
authored
Jul 26, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
running, but not correctly
parent
4067aa04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
6 deletions
+22
-6
nifty5/field.py
nifty5/field.py
+2
-0
nifty5/operator.py
nifty5/operator.py
+18
-4
nifty5/operators/relaxed_sum_operator.py
nifty5/operators/relaxed_sum_operator.py
+2
-2
No files found.
nifty5/field.py
View file @
6e6b4f76
...
...
@@ -49,6 +49,8 @@ class Field(object):
def
__init__
(
self
,
domain
,
val
):
if
not
isinstance
(
domain
,
DomainTuple
):
raise
TypeError
(
"domain must be of type DomainTuple"
)
if
np
.
isscalar
(
val
):
val
=
np
.
full
((),
val
)
if
not
isinstance
(
val
,
dobj
.
data_object
):
raise
TypeError
(
"val must be of type dobj.data_object"
)
if
domain
.
shape
!=
val
.
shape
:
...
...
nifty5/operator.py
View file @
6e6b4f76
...
...
@@ -11,9 +11,10 @@ from .multi.multi_field import MultiField
class
Linearization
(
object
):
def
__init__
(
self
,
val
,
jac
):
def
__init__
(
self
,
val
,
jac
,
metric
=
None
):
self
.
_val
=
val
self
.
_jac
=
jac
self
.
_metric
=
metric
@
property
def
domain
(
self
):
...
...
@@ -31,17 +32,25 @@ class Linearization(object):
def
jac
(
self
):
return
self
.
_jac
@
property
def
metric
(
self
):
return
self
.
_metric
def
__neg__
(
self
):
return
Linearization
(
-
self
.
_val
,
self
.
_jac
*
(
-
1
))
return
Linearization
(
-
self
.
_val
,
self
.
_jac
*
(
-
1
),
None
if
self
.
_metric
is
None
else
self
.
_metric
*
(
-
1
))
def
__add__
(
self
,
other
):
if
isinstance
(
other
,
Linearization
):
from
.operators.relaxed_sum_operator
import
RelaxedSumOperator
met
=
None
if
self
.
_metric
is
not
None
and
other
.
_metric
is
not
None
:
met
=
RelaxedSumOperator
((
self
.
_metric
,
other
.
_metric
))
return
Linearization
(
self
.
_val
.
unite
(
other
.
_val
),
RelaxedSumOperator
((
self
.
_jac
,
other
.
_jac
)))
RelaxedSumOperator
((
self
.
_jac
,
other
.
_jac
))
,
met
)
if
isinstance
(
other
,
(
int
,
float
,
complex
,
Field
,
MultiField
)):
return
Linearization
(
self
.
_val
+
other
,
self
.
_jac
)
return
Linearization
(
self
.
_val
+
other
,
self
.
_jac
,
self
.
_metric
)
def
__radd__
(
self
,
other
):
return
self
.
__add__
(
other
)
...
...
@@ -76,6 +85,11 @@ class Linearization(object):
d1
=
makeOp
(
other
)
return
Linearization
(
self
.
_val
*
other
,
d1
*
self
.
_jac
)
def
sum
(
self
):
from
.sugar
import
full
from
.operators.vdot_operator
import
VdotOperator
return
Linearization
(
full
((),
self
.
_val
.
sum
()),
VdotOperator
(
full
(
self
.
_jac
.
target
,
1
))
*
self
.
_jac
)
@
staticmethod
def
make_var
(
field
):
from
.operators.scaling_operator
import
ScalingOperator
...
...
nifty5/operators/relaxed_sum_operator.py
View file @
6e6b4f76
...
...
@@ -60,6 +60,6 @@ class RelaxedSumOperator(LinearOperator):
self
.
_check_mode
(
mode
)
res
=
None
for
op
in
self
.
_ops
:
x
=
op
.
apply
(
x
.
extract
(
op
.
_dom
(
mode
)),
mode
)
res
=
x
if
res
is
None
else
res
.
unite
(
x
)
tmp
=
op
.
apply
(
x
.
extract
(
op
.
_dom
(
mode
)),
mode
)
res
=
tmp
if
res
is
None
else
res
.
unite
(
tmp
)
return
res
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