Skip to content

Commit f044993

Browse files
committed
variable nearest_node_threshold
1 parent 839d720 commit f044993

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/feenox.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,8 @@ struct feenox_t {
16651665
var_t *on_gsl_error;
16661666
var_t *on_ida_error;
16671667
// var_t *realtime_scale;
1668+
1669+
var_t *nearest_node_threshold;
16681670
} special_vars;
16691671

16701672

src/flow/init.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,16 @@ int feenox_init_special_objects(void) {
469469
//va+realtime_scale+detail and execution will proceed as quick as possible with no delays.
470470
// feenox_special_var(realtime_scale) = feenox_get_or_define_variable_get_ptr("realtime_scale");
471471

472+
///va+nearest_node_threshold+desc Threshold distance to interpolate instead of using the nearest-node value.
473+
///va+nearest_node_threshold+detail When evaluating a multi-dimensional point-defined function $F(\vec{x})$, if $\vec{x}$ is
474+
///va+nearest_node_threshold+detail “close enough” to one of the definition points, the value of the defined point is returned.
475+
///va+nearest_node_threshold+detail Otherwise, FeenoX will interpolate the definition points---depending on the settings on how $F(\vec{x})$ was defined.
476+
///va+nearest_node_threshold+detail This variable controls what “close enough” means as an euclidean distance.
477+
///va+nearest_node_threshold+detail The default value $\left(\frac{1}{2}\right)^20 \appox 10^{-8}$.
478+
feenox_special_var(nearest_node_threshold) = feenox_get_or_define_variable_get_ptr("nearest_node_threshold");
479+
feenox_special_var_value(nearest_node_threshold) = DEFAULT_MULTIDIM_INTERPOLATION_THRESHOLD;
480+
481+
472482
// standard unix files
473483
feenox_call(feenox_define_file("stdin", "stdin", 0, "r"));
474484
feenox.special_files._stdin = feenox_get_file_ptr("stdin");

src/math/function.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ int feenox_function_init(function_t *this) {
265265

266266
if (this->algebraic_expression.items == NULL) {
267267

268-
this->multidim_threshold = (this->expr_multidim_threshold.items != NULL) ? feenox_expression_eval(&this->expr_multidim_threshold) : DEFAULT_MULTIDIM_INTERPOLATION_THRESHOLD;
268+
this->multidim_threshold = (this->expr_multidim_threshold.items != NULL) ? feenox_expression_eval(&this->expr_multidim_threshold) : feenox_special_var_value(nearest_node_threshold);
269269

270270
if (this->vector_argument != NULL) {
271271
for (unsigned int i = 0; i < this->n_arguments; i++) {

src/parser/parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ int feenox_parse_function(void) {
12761276
///kw+FUNCTION+detail @
12771277
///kw+FUNCTION+usage [ INTERPOLATION_THRESHOLD <expr> ]
12781278
///kw+FUNCTION+detail For $n>1$, if the euclidean distance between the arguments and the definition points is smaller than `INTERPOLATION_THRESHOLD`, the definition point is returned and no interpolation is performed.
1279-
///kw+FUNCTION+detail Default value is square root of `DEFAULT_MULTIDIM_INTERPOLATION_THRESHOLD`.
1279+
///kw+FUNCTION+detail Otherwise, the value of the special variable `nearest_node_threshold` at the moment the function is defined is used as the threshold.
12801280
} else if (strcasecmp(token, "INTERPOLATION_THRESHOLD") == 0) {
12811281

12821282
feenox_parser_expression(&function->expr_multidim_threshold);

0 commit comments

Comments
 (0)