summaryrefslogtreecommitdiffstats
path: root/lib/ulcer_index.c
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-08-09 15:02:21 +0400
committerEthan Werner <mail@ethanwerner.com>2026-08-09 15:02:21 +0400
commit3d92926a902017e7cf1f5738e99ff62da596ce12 (patch)
tree2b55422c26a48759d56fa91f06df24449e9dfa88 /lib/ulcer_index.c
parent07e18043145f3d91c8ea7ec3ad41b3c905585277 (diff)
refactormain
Diffstat (limited to 'lib/ulcer_index.c')
-rw-r--r--lib/ulcer_index.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ulcer_index.c b/lib/ulcer_index.c
index ca70734..1063880 100644
--- a/lib/ulcer_index.c
+++ b/lib/ulcer_index.c
@@ -24,7 +24,7 @@ ts_parameter_t const ts_ulcer_index_p = { .n_inputs = 1, .n_outputs = 1, .n_cons
uint_t ts_ulcer_index_offset( ts_constant_t const *c )
{
( void )c;
- return ( c ? ((ts_ulcer_index_params_t *)c)->k > 0 ? ((ts_ulcer_index_params_t *)c)->k - 1 : 0 : 0 );
+ return ( c ? ((ts_ulcer_index_params_t const *)c)->k > 0 ? ((ts_ulcer_index_params_t const *)c)->k - 1 : 0 : 0 );
}
int ts_ulcer_index(
@@ -35,8 +35,8 @@ int ts_ulcer_index(
{
TS_PROLOGUE( ts_ulcer_index_p );
if ( !c ) return -1;
- uint_t k = ((ts_ulcer_index_params_t *)c)->k;
- if (k == 0 || n < k) return -1;
+ uint_t k = ((ts_ulcer_index_params_t const *)c)->k;
+ if (k == 0) return -1;
/* Precompute cumulative highest-high for each index: O(n) */
fp_t *cum_hhv = calloc( n, sizeof( fp_t ) );
@@ -50,13 +50,13 @@ int ts_ulcer_index(
}
}
- for( uint_t i = k - 1; i < n; ++i )
+ for( uint_t i = k - 1; i < n; ++i )
{
fp_t hhv = x[0][i - k + 1];
for( uint_t j = 1; j < k; ++j )
{
fp_t v = x[0][i - k + 1 + j];
- if (v > hhv) hhv = v;
+ if ( v > hhv ) hhv = v;
}
fp_t d_sq_sum = 0;