/* See wt_table_triangular.h */ /* Last edited on 2024-11-23 06:13:04 by stolfi */ #define wt_table_triangular_C_COPYRIGHT \ "Copyright © 2023 by the State University of Campinas (UNICAMP)" #include #include #include #include #include #include #include #include #include double_vec_t wt_table_triangular_make(uint32_t n) { /* Allocate and fill the table: */ double_vec_t wt = double_vec_new(n); wt_table_triangular_fill(n, wt.e, NULL); return wt; } void wt_table_triangular_fill(uint32_t n, double wt[], uint32_t *stride_P) { /* Build triangular table and compute its sum: */ uint32_t m = (n-1)/2; for (int32_t k = 0; k < n; k++) { wt[k] = (k <= m ? k + 1.0 : wt[(int32_t)n-1-k]); } if (stride_P != NULL) { (*stride_P) = (n+1)/2; } }