MCPcopy Create free account
hub / github.com/apache/madlib / accum_sdata_values_double

Function accum_sdata_values_double

methods/svec/src/pg_gp/SparseData.c:974–989  ·  view source on GitHub ↗

This function is introduced to capture a common routine for * traversing a SparseData, transforming each element as we go along and * summing up the transformed elements. The method is non-destructive to * the input SparseData. */

Source from the content-addressed store, hash-verified

972 * the input SparseData.
973 */
974double
975accum_sdata_values_double(SparseData sdata, double (*func)(double))
976{
977 double accum=0.;
978 char *ix = sdata->index->data;
979 double *vals = (double *)sdata->vals->data;
980 int64 run_length;
981
982 for (int i=0;i<sdata->unique_value_count;i++)
983 {
984 run_length = compword_to_int8(ix);
985 accum += func(vals[i])*run_length;
986 ix+=int8compstoragesize(ix);
987 }
988 return (accum);
989}
990
991/* Computes the running sum of the elements of a SparseData */
992double sum_sdata_values_double(SparseData sdata) {

Callers 3

sum_sdata_values_doubleFunction · 0.85

Calls 1

compword_to_int8Function · 0.85

Tested by

no test coverage detected