Commit c4fbf826 authored by Brice Videau's avatar Brice Videau

Fix c++ library.

parent 8fec6645
......@@ -28,25 +28,8 @@ ccs_interval_equal(ccs_interval_t *interval1,
ccs_interval_t *interval2,
ccs_bool_t *equal_res);
inline ccs_bool_t
ccs_interval_include(ccs_interval_t *interval, ccs_numeric_t value) {
if (interval->type == CCS_NUM_FLOAT) {
return ( interval->lower_included ?
interval->lower.f <= value.f :
interval->lower.f < value.f ) &&
( interval->upper_included ?
interval->upper.f >= value.f :
interval->upper.f > value.f );
} else {
return ( interval->lower_included ?
interval->lower.i <= value.i :
interval->lower.i < value.i ) &&
( interval->upper_included ?
interval->upper.i >= value.i :
interval->upper.i > value.i );
}
}
extern ccs_bool_t
ccs_interval_include(ccs_interval_t *interval, ccs_numeric_t value);
#ifdef __cplusplus
}
#endif
......
......@@ -3,6 +3,25 @@
#include <cconfigspace.h>
static inline ccs_bool_t
_ccs_interval_include(ccs_interval_t *interval, ccs_numeric_t value) {
if (interval->type == CCS_NUM_FLOAT) {
return ( interval->lower_included ?
interval->lower.f <= value.f :
interval->lower.f < value.f ) &&
( interval->upper_included ?
interval->upper.f >= value.f :
interval->upper.f > value.f );
} else {
return ( interval->lower_included ?
interval->lower.i <= value.i :
interval->lower.i < value.i ) &&
( interval->upper_included ?
interval->upper.i >= value.i :
interval->upper.i > value.i );
}
}
struct _ccs_object_ops_s {
ccs_result_t (*del)(ccs_object_t object);
};
......
......@@ -28,14 +28,14 @@ _ccs_hyperparameter_numerical_check_values(_ccs_hyperparameter_data_t *data,
if (values[i].type != CCS_FLOAT)
results[i] = CCS_FALSE;
else
results[i] = ccs_interval_include(interval, CCSF(values[i].value.f));
results[i] = _ccs_interval_include(interval, CCSF(values[i].value.f));
}
else {
for(size_t i = 0; i < num_values; i++)
if (values[i].type != CCS_INTEGER)
results[i] = CCS_FALSE;
else
results[i] = ccs_interval_include(interval, CCSI(values[i].value.i));
results[i] = _ccs_interval_include(interval, CCSI(values[i].value.i));
}
return CCS_SUCCESS;
}
......@@ -75,11 +75,11 @@ _ccs_hyperparameter_numerical_samples(_ccs_hyperparameter_data_t *data,
size_t found = 0;
if (type == CCS_NUM_FLOAT) {
for(size_t i = 0; i < num_values; i++)
if (ccs_interval_include(interval, vs[i]))
if (_ccs_interval_include(interval, vs[i]))
values[found++].value.f = vs[i].f;
} else {
for(size_t i = 0; i < num_values; i++)
if (ccs_interval_include(interval, vs[i]))
if (_ccs_interval_include(interval, vs[i]))
values[found++].value.i = vs[i].i;
}
vs = NULL;
......@@ -93,11 +93,11 @@ _ccs_hyperparameter_numerical_samples(_ccs_hyperparameter_data_t *data,
buff_sz, vs);
if (type == CCS_NUM_FLOAT) {
for(size_t i = 0; i < buff_sz && found < num_values; i++)
if (ccs_interval_include(interval, vs[i]))
if (_ccs_interval_include(interval, vs[i]))
values[found++].value.f = vs[i].f;
} else {
for(size_t i = 0; i < buff_sz && found < num_values; i++)
if (ccs_interval_include(interval, vs[i]))
if (_ccs_interval_include(interval, vs[i]))
values[found++].value.i = vs[i].i;
}
coeff <<= 1;
......
#include "cconfigspace.h"
#include "cconfigspace_internal.h"
ccs_result_t
ccs_interval_empty(ccs_interval_t *interval, ccs_bool_t *empty_ret) {
......@@ -117,5 +117,7 @@ ccs_interval_equal(ccs_interval_t *interval1,
return CCS_SUCCESS;
}
extern inline ccs_bool_t
ccs_interval_include(ccs_interval_t *interval, ccs_numeric_t value);
ccs_bool_t
ccs_interval_include(ccs_interval_t *interval, ccs_numeric_t value) {
return _ccs_interval_include(interval, value);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment