diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2023-04-28 11:40:01 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2023-04-28 11:41:26 -0400 |
| commit | 8834434b67f239d37e0dc8fcc23dbbbdaf7360eb (patch) | |
| tree | c0ad0f5894d6339f1322825c3f468cd6851586ed | |
| parent | fa12e9399e4a7c33f4eb184a8b551e557a019e92 (diff) | |
| download | pyisda-8834434b67f239d37e0dc8fcc23dbbbdaf7360eb.tar.gz | |
extend range of possible values
| -rw-r--r-- | pyisda/curve.pyx | 8 |
1 files 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): - (<uint16_t*>dst)[i] = (<TRatePt*>src)[i].fDate - curve.fBaseDate + (<uint16_t*>dst)[i] = (<TRatePt*>src)[i].fDate - ref_date + ref_date = (<TRatePt*>src)[i].fDate (<double*>(dst + curve.fNumItems * sizeof(uint16_t)))[i] = (<TRatePt*>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): - (<TRatePt*>cursor)[i] = TRatePt(base_date + (<uint16_t*>src)[i], (<double*>(src + n * sizeof(uint16_t)))[i]) + base_date += (<uint16_t*>src)[i] + (<TRatePt*>cursor)[i] = TRatePt(base_date, (<double*>(src + n * sizeof(uint16_t)))[i]) decomp_size = state_size - (sizeof(TCurve) + n * sizeof(TRatePt)) if decomp_size > 0: cursor += n * sizeof(TRatePt) |
