From 8834434b67f239d37e0dc8fcc23dbbbdaf7360eb Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 28 Apr 2023 11:40:01 -0400 Subject: extend range of possible values --- pyisda/curve.pyx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index c3263b0..02bf22a 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -85,6 +85,7 @@ cdef class Curve(object): int size = self.buf_size int packed_size const TCurve* curve = self.get_TCurve() + TDate ref_date if fmt == 1: dst_capacity = LZ4_compressBound(size) @@ -102,8 +103,10 @@ cdef class Curve(object): memcpy(dst, src, sizeof(TCurve)) src += sizeof(TCurve) dst += sizeof(TCurve) + ref_date = curve.fBaseDate for i in range(curve.fNumItems): - (dst)[i] = (src)[i].fDate - curve.fBaseDate + (dst)[i] = (src)[i].fDate - ref_date + ref_date = (src)[i].fDate ((dst + curve.fNumItems * sizeof(uint16_t)))[i] = (src)[i].fRate return r @@ -171,7 +174,8 @@ cdef class Curve(object): cursor = curve + sizeof(TCurve) src += sizeof(TCurve) for i in range(n): - (cursor)[i] = TRatePt(base_date + (src)[i], ((src + n * sizeof(uint16_t)))[i]) + base_date += (src)[i] + (cursor)[i] = TRatePt(base_date, ((src + n * sizeof(uint16_t)))[i]) decomp_size = state_size - (sizeof(TCurve) + n * sizeof(TRatePt)) if decomp_size > 0: cursor += n * sizeof(TRatePt) -- cgit v1.2.3-70-g09d2