mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Replace pow with std::pow
The C pow casts to double while std::pow has overloads that can be optimized by the compiler. Also replace pow(*, 1./3) by cbrt.
This commit is contained in:
@@ -446,7 +446,7 @@ BRISK_Impl::generateKernel(const std::vector<float> &radiusList,
|
||||
const float sigma_scale = 1.3f;
|
||||
|
||||
for (unsigned int scale = 0; scale < scales_; ++scale) {
|
||||
scaleList_[scale] = (float) std::pow((double) 2.0, (double) (scale * lb_scale_step));
|
||||
scaleList_[scale] = (float) std::pow(2, scale * lb_scale_step);
|
||||
sizeList_[scale] = 0;
|
||||
BriskPatternPoint *patternIteratorOuter = patternPoints_ + (scale * n_rot_ * points_);
|
||||
// generate the pattern points look-up
|
||||
|
||||
@@ -73,7 +73,7 @@ void AKAZEFeatures::Allocate_Memory_Evolution(void) {
|
||||
for (int j = 0; j < options_.nsublevels; j++) {
|
||||
MEvolution step;
|
||||
step.size = Size(level_width, level_height);
|
||||
step.esigma = options_.soffset*pow(2.f, (float)(j) / (float)(options_.nsublevels) + i);
|
||||
step.esigma = (float)(options_.soffset*std::pow(2, (float)(j) / (float)(options_.nsublevels) + i));
|
||||
step.sigma_size = cvRound(step.esigma * options_.derivative_factor / power); // In fact sigma_size only depends on j
|
||||
step.etime = 0.5f * (step.esigma * step.esigma);
|
||||
step.octave = i;
|
||||
|
||||
@@ -66,7 +66,7 @@ void KAZEFeatures::Allocate_Memory_Evolution(void) {
|
||||
aux.Lt = Mat::zeros(options_.img_height, options_.img_width, CV_32F);
|
||||
aux.Lsmooth = Mat::zeros(options_.img_height, options_.img_width, CV_32F);
|
||||
aux.Ldet = Mat::zeros(options_.img_height, options_.img_width, CV_32F);
|
||||
aux.esigma = options_.soffset*pow((float)2.0f, (float)(j) / (float)(options_.nsublevels)+i);
|
||||
aux.esigma = (float)(options_.soffset*std::pow(2, (float)(j) / (float)(options_.nsublevels)+i));
|
||||
aux.etime = 0.5f*(aux.esigma*aux.esigma);
|
||||
aux.sigma_size = cvRound(aux.esigma);
|
||||
aux.octave = i;
|
||||
@@ -472,7 +472,7 @@ void KAZEFeatures::Do_Subpixel_Refinement(std::vector<KeyPoint> &kpts) {
|
||||
dsc = kpts_[i].octave + (kpts_[i].angle + *(dst.ptr<float>(2))) / ((float)(options_.nsublevels));
|
||||
|
||||
// In OpenCV the size of a keypoint is the diameter!!
|
||||
kpts_[i].size = 2.0f*options_.soffset*pow((float)2.0f, dsc);
|
||||
kpts_[i].size = (float)(2*options_.soffset*std::pow(2, dsc));
|
||||
kpts_[i].angle = 0.0;
|
||||
}
|
||||
// Set the points to be deleted after the for loop
|
||||
|
||||
@@ -231,10 +231,10 @@ void SIFT_Impl::buildGaussianPyramid( const Mat& base, std::vector<Mat>& pyr, in
|
||||
// precompute Gaussian sigmas using the following formula:
|
||||
// \sigma_{total}^2 = \sigma_{i}^2 + \sigma_{i-1}^2
|
||||
sig[0] = sigma;
|
||||
double k = std::pow( 2., 1. / nOctaveLayers );
|
||||
double k = std::pow( 2, 1. / nOctaveLayers );
|
||||
for( int i = 1; i < nOctaveLayers + 3; i++ )
|
||||
{
|
||||
double sig_prev = std::pow(k, (double)(i-1))*sigma;
|
||||
double sig_prev = (double)std::pow(k, i-1)*sigma;
|
||||
double sig_total = sig_prev*k;
|
||||
sig[i] = std::sqrt(sig_total*sig_total - sig_prev*sig_prev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user