From 3d92926a902017e7cf1f5738e99ff62da596ce12 Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Sun, 9 Aug 2026 15:02:21 +0400 Subject: refactor --- lib/ulcer_index.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/ulcer_index.c') 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; -- cgit v1.3.1