diff options
| -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) |
