Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
4d783429
Commit
4d783429
authored
Aug 23, 2018
by
Hamdi Sahloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes #12281 - a bug in cuda::pow with negative base values
parent
6700fdb8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
23 deletions
+8
-23
math.cu
modules/cudaarithm/src/cuda/math.cu
+8
-23
No files found.
modules/cudaarithm/src/cuda/math.cu
View file @
4d783429
...
...
@@ -278,20 +278,12 @@ namespace
{
template<typename T, bool Signed = numeric_limits<T>::is_signed> struct PowOp : unary_function<T, T>
{
float power;
typedef typename LargerType<T, float>::type LargerType;
LargerType power;
__device__ __forceinline__ T operator()(T e) const
{
return cudev::saturate_cast<T>(__powf((float)e, power));
}
};
template<typename T> struct PowOp<T, true> : unary_function<T, T>
{
float power;
__device__ __forceinline__ T operator()(T e) const
{
T res = cudev::saturate_cast<T>(__powf((float)e, power));
T res = cudev::saturate_cast<T>(__powf(e < 0 ? -e : e, power));
if ((e < 0) && (1 & static_cast<int>(power)))
res *= -1;
...
...
@@ -299,22 +291,15 @@ namespace
return res;
}
};
template<> struct PowOp<float> : unary_function<float, float>
{
float power;
__device__ __forceinline__ float operator()(float e) const
{
return __powf(::fabs(e), power);
}
};
template<> struct PowOp<double> : unary_function<double, double>
template<typename T> struct PowOp<T, false> : unary_function<T, T>
{
double power;
typedef typename LargerType<T, float>::type LargerType;
LargerType power;
__device__ __forceinline__
double operator()(double
e) const
__device__ __forceinline__
T operator()(T
e) const
{
return
::pow(::fabs(e), power
);
return
cudev::saturate_cast<T>(__powf(e, power)
);
}
};
...
...
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