Skip to content

Commit

Permalink
Replace CMath::ceil with std::ceil
Browse files Browse the repository at this point in the history
  • Loading branch information
syashakash committed Mar 3, 2018
1 parent 3918546 commit 2d70378
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 197 deletions.
2 changes: 1 addition & 1 deletion src/shogun/features/DataGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SGMatrix<float64_t> CDataGenerator::generate_checkboard_data(int32_t num_classes
{
int32_t points_per_class = num_points / num_classes;

int32_t grid_size = (int32_t ) CMath::ceil(CMath::sqrt((float64_t ) num_classes));
int32_t grid_size = (int32_t)std::ceil(CMath::sqrt((float64_t)num_classes));
float64_t cell_size = (float64_t ) 1 / grid_size;
SGVector<float64_t> grid_idx(dim);
for (index_t i=0; i<dim; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/features/StringFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ template<class ST> bool CStringFeatures<ST>::load_compressed(char* src, bool dec
}
else
{
int32_t offs=CMath::ceil(2.0*sizeof(int32_t)/sizeof(ST));
int32_t offs = std::ceil(2.0 * sizeof(int32_t) / sizeof(ST));
features[i].string=SG_MALLOC(ST, len_compressed+offs);
features[i].slen=len_compressed+offs;
int32_t* feat32ptr=((int32_t*) (features[i].string));
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/lib/JLCoverTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ inline float dist_of_scale (int s)

inline int get_scale(float d)
{
return (int) CMath::ceil(il2 * log(d));
return (int)std::ceil(il2 * log(d));
}

template<class P>
Expand Down
9 changes: 0 additions & 9 deletions src/shogun/mathematics/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,6 @@ class CMath : public CSGObject
return std::floor(d);
}

/** The value of x rounded upward (as a floating-point value)
* @param d input decimal value
* @return rounded off value
*/
static inline float64_t ceil(float64_t d)
{
return std::ceil(d);
}

/** Signum of input value
* @param a input value
* @return 1 if a>0, -1 if a<0
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/mathematics/ajd/FFDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SGMatrix<float64_t> CFFDiag::diagonalize(SGNDArray<float64_t> C0, SGMatrix<float
W.data());

W.transposeInPlace();
int e = CMath::ceil(log2(W.array().abs().rowwise().sum().maxCoeff()));
int e = std::ceil(log2(W.array().abs().rowwise().sum().maxCoeff()));
int s = std::max(0,e-1);
W /= pow(2,s);

Expand Down
2 changes: 1 addition & 1 deletion src/shogun/preprocessor/DecompressString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ST* CDecompressString<ST>::apply_to_string(ST* f, int32_t &len)
uint64_t compressed_size=((int32_t*) f)[0];
uint64_t uncompressed_size=((int32_t*) f)[1];

int32_t offs=CMath::ceil(2.0*sizeof(int32_t)/sizeof(ST));
int32_t offs = std::ceil(2.0 * sizeof(int32_t) / sizeof(ST));
ASSERT(uint64_t(len)==uint64_t(offs)+compressed_size)

len=uncompressed_size;
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/regression/KRRNystrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool CKRRNystrom::solve_krr_system()

if (m_num_rkhs_basis == 0)
{
set_num_rkhs_basis((int32_t)CMath::ceil(n/2.0));
set_num_rkhs_basis((int32_t)std::ceil(n / 2.0));
SG_SWARNING("Number of sampled rows not set, default is half (%d) "
"of the number of data points (%d)\n", m_num_rkhs_basis, n);
}
Expand Down

0 comments on commit 2d70378

Please sign in to comment.