changed optimization_utils.h to std::pow
This commit is contained in:
@@ -170,8 +170,9 @@ class OptUtils {
|
||||
ones.SetAll(1.0);
|
||||
// This part of the sparsity constraint function formula can be
|
||||
// precomputed and it is the same for every iteration
|
||||
double precomputed_sparse_factor=-sparse_factor*(math::Pow<1,2>(dimension)-1)+
|
||||
math::Pow<1,2>(dimension);
|
||||
double temp_pow_1_2_dimension = 1.0/std::pow(2,dimension)
|
||||
double precomputed_sparse_factor
|
||||
= -sparse_factor*(temp_pow_1_2_dimension-1)+temp_pow_1_2_dimension;
|
||||
|
||||
for (index_t i=0; i<data->n_cols(); i++) {
|
||||
double *point=data->GetColumnPtr(i);
|
||||
@@ -199,7 +200,7 @@ class OptUtils {
|
||||
double w_norm=la::LengthEuclidean(w_vector);
|
||||
double w_times_v = 2*la::Dot(v_vector, w_vector);
|
||||
double v_norm_minus_l2=la::LengthEuclidean(v_vector)-l2_norm;
|
||||
double alpha = (-w_times_v+math::Pow<1,2>(w_times_v*w_times_v
|
||||
double alpha = (-w_times_v+1.0/std::pow(2,w_times_v*w_times_v
|
||||
-4*w_norm*v_norm_minus_l2))/(2*w_norm);
|
||||
la::AddExpert(alpha, w_vector, &v_vector);
|
||||
bool all_positive=true;
|
||||
|
||||
Reference in New Issue
Block a user