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
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
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
89ff8afe
Commit
89ff8afe
authored
Aug 14, 2017
by
Theo Steininger
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added limitted_exp to basic_arithmetics.py
parent
eb02f1c4
Pipeline
#16508
passed with stages
in 15 minutes and 35 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
nifty/basic_arithmetics.py
nifty/basic_arithmetics.py
+14
-1
No files found.
nifty/basic_arithmetics.py
View file @
89ff8afe
...
...
@@ -23,7 +23,7 @@ from nifty.field import Field
__all__
=
[
'cos'
,
'sin'
,
'cosh'
,
'sinh'
,
'tan'
,
'tanh'
,
'arccos'
,
'arcsin'
,
'arccosh'
,
'arcsinh'
,
'arctan'
,
'arctanh'
,
'sqrt'
,
'exp'
,
'log'
,
'conjugate'
,
'clipped_exp'
]
'conjugate'
,
'clipped_exp'
,
'limitted_exp'
]
def
_math_helper
(
x
,
function
):
...
...
@@ -99,6 +99,19 @@ def clipped_exp(x):
return
_math_helper
(
x
,
lambda
z
:
np
.
exp
(
np
.
minimum
(
200
,
z
)))
def
limitted_exp
(
x
):
thr
=
200
expthr
=
np
.
exp
(
thr
)
return
_math_helper
(
x
,
lambda
z
:
_limitted_exp_helper
(
z
,
thr
,
expthr
))
def
_limitted_exp_helper
(
x
,
thr
,
expthr
):
mask
=
(
x
>
thr
)
result
=
np
.
exp
(
x
)
result
[
mask
]
=
((
1
-
thr
)
+
x
[
mask
])
*
expthr
return
result
def
log
(
x
,
base
=
None
):
result
=
_math_helper
(
x
,
np
.
log
)
if
base
is
not
None
:
...
...
Theo Steininger
@theos
mentioned in issue
#172 (closed)
·
Aug 14, 2017
mentioned in issue
#172 (closed)
mentioned in issue #172
Toggle commit list
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