Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
Julien Lopez
QueryR
Commits
dbc441d4
Commit
dbc441d4
authored
10 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
remove special handling of NaNs in complex multiplication
parent
1bd47865
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/BinaryArithmetic.java
+4
-59
4 additions, 59 deletions
...rc/com/oracle/truffle/r/runtime/ops/BinaryArithmetic.java
with
4 additions
and
59 deletions
com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/BinaryArithmetic.java
+
4
−
59
View file @
dbc441d4
...
...
@@ -258,12 +258,10 @@ public abstract class BinaryArithmetic extends Operation {
double
[]
res
=
new
double
[
2
];
double
[]
interm
=
new
double
[
4
];
complexMult
(
leftReal
,
leftImag
,
rightReal
,
rightImag
,
res
,
interm
);
if
(
Double
.
isNaN
(
res
[
0
])
&&
Double
.
isNaN
(
res
[
1
]))
{
CompilerDirectives
.
transferToInterpreterAndInvalidate
();
MultiplyNaN
multNaN
=
new
MultiplyNaN
();
replace
(
multNaN
);
return
multNaN
.
handleNaN
(
leftReal
,
leftImag
,
rightReal
,
rightImag
,
res
,
interm
);
}
/*
* LStadler: removed the special code for handling NaNs in the result, since it works
* fine (and the tests are broken either way). to revive it, get it from the history.
*/
return
RDataFactory
.
createComplex
(
res
[
0
],
res
[
1
]);
}
...
...
@@ -297,59 +295,6 @@ public abstract class BinaryArithmetic extends Operation {
}
private
static
final
class
MultiplyNaN
extends
Multiply
{
private
final
ConditionProfile
inf1
=
ConditionProfile
.
createBinaryProfile
();
private
final
ConditionProfile
inf2
=
ConditionProfile
.
createBinaryProfile
();
private
final
ConditionProfile
inf3
=
ConditionProfile
.
createBinaryProfile
();
@Override
public
RComplex
op
(
double
leftReal
,
double
leftImag
,
double
rightReal
,
double
rightImag
)
{
double
[]
res
=
new
double
[
2
];
double
[]
interm
=
new
double
[
4
];
complexMult
(
leftReal
,
leftImag
,
rightReal
,
rightImag
,
res
,
interm
);
if
(
Double
.
isNaN
(
res
[
0
])
&&
Double
.
isNaN
(
res
[
1
]))
{
return
handleNaN
(
leftReal
,
leftImag
,
rightReal
,
rightImag
,
res
,
interm
);
}
return
RDataFactory
.
createComplex
(
res
[
0
],
res
[
1
]);
}
protected
RComplex
handleNaN
(
double
leftReal
,
double
leftImag
,
double
rightReal
,
double
rightImag
,
double
[]
res
,
double
[]
interm
)
{
boolean
recalc
=
false
;
double
ra
=
leftReal
;
double
rb
=
leftImag
;
double
rc
=
rightReal
;
double
rd
=
rightImag
;
if
(
inf1
.
profile
(
Double
.
isInfinite
(
ra
)
||
Double
.
isInfinite
(
rb
)))
{
ra
=
convertInf
(
ra
);
rb
=
convertInf
(
rb
);
rc
=
convertNaN
(
rc
);
rd
=
convertNaN
(
rd
);
recalc
=
true
;
}
if
(
inf2
.
profile
(
Double
.
isInfinite
(
rc
)
||
Double
.
isInfinite
(
rd
)))
{
rc
=
convertInf
(
rc
);
rd
=
convertInf
(
rd
);
ra
=
convertNaN
(
ra
);
rb
=
convertNaN
(
rb
);
recalc
=
true
;
}
if
(
inf3
.
profile
(!
recalc
&&
(
Double
.
isInfinite
(
interm
[
0
])
||
Double
.
isInfinite
(
interm
[
1
])
||
Double
.
isInfinite
(
interm
[
2
])
||
Double
.
isInfinite
(
interm
[
3
]))))
{
ra
=
convertNaN
(
ra
);
rb
=
convertNaN
(
rb
);
rc
=
convertNaN
(
rc
);
rd
=
convertNaN
(
rd
);
recalc
=
true
;
}
if
(
recalc
)
{
res
[
0
]
=
Double
.
POSITIVE_INFINITY
*
(
ra
*
rc
-
rb
*
rd
);
res
[
1
]
=
Double
.
POSITIVE_INFINITY
*
(
ra
*
rd
+
rb
*
rc
);
}
return
RDataFactory
.
createComplex
(
res
[
0
],
res
[
1
]);
}
}
private
static
class
Div
extends
BinaryArithmetic
{
public
Div
()
{
...
...
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