Skip to content

Commit

Permalink
Fix scale for spansets (MobilityDB#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanzimanyi authored Jul 19, 2024
1 parent 42e6d78 commit 7fea79a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions meos/src/general/spanset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,19 +1692,26 @@ numspanset_shift_scale(const SpanSet *ss, Datum shift, Datum width,
return NULL;

/* Copy the input span set to the output span set */
SpanSet *result = spanset_cp(ss);
SpanSet *copy = spanset_cp(ss);

/* Shift and/or scale the bounding span */
Datum delta;
double scale;
numspan_shift_scale1(&result->span, shift, width, hasshift, haswidth,
numspan_shift_scale1(&copy->span, shift, width, hasshift, haswidth,
&delta, &scale);
Datum origin = result->span.lower;
Datum origin = copy->span.lower;

/* Shift and/or scale the span set */
for (int i = 0; i < ss->count; i++)
numspan_delta_scale_iter(&result->elems[i], origin, delta, hasshift,
numspan_delta_scale_iter(&copy->elems[i], origin, delta, hasshift,
scale);

/* Normalization is required after scaling */
Span *spans = palloc(sizeof(Span) * ss->count);
for (int i = 0; i < ss->count; i++)
memcpy(&spans[i], &copy->elems[i], sizeof(Span));
SpanSet *result = spanset_make_exp(spans, ss->count, ss->count, true, true);
pfree(copy); pfree(spans);
return result;
}

Expand Down

0 comments on commit 7fea79a

Please sign in to comment.