From f1a180b5a599e77f43e3da684f7a6da9a8ddc93a Mon Sep 17 00:00:00 2001 From: Kenneth Jao Date: Thu, 27 Jan 2022 20:25:30 -0500 Subject: [PATCH] Non-numerical Hessian for Radial[T] --- squish/core.c | 940 ++++++---- squish/core.pxd | 6 +- squish/core.pyx | 26 +- squish/diagram.py | 160 +- squish/energy.c | 4173 ++++++++++++++++++++++++++++++++---------- squish/energy.pyx | 513 ++++-- squish/ordered.py | 83 +- squish/simulation.py | 18 +- squish/voronoi.c | 2878 ++++++----------------------- squish/voronoi.pxd | 3 +- squish/voronoi.pyx | 162 +- 11 files changed, 4879 insertions(+), 4083 deletions(-) diff --git a/squish/core.c b/squish/core.c index 02f9c39..67f9df5 100644 --- a/squish/core.c +++ b/squish/core.c @@ -3,6 +3,12 @@ /* BEGIN: Cython Metadata { "distutils": { + "define_macros": [ + [ + "NPY_NO_DEPRECATED_API", + "NPY_1_7_API_VERSION" + ] + ], "depends": [], "name": "squish.core", "sources": [ @@ -871,8 +877,8 @@ static const char *__pyx_filename; static const char *__pyx_f[] = { "squish/core.pyx", - "__init__.pxd", - "type.pxd", + ".venv/lib/python3.8/site-packages/numpy/__init__.pxd", + ".venv/lib/python3.8/site-packages/Cython/Includes/cpython/type.pxd", }; /* ForceInitThreads.proto */ #ifndef __PYX_FORCE_INIT_THREADS @@ -887,7 +893,7 @@ static const char *__pyx_f[] = { #define __Pyx_FastGilFuncInit() -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":690 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":690 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -896,7 +902,7 @@ static const char *__pyx_f[] = { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":691 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":691 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -905,7 +911,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":692 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":692 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -914,7 +920,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":693 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":693 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -923,7 +929,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":697 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":697 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -932,7 +938,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":698 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":698 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -941,7 +947,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":699 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":699 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -950,7 +956,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":700 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":700 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -959,7 +965,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":704 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":704 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -968,7 +974,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":705 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":705 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -977,7 +983,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":714 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":714 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -986,7 +992,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":715 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":715 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -995,7 +1001,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":716 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":716 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -1004,7 +1010,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":718 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":718 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -1013,7 +1019,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":719 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":719 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -1022,7 +1028,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":720 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":720 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -1031,7 +1037,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":722 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":722 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -1040,7 +1046,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":723 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":723 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -1049,7 +1055,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":725 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":725 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -1058,7 +1064,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":726 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":726 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -1067,7 +1073,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":727 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":727 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -1120,7 +1126,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do /*--- Type declarations ---*/ -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":729 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":729 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -1129,7 +1135,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":730 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":730 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -1138,7 +1144,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":731 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":731 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -1147,7 +1153,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":733 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":733 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1306,10 +1312,11 @@ typedef __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_6squish_4core_MatrixCopySclOp) * * ctypedef struct VectorSelfOps: # <<<<<<<<<<<<<< * Vector2D* (*neg)(Vector2D*) nogil - * + * Vector2D* (*rot)(Vector2D*) nogil */ struct __pyx_t_6squish_4core_VectorSelfOps { __pyx_t_6squish_4core_Vector2D *(*neg)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Vector2D *(*rot)(__pyx_t_6squish_4core_Vector2D *); __pyx_t_6squish_4core_VectorSelfVecOp vadd; __pyx_t_6squish_4core_VectorSelfVecOp vsub; __pyx_t_6squish_4core_VectorSelfVecOp vmul; @@ -1321,15 +1328,16 @@ struct __pyx_t_6squish_4core_VectorSelfOps { __pyx_t_6squish_4core_VectorSelfSclOp sdiv; }; -/* "squish/core.pxd":67 +/* "squish/core.pxd":68 * * * ctypedef struct VectorCopyOps: # <<<<<<<<<<<<<< * Vector2D (*neg)(Vector2D*) nogil - * + * Vector2D (*rot)(Vector2D*) nogil */ struct __pyx_t_6squish_4core_VectorCopyOps { __pyx_t_6squish_4core_Vector2D (*neg)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Vector2D (*rot)(__pyx_t_6squish_4core_Vector2D *); __pyx_t_6squish_4core_VectorCopyVecOp vadd; __pyx_t_6squish_4core_VectorCopyVecOp vsub; __pyx_t_6squish_4core_VectorCopyVecOp vmul; @@ -1341,15 +1349,16 @@ struct __pyx_t_6squish_4core_VectorCopyOps { __pyx_t_6squish_4core_VectorCopySclOp sdiv; }; -/* "squish/core.pxd":82 +/* "squish/core.pxd":84 * * * ctypedef struct MatrixSelfOps: # <<<<<<<<<<<<<< * Matrix2x2* (*neg)(Matrix2x2*) nogil - * + * Matrix2x2* (*T)(Matrix2x2*) nogil */ struct __pyx_t_6squish_4core_MatrixSelfOps { __pyx_t_6squish_4core_Matrix2x2 *(*neg)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 *(*T)(__pyx_t_6squish_4core_Matrix2x2 *); __pyx_t_6squish_4core_MatrixSelfMatOp madd; __pyx_t_6squish_4core_MatrixSelfMatOp msub; __pyx_t_6squish_4core_MatrixSelfMatOp mmul; @@ -1361,15 +1370,16 @@ struct __pyx_t_6squish_4core_MatrixSelfOps { __pyx_t_6squish_4core_MatrixSelfSclOp sdiv; }; -/* "squish/core.pxd":97 +/* "squish/core.pxd":100 * * * ctypedef struct MatrixCopyOps: # <<<<<<<<<<<<<< * Matrix2x2 (*neg)(Matrix2x2*) nogil - * + * Matrix2x2 (*T)(Matrix2x2*) nogil */ struct __pyx_t_6squish_4core_MatrixCopyOps { __pyx_t_6squish_4core_Matrix2x2 (*neg)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 (*T)(__pyx_t_6squish_4core_Matrix2x2 *); __pyx_t_6squish_4core_MatrixCopyMatOp madd; __pyx_t_6squish_4core_MatrixCopyMatOp msub; __pyx_t_6squish_4core_MatrixCopyMatOp mmul; @@ -1381,7 +1391,7 @@ struct __pyx_t_6squish_4core_MatrixCopyOps { __pyx_t_6squish_4core_MatrixCopySclOp sdiv; }; -/* "squish/core.pxd":112 +/* "squish/core.pxd":116 * * # Psuedo-class for a 2-dimensional vector. No orientation. * ctypedef struct Vector2D: # <<<<<<<<<<<<<< @@ -1394,12 +1404,12 @@ struct __pyx_t_6squish_4core_Vector2D { __pyx_t_6squish_4core_VectorSelfOps self; __pyx_t_6squish_4core_VectorCopyOps copy; int (*equals)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); - __pyx_t_6squish_4core_Vector2D (*rot)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Matrix2x2 (*vecmul)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*dot)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*mag)(__pyx_t_6squish_4core_Vector2D *); }; -/* "squish/core.pxd":123 +/* "squish/core.pxd":127 * * # Psuedo-class for a 2x2 matrix. * ctypedef struct Matrix2x2: # <<<<<<<<<<<<<< @@ -1905,6 +1915,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_v_ssu static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_v_smul_s(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_v_sdiv_s(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_v_matmul_s(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Matrix2x2); /*proto*/ +static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_rot_s(__pyx_t_6squish_4core_Vector2D *); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_neg_c(__pyx_t_6squish_4core_Vector2D *); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vadd_c(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vsub_c(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); /*proto*/ @@ -1915,9 +1926,10 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_ssub static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_smul_c(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sdiv_c(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_matmul_c(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Matrix2x2); /*proto*/ -static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_rot(__pyx_t_6squish_4core_Vector2D *); /*proto*/ +static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_rot_c(__pyx_t_6squish_4core_Vector2D *); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_dot(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_mag(__pyx_t_6squish_4core_Vector2D *); /*proto*/ +static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_v_vecmul(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); /*proto*/ static CYTHON_INLINE int __pyx_f_6squish_4core_m_equals(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_m_vecmul(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Vector2D); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_neg_s(__pyx_t_6squish_4core_Matrix2x2 *); /*proto*/ @@ -1930,6 +1942,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_smul_s(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sdiv_s(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_matmul_s(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); /*proto*/ +static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_transpose_s(__pyx_t_6squish_4core_Matrix2x2 *); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_neg_c(__pyx_t_6squish_4core_Matrix2x2 *); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_madd_c(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_msub_c(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); /*proto*/ @@ -1940,6 +1953,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_ssu static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_smul_c(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sdiv_c(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_matmul_c(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); /*proto*/ +static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_transpose_c(__pyx_t_6squish_4core_Matrix2x2 *); /*proto*/ #define __Pyx_MODULE_NAME "squish.core" extern int __pyx_module_is_main_squish__core; int __pyx_module_is_main_squish__core = 0; @@ -2688,7 +2702,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core__Vecto __pyx_t_6squish_4core_VectorSelfOps __pyx_t_3; __pyx_t_6squish_4core_VectorCopyOps __pyx_t_4; int (*__pyx_t_5)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); - __pyx_t_6squish_4core_Vector2D (*__pyx_t_6)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_6)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*__pyx_t_7)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*__pyx_t_8)(__pyx_t_6squish_4core_Vector2D *); @@ -2709,7 +2723,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core__Vecto * vec.x, vec.y = x, y * vec.self, vec.copy = VSO, VCO # <<<<<<<<<<<<<< * - * vec.equals, vec.rot, vec.dot, vec.mag = &v_equals, &rot, &dot, &mag + * vec.equals, vec.vecmul, vec.dot, vec.mag = &v_equals, &v_vecmul, &dot, &mag */ __pyx_t_3 = __pyx_v_6squish_4core_VSO; __pyx_t_4 = __pyx_v_6squish_4core_VCO; @@ -2719,21 +2733,21 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core__Vecto /* "squish/core.pyx":146 * vec.self, vec.copy = VSO, VCO * - * vec.equals, vec.rot, vec.dot, vec.mag = &v_equals, &rot, &dot, &mag # <<<<<<<<<<<<<< + * vec.equals, vec.vecmul, vec.dot, vec.mag = &v_equals, &v_vecmul, &dot, &mag # <<<<<<<<<<<<<< * * return vec */ __pyx_t_5 = (&__pyx_f_6squish_4core_v_equals); - __pyx_t_6 = (&__pyx_f_6squish_4core_rot); + __pyx_t_6 = (&__pyx_f_6squish_4core_v_vecmul); __pyx_t_7 = (&__pyx_f_6squish_4core_dot); __pyx_t_8 = (&__pyx_f_6squish_4core_mag); __pyx_v_vec.equals = __pyx_t_5; - __pyx_v_vec.rot = __pyx_t_6; + __pyx_v_vec.vecmul = __pyx_t_6; __pyx_v_vec.dot = __pyx_t_7; __pyx_v_vec.mag = __pyx_t_8; /* "squish/core.pyx":148 - * vec.equals, vec.rot, vec.dot, vec.mag = &v_equals, &rot, &dot, &mag + * vec.equals, vec.vecmul, vec.dot, vec.mag = &v_equals, &v_vecmul, &dot, &mag * * return vec # <<<<<<<<<<<<<< * @@ -3298,7 +3312,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_v_mat * self.x, self.y = self.x*m.a + self.y*m.c, self.x*m.b + self.y*m.d * return self # <<<<<<<<<<<<<< * - * cdef inline Vector2D v_neg_c(Vector2D* self) nogil: + * cdef inline Vector2D* rot_s(Vector2D* self) nogil: */ __pyx_r = __pyx_v_self; goto __pyx_L0; @@ -3317,6 +3331,54 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_v_mat } /* "squish/core.pyx":203 + * return self + * + * cdef inline Vector2D* rot_s(Vector2D* self) nogil: # <<<<<<<<<<<<<< + * self.x, self.y = -self.y, self.x + * return self + */ + +static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_rot_s(__pyx_t_6squish_4core_Vector2D *__pyx_v_self) { + __pyx_t_6squish_4core_Vector2D *__pyx_r; + __pyx_t_6squish_4core_FLOAT_T __pyx_t_1; + __pyx_t_6squish_4core_FLOAT_T __pyx_t_2; + + /* "squish/core.pyx":204 + * + * cdef inline Vector2D* rot_s(Vector2D* self) nogil: + * self.x, self.y = -self.y, self.x # <<<<<<<<<<<<<< + * return self + * + */ + __pyx_t_1 = (-__pyx_v_self->y); + __pyx_t_2 = __pyx_v_self->x; + __pyx_v_self->x = __pyx_t_1; + __pyx_v_self->y = __pyx_t_2; + + /* "squish/core.pyx":205 + * cdef inline Vector2D* rot_s(Vector2D* self) nogil: + * self.x, self.y = -self.y, self.x + * return self # <<<<<<<<<<<<<< + * + * cdef inline Vector2D v_neg_c(Vector2D* self) nogil: + */ + __pyx_r = __pyx_v_self; + goto __pyx_L0; + + /* "squish/core.pyx":203 + * return self + * + * cdef inline Vector2D* rot_s(Vector2D* self) nogil: # <<<<<<<<<<<<<< + * self.x, self.y = -self.y, self.x + * return self + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "squish/core.pyx":207 * return self * * cdef inline Vector2D v_neg_c(Vector2D* self) nogil: # <<<<<<<<<<<<<< @@ -3327,7 +3389,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D *__pyx_f_6squish_4core_v_mat static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_neg_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":204 + /* "squish/core.pyx":208 * * cdef inline Vector2D v_neg_c(Vector2D* self) nogil: * return _Vector2D(-self.x, -self.y) # <<<<<<<<<<<<<< @@ -3337,7 +3399,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_neg_ __pyx_r = __pyx_f_6squish_4core__Vector2D((-__pyx_v_self->x), (-__pyx_v_self->y)); goto __pyx_L0; - /* "squish/core.pyx":203 + /* "squish/core.pyx":207 * return self * * cdef inline Vector2D v_neg_c(Vector2D* self) nogil: # <<<<<<<<<<<<<< @@ -3350,7 +3412,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_neg_ return __pyx_r; } -/* "squish/core.pyx":206 +/* "squish/core.pyx":210 * return _Vector2D(-self.x, -self.y) * * cdef inline Vector2D v_vadd_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3361,7 +3423,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_neg_ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vadd_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_Vector2D __pyx_v_w) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":207 + /* "squish/core.pyx":211 * * cdef inline Vector2D v_vadd_c(Vector2D* self, Vector2D w) nogil: * return _Vector2D(self.x + w.x, self.y + w.y) # <<<<<<<<<<<<<< @@ -3371,7 +3433,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vadd __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x + __pyx_v_w.x), (__pyx_v_self->y + __pyx_v_w.y)); goto __pyx_L0; - /* "squish/core.pyx":206 + /* "squish/core.pyx":210 * return _Vector2D(-self.x, -self.y) * * cdef inline Vector2D v_vadd_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3384,7 +3446,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vadd return __pyx_r; } -/* "squish/core.pyx":209 +/* "squish/core.pyx":213 * return _Vector2D(self.x + w.x, self.y + w.y) * * cdef inline Vector2D v_vsub_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3395,7 +3457,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vadd static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vsub_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_Vector2D __pyx_v_w) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":210 + /* "squish/core.pyx":214 * * cdef inline Vector2D v_vsub_c(Vector2D* self, Vector2D w) nogil: * return _Vector2D(self.x - w.x, self.y - w.y) # <<<<<<<<<<<<<< @@ -3405,7 +3467,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vsub __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x - __pyx_v_w.x), (__pyx_v_self->y - __pyx_v_w.y)); goto __pyx_L0; - /* "squish/core.pyx":209 + /* "squish/core.pyx":213 * return _Vector2D(self.x + w.x, self.y + w.y) * * cdef inline Vector2D v_vsub_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3418,7 +3480,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vsub return __pyx_r; } -/* "squish/core.pyx":212 +/* "squish/core.pyx":216 * return _Vector2D(self.x - w.x, self.y - w.y) * * cdef inline Vector2D v_vmul_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3429,7 +3491,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vsub static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vmul_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_Vector2D __pyx_v_w) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":213 + /* "squish/core.pyx":217 * * cdef inline Vector2D v_vmul_c(Vector2D* self, Vector2D w) nogil: * return _Vector2D(self.x * w.x, self.y * w.y) # <<<<<<<<<<<<<< @@ -3439,7 +3501,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vmul __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x * __pyx_v_w.x), (__pyx_v_self->y * __pyx_v_w.y)); goto __pyx_L0; - /* "squish/core.pyx":212 + /* "squish/core.pyx":216 * return _Vector2D(self.x - w.x, self.y - w.y) * * cdef inline Vector2D v_vmul_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3452,7 +3514,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vmul return __pyx_r; } -/* "squish/core.pyx":215 +/* "squish/core.pyx":219 * return _Vector2D(self.x * w.x, self.y * w.y) * * cdef inline Vector2D v_vdiv_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3463,7 +3525,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vmul static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vdiv_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_Vector2D __pyx_v_w) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":216 + /* "squish/core.pyx":220 * * cdef inline Vector2D v_vdiv_c(Vector2D* self, Vector2D w) nogil: * return _Vector2D(self.x / w.x, self.y / w.y) # <<<<<<<<<<<<<< @@ -3473,7 +3535,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vdiv __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x / __pyx_v_w.x), (__pyx_v_self->y / __pyx_v_w.y)); goto __pyx_L0; - /* "squish/core.pyx":215 + /* "squish/core.pyx":219 * return _Vector2D(self.x * w.x, self.y * w.y) * * cdef inline Vector2D v_vdiv_c(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3486,7 +3548,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vdiv return __pyx_r; } -/* "squish/core.pyx":218 +/* "squish/core.pyx":222 * return _Vector2D(self.x / w.x, self.y / w.y) * * cdef inline Vector2D v_sadd_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3497,7 +3559,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_vdiv static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sadd_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":219 + /* "squish/core.pyx":223 * * cdef inline Vector2D v_sadd_c(Vector2D* self, FLOAT_T s) nogil: * return _Vector2D(self.x + s, self.y + s) # <<<<<<<<<<<<<< @@ -3507,7 +3569,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sadd __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x + __pyx_v_s), (__pyx_v_self->y + __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":218 + /* "squish/core.pyx":222 * return _Vector2D(self.x / w.x, self.y / w.y) * * cdef inline Vector2D v_sadd_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3520,7 +3582,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sadd return __pyx_r; } -/* "squish/core.pyx":221 +/* "squish/core.pyx":225 * return _Vector2D(self.x + s, self.y + s) * * cdef inline Vector2D v_ssub_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3531,7 +3593,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sadd static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_ssub_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":222 + /* "squish/core.pyx":226 * * cdef inline Vector2D v_ssub_c(Vector2D* self, FLOAT_T s) nogil: * return _Vector2D(self.x + s, self.y + s) # <<<<<<<<<<<<<< @@ -3541,7 +3603,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_ssub __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x + __pyx_v_s), (__pyx_v_self->y + __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":221 + /* "squish/core.pyx":225 * return _Vector2D(self.x + s, self.y + s) * * cdef inline Vector2D v_ssub_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3554,7 +3616,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_ssub return __pyx_r; } -/* "squish/core.pyx":224 +/* "squish/core.pyx":228 * return _Vector2D(self.x + s, self.y + s) * * cdef inline Vector2D v_smul_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3565,7 +3627,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_ssub static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_smul_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":225 + /* "squish/core.pyx":229 * * cdef inline Vector2D v_smul_c(Vector2D* self, FLOAT_T s) nogil: * return _Vector2D(self.x * s, self.y * s) # <<<<<<<<<<<<<< @@ -3575,7 +3637,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_smul __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x * __pyx_v_s), (__pyx_v_self->y * __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":224 + /* "squish/core.pyx":228 * return _Vector2D(self.x + s, self.y + s) * * cdef inline Vector2D v_smul_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3588,7 +3650,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_smul return __pyx_r; } -/* "squish/core.pyx":227 +/* "squish/core.pyx":231 * return _Vector2D(self.x * s, self.y * s) * * cdef inline Vector2D v_sdiv_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3599,7 +3661,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_smul static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sdiv_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":228 + /* "squish/core.pyx":232 * * cdef inline Vector2D v_sdiv_c(Vector2D* self, FLOAT_T s) nogil: * return _Vector2D(self.x / s, self.y / s) # <<<<<<<<<<<<<< @@ -3609,7 +3671,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sdiv __pyx_r = __pyx_f_6squish_4core__Vector2D((__pyx_v_self->x / __pyx_v_s), (__pyx_v_self->y / __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":227 + /* "squish/core.pyx":231 * return _Vector2D(self.x * s, self.y * s) * * cdef inline Vector2D v_sdiv_c(Vector2D* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -3622,7 +3684,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sdiv return __pyx_r; } -/* "squish/core.pyx":230 +/* "squish/core.pyx":234 * return _Vector2D(self.x / s, self.y / s) * * cdef inline Vector2D v_matmul_c(Vector2D* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -3633,7 +3695,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_sdiv static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_matmul_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":231 + /* "squish/core.pyx":235 * * cdef inline Vector2D v_matmul_c(Vector2D* self, Matrix2x2 m) nogil: * return _Vector2D( # <<<<<<<<<<<<<< @@ -3643,7 +3705,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_matm __pyx_r = __pyx_f_6squish_4core__Vector2D(((__pyx_v_self->x * __pyx_v_m.a) + (__pyx_v_self->y * __pyx_v_m.c)), ((__pyx_v_self->x * __pyx_v_m.b) + (__pyx_v_self->y * __pyx_v_m.d))); goto __pyx_L0; - /* "squish/core.pyx":230 + /* "squish/core.pyx":234 * return _Vector2D(self.x / s, self.y / s) * * cdef inline Vector2D v_matmul_c(Vector2D* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -3656,20 +3718,20 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_v_matm return __pyx_r; } -/* "squish/core.pyx":235 +/* "squish/core.pyx":239 * ) * - * cdef inline Vector2D rot(Vector2D* self) nogil: # <<<<<<<<<<<<<< + * cdef inline Vector2D rot_c(Vector2D* self) nogil: # <<<<<<<<<<<<<< * return _Vector2D(-self.y, self.x) * */ -static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_rot(__pyx_t_6squish_4core_Vector2D *__pyx_v_self) { +static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_rot_c(__pyx_t_6squish_4core_Vector2D *__pyx_v_self) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":236 + /* "squish/core.pyx":240 * - * cdef inline Vector2D rot(Vector2D* self) nogil: + * cdef inline Vector2D rot_c(Vector2D* self) nogil: * return _Vector2D(-self.y, self.x) # <<<<<<<<<<<<<< * * cdef inline FLOAT_T dot(Vector2D* self, Vector2D w) nogil: @@ -3677,10 +3739,10 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_rot(__ __pyx_r = __pyx_f_6squish_4core__Vector2D((-__pyx_v_self->y), __pyx_v_self->x); goto __pyx_L0; - /* "squish/core.pyx":235 + /* "squish/core.pyx":239 * ) * - * cdef inline Vector2D rot(Vector2D* self) nogil: # <<<<<<<<<<<<<< + * cdef inline Vector2D rot_c(Vector2D* self) nogil: # <<<<<<<<<<<<<< * return _Vector2D(-self.y, self.x) * */ @@ -3690,7 +3752,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_rot(__ return __pyx_r; } -/* "squish/core.pyx":238 +/* "squish/core.pyx":242 * return _Vector2D(-self.y, self.x) * * cdef inline FLOAT_T dot(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3701,7 +3763,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_rot(__ static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_dot(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_Vector2D __pyx_v_w) { __pyx_t_6squish_4core_FLOAT_T __pyx_r; - /* "squish/core.pyx":239 + /* "squish/core.pyx":243 * * cdef inline FLOAT_T dot(Vector2D* self, Vector2D w) nogil: * return self.x*w.x + self.y*w.y # <<<<<<<<<<<<<< @@ -3711,7 +3773,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_dot(__p __pyx_r = ((__pyx_v_self->x * __pyx_v_w.x) + (__pyx_v_self->y * __pyx_v_w.y)); goto __pyx_L0; - /* "squish/core.pyx":238 + /* "squish/core.pyx":242 * return _Vector2D(-self.y, self.x) * * cdef inline FLOAT_T dot(Vector2D* self, Vector2D w) nogil: # <<<<<<<<<<<<<< @@ -3724,7 +3786,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_dot(__p return __pyx_r; } -/* "squish/core.pyx":241 +/* "squish/core.pyx":245 * return self.x*w.x + self.y*w.y * * cdef inline FLOAT_T mag(Vector2D* self) nogil: # <<<<<<<<<<<<<< @@ -3735,17 +3797,17 @@ static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_dot(__p static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_mag(__pyx_t_6squish_4core_Vector2D *__pyx_v_self) { __pyx_t_6squish_4core_FLOAT_T __pyx_r; - /* "squish/core.pyx":242 + /* "squish/core.pyx":246 * * cdef inline FLOAT_T mag(Vector2D* self) nogil: * return sqrt((self.x*self.x + self.y*self.y)) # <<<<<<<<<<<<<< * - * + * cdef inline Matrix2x2 v_vecmul(Vector2D* self, Vector2D v) nogil: */ __pyx_r = ((__pyx_t_6squish_4core_FLOAT_T)sqrt(((double)((__pyx_v_self->x * __pyx_v_self->x) + (__pyx_v_self->y * __pyx_v_self->y))))); goto __pyx_L0; - /* "squish/core.pyx":241 + /* "squish/core.pyx":245 * return self.x*w.x + self.y*w.y * * cdef inline FLOAT_T mag(Vector2D* self) nogil: # <<<<<<<<<<<<<< @@ -3758,7 +3820,41 @@ static CYTHON_INLINE __pyx_t_6squish_4core_FLOAT_T __pyx_f_6squish_4core_mag(__p return __pyx_r; } -/* "squish/core.pyx":247 +/* "squish/core.pyx":248 + * return sqrt((self.x*self.x + self.y*self.y)) + * + * cdef inline Matrix2x2 v_vecmul(Vector2D* self, Vector2D v) nogil: # <<<<<<<<<<<<<< + * return _Matrix2x2(self.x*v.x, self.x*v.y, self.y*v.x, self.y*v.y) + * + */ + +static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_v_vecmul(__pyx_t_6squish_4core_Vector2D *__pyx_v_self, __pyx_t_6squish_4core_Vector2D __pyx_v_v) { + __pyx_t_6squish_4core_Matrix2x2 __pyx_r; + + /* "squish/core.pyx":249 + * + * cdef inline Matrix2x2 v_vecmul(Vector2D* self, Vector2D v) nogil: + * return _Matrix2x2(self.x*v.x, self.x*v.y, self.y*v.x, self.y*v.y) # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->x * __pyx_v_v.x), (__pyx_v_self->x * __pyx_v_v.y), (__pyx_v_self->y * __pyx_v_v.x), (__pyx_v_self->y * __pyx_v_v.y)); + goto __pyx_L0; + + /* "squish/core.pyx":248 + * return sqrt((self.x*self.x + self.y*self.y)) + * + * cdef inline Matrix2x2 v_vecmul(Vector2D* self, Vector2D v) nogil: # <<<<<<<<<<<<<< + * return _Matrix2x2(self.x*v.x, self.x*v.y, self.y*v.x, self.y*v.y) + * + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "squish/core.pyx":254 * #### Matrix2x2 Methods #### * * cdef inline Matrix2x2 _Matrix2x2(FLOAT_T a, FLOAT_T b, FLOAT_T c, FLOAT_T d) nogil: # <<<<<<<<<<<<<< @@ -3778,7 +3874,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core__Matr int (*__pyx_t_7)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); __pyx_t_6squish_4core_Vector2D (*__pyx_t_8)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Vector2D); - /* "squish/core.pyx":249 + /* "squish/core.pyx":256 * cdef inline Matrix2x2 _Matrix2x2(FLOAT_T a, FLOAT_T b, FLOAT_T c, FLOAT_T d) nogil: * cdef Matrix2x2 matrix * matrix.a, matrix.b, matrix.c, matrix.d = a, b, c, d # <<<<<<<<<<<<<< @@ -3794,7 +3890,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core__Matr __pyx_v_matrix.c = __pyx_t_3; __pyx_v_matrix.d = __pyx_t_4; - /* "squish/core.pyx":250 + /* "squish/core.pyx":257 * cdef Matrix2x2 matrix * matrix.a, matrix.b, matrix.c, matrix.d = a, b, c, d * matrix.self, matrix.copy = MSO, MCO # <<<<<<<<<<<<<< @@ -3806,7 +3902,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core__Matr __pyx_v_matrix.self = __pyx_t_5; __pyx_v_matrix.copy = __pyx_t_6; - /* "squish/core.pyx":252 + /* "squish/core.pyx":259 * matrix.self, matrix.copy = MSO, MCO * * matrix.equals, matrix.vecmul = &m_equals, &m_vecmul # <<<<<<<<<<<<<< @@ -3818,7 +3914,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core__Matr __pyx_v_matrix.equals = __pyx_t_7; __pyx_v_matrix.vecmul = __pyx_t_8; - /* "squish/core.pyx":254 + /* "squish/core.pyx":261 * matrix.equals, matrix.vecmul = &m_equals, &m_vecmul * * return matrix # <<<<<<<<<<<<<< @@ -3828,7 +3924,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core__Matr __pyx_r = __pyx_v_matrix; goto __pyx_L0; - /* "squish/core.pyx":247 + /* "squish/core.pyx":254 * #### Matrix2x2 Methods #### * * cdef inline Matrix2x2 _Matrix2x2(FLOAT_T a, FLOAT_T b, FLOAT_T c, FLOAT_T d) nogil: # <<<<<<<<<<<<<< @@ -3841,7 +3937,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core__Matr return __pyx_r; } -/* "squish/core.pyx":256 +/* "squish/core.pyx":263 * return matrix * * cdef inline bint m_equals(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -3854,7 +3950,7 @@ static CYTHON_INLINE int __pyx_f_6squish_4core_m_equals(__pyx_t_6squish_4core_Ma int __pyx_t_1; int __pyx_t_2; - /* "squish/core.pyx":258 + /* "squish/core.pyx":265 * cdef inline bint m_equals(Matrix2x2* self, Matrix2x2 m) nogil: * return ( * (self.a == m.a) and (self.b == m.b) and (self.c == m.c) and (self.d == m.d) # <<<<<<<<<<<<<< @@ -3885,7 +3981,7 @@ static CYTHON_INLINE int __pyx_f_6squish_4core_m_equals(__pyx_t_6squish_4core_Ma __pyx_r = __pyx_t_1; goto __pyx_L0; - /* "squish/core.pyx":256 + /* "squish/core.pyx":263 * return matrix * * cdef inline bint m_equals(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -3898,7 +3994,7 @@ static CYTHON_INLINE int __pyx_f_6squish_4core_m_equals(__pyx_t_6squish_4core_Ma return __pyx_r; } -/* "squish/core.pyx":261 +/* "squish/core.pyx":268 * ) * * cdef inline Vector2D m_vecmul(Matrix2x2* self, Vector2D v) nogil: # <<<<<<<<<<<<<< @@ -3909,7 +4005,7 @@ static CYTHON_INLINE int __pyx_f_6squish_4core_m_equals(__pyx_t_6squish_4core_Ma static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_m_vecmul(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Vector2D __pyx_v_v) { __pyx_t_6squish_4core_Vector2D __pyx_r; - /* "squish/core.pyx":262 + /* "squish/core.pyx":269 * * cdef inline Vector2D m_vecmul(Matrix2x2* self, Vector2D v) nogil: * return _Vector2D( # <<<<<<<<<<<<<< @@ -3919,7 +4015,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_m_vecm __pyx_r = __pyx_f_6squish_4core__Vector2D(((__pyx_v_self->a * __pyx_v_v.x) + (__pyx_v_self->b * __pyx_v_v.y)), ((__pyx_v_self->c * __pyx_v_v.x) + (__pyx_v_self->d * __pyx_v_v.y))); goto __pyx_L0; - /* "squish/core.pyx":261 + /* "squish/core.pyx":268 * ) * * cdef inline Vector2D m_vecmul(Matrix2x2* self, Vector2D v) nogil: # <<<<<<<<<<<<<< @@ -3932,7 +4028,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Vector2D __pyx_f_6squish_4core_m_vecm return __pyx_r; } -/* "squish/core.pyx":266 +/* "squish/core.pyx":273 * ) * * cdef inline Matrix2x2* m_neg_s(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< @@ -3947,7 +4043,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ne __pyx_t_6squish_4core_FLOAT_T __pyx_t_3; __pyx_t_6squish_4core_FLOAT_T __pyx_t_4; - /* "squish/core.pyx":267 + /* "squish/core.pyx":274 * * cdef inline Matrix2x2* m_neg_s(Matrix2x2* self) nogil: * self.a, self.b, self.c, self.d = -self.a, -self.b, -self.c, -self.d # <<<<<<<<<<<<<< @@ -3963,7 +4059,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ne __pyx_v_self->c = __pyx_t_3; __pyx_v_self->d = __pyx_t_4; - /* "squish/core.pyx":268 + /* "squish/core.pyx":275 * cdef inline Matrix2x2* m_neg_s(Matrix2x2* self) nogil: * self.a, self.b, self.c, self.d = -self.a, -self.b, -self.c, -self.d * return self # <<<<<<<<<<<<<< @@ -3973,7 +4069,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ne __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":266 + /* "squish/core.pyx":273 * ) * * cdef inline Matrix2x2* m_neg_s(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< @@ -3986,7 +4082,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ne return __pyx_r; } -/* "squish/core.pyx":270 +/* "squish/core.pyx":277 * return self * * cdef inline Matrix2x2* m_madd_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -3997,7 +4093,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ne static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_madd_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":271 + /* "squish/core.pyx":278 * * cdef inline Matrix2x2* m_madd_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a += m.a # <<<<<<<<<<<<<< @@ -4006,7 +4102,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma */ __pyx_v_self->a = (__pyx_v_self->a + __pyx_v_m.a); - /* "squish/core.pyx":272 + /* "squish/core.pyx":279 * cdef inline Matrix2x2* m_madd_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a += m.a * self.b += m.b # <<<<<<<<<<<<<< @@ -4015,7 +4111,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma */ __pyx_v_self->b = (__pyx_v_self->b + __pyx_v_m.b); - /* "squish/core.pyx":273 + /* "squish/core.pyx":280 * self.a += m.a * self.b += m.b * self.c += m.c # <<<<<<<<<<<<<< @@ -4024,7 +4120,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma */ __pyx_v_self->c = (__pyx_v_self->c + __pyx_v_m.c); - /* "squish/core.pyx":274 + /* "squish/core.pyx":281 * self.b += m.b * self.c += m.c * self.d += m.d # <<<<<<<<<<<<<< @@ -4033,7 +4129,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma */ __pyx_v_self->d = (__pyx_v_self->d + __pyx_v_m.d); - /* "squish/core.pyx":275 + /* "squish/core.pyx":282 * self.c += m.c * self.d += m.d * return self # <<<<<<<<<<<<<< @@ -4043,7 +4139,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":270 + /* "squish/core.pyx":277 * return self * * cdef inline Matrix2x2* m_madd_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4056,7 +4152,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma return __pyx_r; } -/* "squish/core.pyx":277 +/* "squish/core.pyx":284 * return self * * cdef inline Matrix2x2* m_msub_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4067,7 +4163,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_msub_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":278 + /* "squish/core.pyx":285 * * cdef inline Matrix2x2* m_msub_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a -= m.a # <<<<<<<<<<<<<< @@ -4076,7 +4172,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ms */ __pyx_v_self->a = (__pyx_v_self->a - __pyx_v_m.a); - /* "squish/core.pyx":279 + /* "squish/core.pyx":286 * cdef inline Matrix2x2* m_msub_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a -= m.a * self.b -= m.b # <<<<<<<<<<<<<< @@ -4085,7 +4181,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ms */ __pyx_v_self->b = (__pyx_v_self->b - __pyx_v_m.b); - /* "squish/core.pyx":280 + /* "squish/core.pyx":287 * self.a -= m.a * self.b -= m.b * self.c -= m.c # <<<<<<<<<<<<<< @@ -4094,7 +4190,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ms */ __pyx_v_self->c = (__pyx_v_self->c - __pyx_v_m.c); - /* "squish/core.pyx":281 + /* "squish/core.pyx":288 * self.b -= m.b * self.c -= m.c * self.d -= m.d # <<<<<<<<<<<<<< @@ -4103,7 +4199,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ms */ __pyx_v_self->d = (__pyx_v_self->d - __pyx_v_m.d); - /* "squish/core.pyx":282 + /* "squish/core.pyx":289 * self.c -= m.c * self.d -= m.d * return self # <<<<<<<<<<<<<< @@ -4113,7 +4209,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ms __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":277 + /* "squish/core.pyx":284 * return self * * cdef inline Matrix2x2* m_msub_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4126,7 +4222,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ms return __pyx_r; } -/* "squish/core.pyx":284 +/* "squish/core.pyx":291 * return self * * cdef inline Matrix2x2* m_mmul_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4137,7 +4233,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ms static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mmul_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":285 + /* "squish/core.pyx":292 * * cdef inline Matrix2x2* m_mmul_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a *= m.a # <<<<<<<<<<<<<< @@ -4146,7 +4242,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mm */ __pyx_v_self->a = (__pyx_v_self->a * __pyx_v_m.a); - /* "squish/core.pyx":286 + /* "squish/core.pyx":293 * cdef inline Matrix2x2* m_mmul_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a *= m.a * self.b *= m.b # <<<<<<<<<<<<<< @@ -4155,7 +4251,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mm */ __pyx_v_self->b = (__pyx_v_self->b * __pyx_v_m.b); - /* "squish/core.pyx":287 + /* "squish/core.pyx":294 * self.a *= m.a * self.b *= m.b * self.c *= m.c # <<<<<<<<<<<<<< @@ -4164,7 +4260,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mm */ __pyx_v_self->c = (__pyx_v_self->c * __pyx_v_m.c); - /* "squish/core.pyx":288 + /* "squish/core.pyx":295 * self.b *= m.b * self.c *= m.c * self.d *= m.d # <<<<<<<<<<<<<< @@ -4173,7 +4269,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mm */ __pyx_v_self->d = (__pyx_v_self->d * __pyx_v_m.d); - /* "squish/core.pyx":289 + /* "squish/core.pyx":296 * self.c *= m.c * self.d *= m.d * return self # <<<<<<<<<<<<<< @@ -4183,7 +4279,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mm __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":284 + /* "squish/core.pyx":291 * return self * * cdef inline Matrix2x2* m_mmul_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4196,7 +4292,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mm return __pyx_r; } -/* "squish/core.pyx":291 +/* "squish/core.pyx":298 * return self * * cdef inline Matrix2x2* m_mdiv_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4207,7 +4303,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mm static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_mdiv_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":292 + /* "squish/core.pyx":299 * * cdef inline Matrix2x2* m_mdiv_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a /= m.a # <<<<<<<<<<<<<< @@ -4216,7 +4312,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_md */ __pyx_v_self->a = (__pyx_v_self->a / __pyx_v_m.a); - /* "squish/core.pyx":293 + /* "squish/core.pyx":300 * cdef inline Matrix2x2* m_mdiv_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a /= m.a * self.b /= m.b # <<<<<<<<<<<<<< @@ -4225,7 +4321,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_md */ __pyx_v_self->b = (__pyx_v_self->b / __pyx_v_m.b); - /* "squish/core.pyx":294 + /* "squish/core.pyx":301 * self.a /= m.a * self.b /= m.b * self.c /= m.c # <<<<<<<<<<<<<< @@ -4234,7 +4330,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_md */ __pyx_v_self->c = (__pyx_v_self->c / __pyx_v_m.c); - /* "squish/core.pyx":295 + /* "squish/core.pyx":302 * self.b /= m.b * self.c /= m.c * self.d /= m.d # <<<<<<<<<<<<<< @@ -4243,7 +4339,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_md */ __pyx_v_self->d = (__pyx_v_self->d / __pyx_v_m.d); - /* "squish/core.pyx":296 + /* "squish/core.pyx":303 * self.c /= m.c * self.d /= m.d * return self # <<<<<<<<<<<<<< @@ -4253,7 +4349,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_md __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":291 + /* "squish/core.pyx":298 * return self * * cdef inline Matrix2x2* m_mdiv_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4266,7 +4362,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_md return __pyx_r; } -/* "squish/core.pyx":298 +/* "squish/core.pyx":305 * return self * * cdef inline Matrix2x2* m_sadd_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4277,7 +4373,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_md static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sadd_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":299 + /* "squish/core.pyx":306 * * cdef inline Matrix2x2* m_sadd_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a += s # <<<<<<<<<<<<<< @@ -4286,7 +4382,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sa */ __pyx_v_self->a = (__pyx_v_self->a + __pyx_v_s); - /* "squish/core.pyx":300 + /* "squish/core.pyx":307 * cdef inline Matrix2x2* m_sadd_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a += s * self.b += s # <<<<<<<<<<<<<< @@ -4295,7 +4391,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sa */ __pyx_v_self->b = (__pyx_v_self->b + __pyx_v_s); - /* "squish/core.pyx":301 + /* "squish/core.pyx":308 * self.a += s * self.b += s * self.c += s # <<<<<<<<<<<<<< @@ -4304,7 +4400,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sa */ __pyx_v_self->c = (__pyx_v_self->c + __pyx_v_s); - /* "squish/core.pyx":302 + /* "squish/core.pyx":309 * self.b += s * self.c += s * self.d += s # <<<<<<<<<<<<<< @@ -4313,7 +4409,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sa */ __pyx_v_self->d = (__pyx_v_self->d + __pyx_v_s); - /* "squish/core.pyx":303 + /* "squish/core.pyx":310 * self.c += s * self.d += s * return self # <<<<<<<<<<<<<< @@ -4323,7 +4419,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sa __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":298 + /* "squish/core.pyx":305 * return self * * cdef inline Matrix2x2* m_sadd_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4336,7 +4432,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sa return __pyx_r; } -/* "squish/core.pyx":305 +/* "squish/core.pyx":312 * return self * * cdef inline Matrix2x2* m_ssub_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4347,7 +4443,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sa static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ssub_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":306 + /* "squish/core.pyx":313 * * cdef inline Matrix2x2* m_ssub_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a -= s # <<<<<<<<<<<<<< @@ -4356,7 +4452,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss */ __pyx_v_self->a = (__pyx_v_self->a - __pyx_v_s); - /* "squish/core.pyx":307 + /* "squish/core.pyx":314 * cdef inline Matrix2x2* m_ssub_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a -= s * self.b -= s # <<<<<<<<<<<<<< @@ -4365,7 +4461,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss */ __pyx_v_self->b = (__pyx_v_self->b - __pyx_v_s); - /* "squish/core.pyx":308 + /* "squish/core.pyx":315 * self.a -= s * self.b -= s * self.c -= s # <<<<<<<<<<<<<< @@ -4374,7 +4470,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss */ __pyx_v_self->c = (__pyx_v_self->c - __pyx_v_s); - /* "squish/core.pyx":309 + /* "squish/core.pyx":316 * self.b -= s * self.c -= s * self.d -= s # <<<<<<<<<<<<<< @@ -4383,7 +4479,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss */ __pyx_v_self->d = (__pyx_v_self->d - __pyx_v_s); - /* "squish/core.pyx":310 + /* "squish/core.pyx":317 * self.c -= s * self.d -= s * return self # <<<<<<<<<<<<<< @@ -4393,7 +4489,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":305 + /* "squish/core.pyx":312 * return self * * cdef inline Matrix2x2* m_ssub_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4406,7 +4502,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss return __pyx_r; } -/* "squish/core.pyx":312 +/* "squish/core.pyx":319 * return self * * cdef inline Matrix2x2* m_smul_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4417,7 +4513,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ss static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_smul_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":313 + /* "squish/core.pyx":320 * * cdef inline Matrix2x2* m_smul_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a *= s # <<<<<<<<<<<<<< @@ -4426,7 +4522,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sm */ __pyx_v_self->a = (__pyx_v_self->a * __pyx_v_s); - /* "squish/core.pyx":314 + /* "squish/core.pyx":321 * cdef inline Matrix2x2* m_smul_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a *= s * self.b *= s # <<<<<<<<<<<<<< @@ -4435,7 +4531,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sm */ __pyx_v_self->b = (__pyx_v_self->b * __pyx_v_s); - /* "squish/core.pyx":315 + /* "squish/core.pyx":322 * self.a *= s * self.b *= s * self.c *= s # <<<<<<<<<<<<<< @@ -4444,7 +4540,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sm */ __pyx_v_self->c = (__pyx_v_self->c * __pyx_v_s); - /* "squish/core.pyx":316 + /* "squish/core.pyx":323 * self.b *= s * self.c *= s * self.d *= s # <<<<<<<<<<<<<< @@ -4453,7 +4549,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sm */ __pyx_v_self->d = (__pyx_v_self->d * __pyx_v_s); - /* "squish/core.pyx":317 + /* "squish/core.pyx":324 * self.c *= s * self.d *= s * return self # <<<<<<<<<<<<<< @@ -4463,7 +4559,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sm __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":312 + /* "squish/core.pyx":319 * return self * * cdef inline Matrix2x2* m_smul_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4476,7 +4572,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sm return __pyx_r; } -/* "squish/core.pyx":319 +/* "squish/core.pyx":326 * return self * * cdef inline Matrix2x2* m_sdiv_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4487,7 +4583,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sm static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sdiv_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; - /* "squish/core.pyx":320 + /* "squish/core.pyx":327 * * cdef inline Matrix2x2* m_sdiv_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a /= s # <<<<<<<<<<<<<< @@ -4496,7 +4592,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sd */ __pyx_v_self->a = (__pyx_v_self->a / __pyx_v_s); - /* "squish/core.pyx":321 + /* "squish/core.pyx":328 * cdef inline Matrix2x2* m_sdiv_s(Matrix2x2* self, FLOAT_T s) nogil: * self.a /= s * self.b /= s # <<<<<<<<<<<<<< @@ -4505,7 +4601,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sd */ __pyx_v_self->b = (__pyx_v_self->b / __pyx_v_s); - /* "squish/core.pyx":322 + /* "squish/core.pyx":329 * self.a /= s * self.b /= s * self.c /= s # <<<<<<<<<<<<<< @@ -4514,7 +4610,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sd */ __pyx_v_self->c = (__pyx_v_self->c / __pyx_v_s); - /* "squish/core.pyx":323 + /* "squish/core.pyx":330 * self.b /= s * self.c /= s * self.d /= s # <<<<<<<<<<<<<< @@ -4523,7 +4619,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sd */ __pyx_v_self->d = (__pyx_v_self->d / __pyx_v_s); - /* "squish/core.pyx":324 + /* "squish/core.pyx":331 * self.c /= s * self.d /= s * return self # <<<<<<<<<<<<<< @@ -4533,7 +4629,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sd __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":319 + /* "squish/core.pyx":326 * return self * * cdef inline Matrix2x2* m_sdiv_s(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4546,7 +4642,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_sd return __pyx_r; } -/* "squish/core.pyx":326 +/* "squish/core.pyx":333 * return self * * cdef inline Matrix2x2* m_matmul_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4561,7 +4657,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma __pyx_t_6squish_4core_FLOAT_T __pyx_t_3; __pyx_t_6squish_4core_FLOAT_T __pyx_t_4; - /* "squish/core.pyx":328 + /* "squish/core.pyx":335 * cdef inline Matrix2x2* m_matmul_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a, self.b, self.c, self.d = \ * self.a*m.a + self.b*m.c, self.a*m.b + self.b*m.d, \ # <<<<<<<<<<<<<< @@ -4571,7 +4667,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma __pyx_t_1 = ((__pyx_v_self->a * __pyx_v_m.a) + (__pyx_v_self->b * __pyx_v_m.c)); __pyx_t_2 = ((__pyx_v_self->a * __pyx_v_m.b) + (__pyx_v_self->b * __pyx_v_m.d)); - /* "squish/core.pyx":329 + /* "squish/core.pyx":336 * self.a, self.b, self.c, self.d = \ * self.a*m.a + self.b*m.c, self.a*m.b + self.b*m.d, \ * self.c*m.a + self.d*m.c, self.c*m.b + self.d*m.d # <<<<<<<<<<<<<< @@ -4581,7 +4677,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma __pyx_t_3 = ((__pyx_v_self->c * __pyx_v_m.a) + (__pyx_v_self->d * __pyx_v_m.c)); __pyx_t_4 = ((__pyx_v_self->c * __pyx_v_m.b) + (__pyx_v_self->d * __pyx_v_m.d)); - /* "squish/core.pyx":327 + /* "squish/core.pyx":334 * * cdef inline Matrix2x2* m_matmul_s(Matrix2x2* self, Matrix2x2 m) nogil: * self.a, self.b, self.c, self.d = \ # <<<<<<<<<<<<<< @@ -4593,17 +4689,17 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma __pyx_v_self->c = __pyx_t_3; __pyx_v_self->d = __pyx_t_4; - /* "squish/core.pyx":330 + /* "squish/core.pyx":337 * self.a*m.a + self.b*m.c, self.a*m.b + self.b*m.d, \ * self.c*m.a + self.d*m.c, self.c*m.b + self.d*m.d * return self # <<<<<<<<<<<<<< * - * cdef inline Matrix2x2 m_neg_c(Matrix2x2* self) nogil: + * cdef inline Matrix2x2* m_transpose_s(Matrix2x2* self) nogil: */ __pyx_r = __pyx_v_self; goto __pyx_L0; - /* "squish/core.pyx":326 + /* "squish/core.pyx":333 * return self * * cdef inline Matrix2x2* m_matmul_s(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4616,7 +4712,55 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma return __pyx_r; } -/* "squish/core.pyx":332 +/* "squish/core.pyx":339 + * return self + * + * cdef inline Matrix2x2* m_transpose_s(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< + * self.b, self.c = self.c, self.b + * return self + */ + +static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_transpose_s(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self) { + __pyx_t_6squish_4core_Matrix2x2 *__pyx_r; + __pyx_t_6squish_4core_FLOAT_T __pyx_t_1; + __pyx_t_6squish_4core_FLOAT_T __pyx_t_2; + + /* "squish/core.pyx":340 + * + * cdef inline Matrix2x2* m_transpose_s(Matrix2x2* self) nogil: + * self.b, self.c = self.c, self.b # <<<<<<<<<<<<<< + * return self + * + */ + __pyx_t_1 = __pyx_v_self->c; + __pyx_t_2 = __pyx_v_self->b; + __pyx_v_self->b = __pyx_t_1; + __pyx_v_self->c = __pyx_t_2; + + /* "squish/core.pyx":341 + * cdef inline Matrix2x2* m_transpose_s(Matrix2x2* self) nogil: + * self.b, self.c = self.c, self.b + * return self # <<<<<<<<<<<<<< + * + * cdef inline Matrix2x2 m_neg_c(Matrix2x2* self) nogil: + */ + __pyx_r = __pyx_v_self; + goto __pyx_L0; + + /* "squish/core.pyx":339 + * return self + * + * cdef inline Matrix2x2* m_transpose_s(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< + * self.b, self.c = self.c, self.b + * return self + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "squish/core.pyx":343 * return self * * cdef inline Matrix2x2 m_neg_c(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< @@ -4627,7 +4771,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 *__pyx_f_6squish_4core_m_ma static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_neg_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":333 + /* "squish/core.pyx":344 * * cdef inline Matrix2x2 m_neg_c(Matrix2x2* self) nogil: * return _Matrix2x2(-self.a, -self.b, -self.c, -self.d) # <<<<<<<<<<<<<< @@ -4637,7 +4781,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_neg __pyx_r = __pyx_f_6squish_4core__Matrix2x2((-__pyx_v_self->a), (-__pyx_v_self->b), (-__pyx_v_self->c), (-__pyx_v_self->d)); goto __pyx_L0; - /* "squish/core.pyx":332 + /* "squish/core.pyx":343 * return self * * cdef inline Matrix2x2 m_neg_c(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< @@ -4650,7 +4794,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_neg return __pyx_r; } -/* "squish/core.pyx":335 +/* "squish/core.pyx":346 * return _Matrix2x2(-self.a, -self.b, -self.c, -self.d) * * cdef inline Matrix2x2 m_madd_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4661,7 +4805,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_neg static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_madd_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":336 + /* "squish/core.pyx":347 * * cdef inline Matrix2x2 m_madd_c(Matrix2x2* self, Matrix2x2 m) nogil: * return _Matrix2x2(self.a+m.a, self.b+m.b, self.c+m.c, self.d+m.d) # <<<<<<<<<<<<<< @@ -4671,7 +4815,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mad __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a + __pyx_v_m.a), (__pyx_v_self->b + __pyx_v_m.b), (__pyx_v_self->c + __pyx_v_m.c), (__pyx_v_self->d + __pyx_v_m.d)); goto __pyx_L0; - /* "squish/core.pyx":335 + /* "squish/core.pyx":346 * return _Matrix2x2(-self.a, -self.b, -self.c, -self.d) * * cdef inline Matrix2x2 m_madd_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4684,7 +4828,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mad return __pyx_r; } -/* "squish/core.pyx":338 +/* "squish/core.pyx":349 * return _Matrix2x2(self.a+m.a, self.b+m.b, self.c+m.c, self.d+m.d) * * cdef inline Matrix2x2 m_msub_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4695,7 +4839,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mad static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_msub_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":339 + /* "squish/core.pyx":350 * * cdef inline Matrix2x2 m_msub_c(Matrix2x2* self, Matrix2x2 m) nogil: * return _Matrix2x2(self.a-m.a, self.b-m.b, self.c-m.c, self.d-m.d) # <<<<<<<<<<<<<< @@ -4705,7 +4849,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_msu __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a - __pyx_v_m.a), (__pyx_v_self->b - __pyx_v_m.b), (__pyx_v_self->c - __pyx_v_m.c), (__pyx_v_self->d - __pyx_v_m.d)); goto __pyx_L0; - /* "squish/core.pyx":338 + /* "squish/core.pyx":349 * return _Matrix2x2(self.a+m.a, self.b+m.b, self.c+m.c, self.d+m.d) * * cdef inline Matrix2x2 m_msub_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4718,7 +4862,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_msu return __pyx_r; } -/* "squish/core.pyx":341 +/* "squish/core.pyx":352 * return _Matrix2x2(self.a-m.a, self.b-m.b, self.c-m.c, self.d-m.d) * * cdef inline Matrix2x2 m_mmul_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4729,7 +4873,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_msu static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mmul_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":342 + /* "squish/core.pyx":353 * * cdef inline Matrix2x2 m_mmul_c(Matrix2x2* self, Matrix2x2 m) nogil: * return _Matrix2x2(self.a*m.a, self.b*m.b, self.c*m.c, self.d*m.d) # <<<<<<<<<<<<<< @@ -4739,7 +4883,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mmu __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a * __pyx_v_m.a), (__pyx_v_self->b * __pyx_v_m.b), (__pyx_v_self->c * __pyx_v_m.c), (__pyx_v_self->d * __pyx_v_m.d)); goto __pyx_L0; - /* "squish/core.pyx":341 + /* "squish/core.pyx":352 * return _Matrix2x2(self.a-m.a, self.b-m.b, self.c-m.c, self.d-m.d) * * cdef inline Matrix2x2 m_mmul_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4752,7 +4896,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mmu return __pyx_r; } -/* "squish/core.pyx":344 +/* "squish/core.pyx":355 * return _Matrix2x2(self.a*m.a, self.b*m.b, self.c*m.c, self.d*m.d) * * cdef inline Matrix2x2 m_mdiv_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4763,7 +4907,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mmu static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mdiv_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":345 + /* "squish/core.pyx":356 * * cdef inline Matrix2x2 m_mdiv_c(Matrix2x2* self, Matrix2x2 m) nogil: * return _Matrix2x2(self.a/m.a, self.b/m.b, self.c/m.c, self.d/m.d) # <<<<<<<<<<<<<< @@ -4773,7 +4917,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mdi __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a / __pyx_v_m.a), (__pyx_v_self->b / __pyx_v_m.b), (__pyx_v_self->c / __pyx_v_m.c), (__pyx_v_self->d / __pyx_v_m.d)); goto __pyx_L0; - /* "squish/core.pyx":344 + /* "squish/core.pyx":355 * return _Matrix2x2(self.a*m.a, self.b*m.b, self.c*m.c, self.d*m.d) * * cdef inline Matrix2x2 m_mdiv_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4786,7 +4930,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mdi return __pyx_r; } -/* "squish/core.pyx":347 +/* "squish/core.pyx":358 * return _Matrix2x2(self.a/m.a, self.b/m.b, self.c/m.c, self.d/m.d) * * cdef inline Matrix2x2 m_sadd_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4797,7 +4941,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mdi static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sadd_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":348 + /* "squish/core.pyx":359 * * cdef inline Matrix2x2 m_sadd_c(Matrix2x2* self, FLOAT_T s) nogil: * return _Matrix2x2(self.a+s, self.b+s, self.c+s, self.d+s) # <<<<<<<<<<<<<< @@ -4807,7 +4951,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sad __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a + __pyx_v_s), (__pyx_v_self->b + __pyx_v_s), (__pyx_v_self->c + __pyx_v_s), (__pyx_v_self->d + __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":347 + /* "squish/core.pyx":358 * return _Matrix2x2(self.a/m.a, self.b/m.b, self.c/m.c, self.d/m.d) * * cdef inline Matrix2x2 m_sadd_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4820,7 +4964,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sad return __pyx_r; } -/* "squish/core.pyx":350 +/* "squish/core.pyx":361 * return _Matrix2x2(self.a+s, self.b+s, self.c+s, self.d+s) * * cdef inline Matrix2x2 m_ssub_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4831,7 +4975,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sad static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_ssub_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":351 + /* "squish/core.pyx":362 * * cdef inline Matrix2x2 m_ssub_c(Matrix2x2* self, FLOAT_T s) nogil: * return _Matrix2x2(self.a-s, self.b-s, self.c-s, self.d-s) # <<<<<<<<<<<<<< @@ -4841,7 +4985,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_ssu __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a - __pyx_v_s), (__pyx_v_self->b - __pyx_v_s), (__pyx_v_self->c - __pyx_v_s), (__pyx_v_self->d - __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":350 + /* "squish/core.pyx":361 * return _Matrix2x2(self.a+s, self.b+s, self.c+s, self.d+s) * * cdef inline Matrix2x2 m_ssub_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4854,7 +4998,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_ssu return __pyx_r; } -/* "squish/core.pyx":353 +/* "squish/core.pyx":364 * return _Matrix2x2(self.a-s, self.b-s, self.c-s, self.d-s) * * cdef inline Matrix2x2 m_smul_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4865,7 +5009,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_ssu static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_smul_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":354 + /* "squish/core.pyx":365 * * cdef inline Matrix2x2 m_smul_c(Matrix2x2* self, FLOAT_T s) nogil: * return _Matrix2x2(self.a*s, self.b*s, self.c*s, self.d*s) # <<<<<<<<<<<<<< @@ -4875,7 +5019,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_smu __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a * __pyx_v_s), (__pyx_v_self->b * __pyx_v_s), (__pyx_v_self->c * __pyx_v_s), (__pyx_v_self->d * __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":353 + /* "squish/core.pyx":364 * return _Matrix2x2(self.a-s, self.b-s, self.c-s, self.d-s) * * cdef inline Matrix2x2 m_smul_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4888,7 +5032,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_smu return __pyx_r; } -/* "squish/core.pyx":356 +/* "squish/core.pyx":367 * return _Matrix2x2(self.a*s, self.b*s, self.c*s, self.d*s) * * cdef inline Matrix2x2 m_sdiv_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4899,7 +5043,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_smu static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sdiv_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_s) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":357 + /* "squish/core.pyx":368 * * cdef inline Matrix2x2 m_sdiv_c(Matrix2x2* self, FLOAT_T s) nogil: * return _Matrix2x2(self.a/s, self.b/s, self.c/s, self.d/s) # <<<<<<<<<<<<<< @@ -4909,7 +5053,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sdi __pyx_r = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_self->a / __pyx_v_s), (__pyx_v_self->b / __pyx_v_s), (__pyx_v_self->c / __pyx_v_s), (__pyx_v_self->d / __pyx_v_s)); goto __pyx_L0; - /* "squish/core.pyx":356 + /* "squish/core.pyx":367 * return _Matrix2x2(self.a*s, self.b*s, self.c*s, self.d*s) * * cdef inline Matrix2x2 m_sdiv_c(Matrix2x2* self, FLOAT_T s) nogil: # <<<<<<<<<<<<<< @@ -4922,7 +5066,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sdi return __pyx_r; } -/* "squish/core.pyx":359 +/* "squish/core.pyx":370 * return _Matrix2x2(self.a/s, self.b/s, self.c/s, self.d/s) * * cdef inline Matrix2x2 m_matmul_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4933,7 +5077,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_sdi static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_matmul_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self, __pyx_t_6squish_4core_Matrix2x2 __pyx_v_m) { __pyx_t_6squish_4core_Matrix2x2 __pyx_r; - /* "squish/core.pyx":360 + /* "squish/core.pyx":371 * * cdef inline Matrix2x2 m_matmul_c(Matrix2x2* self, Matrix2x2 m) nogil: * return _Matrix2x2( # <<<<<<<<<<<<<< @@ -4943,7 +5087,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mat __pyx_r = __pyx_f_6squish_4core__Matrix2x2(((__pyx_v_self->a * __pyx_v_m.a) + (__pyx_v_self->b * __pyx_v_m.c)), ((__pyx_v_self->a * __pyx_v_m.b) + (__pyx_v_self->b * __pyx_v_m.d)), ((__pyx_v_self->c * __pyx_v_m.a) + (__pyx_v_self->d * __pyx_v_m.c)), ((__pyx_v_self->c * __pyx_v_m.b) + (__pyx_v_self->d * __pyx_v_m.d))); goto __pyx_L0; - /* "squish/core.pyx":359 + /* "squish/core.pyx":370 * return _Matrix2x2(self.a/s, self.b/s, self.c/s, self.d/s) * * cdef inline Matrix2x2 m_matmul_c(Matrix2x2* self, Matrix2x2 m) nogil: # <<<<<<<<<<<<<< @@ -4956,7 +5100,37 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_mat return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":735 +/* "squish/core.pyx":376 + * ) + * + * cdef inline Matrix2x2 m_transpose_c(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< + * return _Matrix2x2(self.a, self.c, self.b, self.d) + */ + +static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_4core_m_transpose_c(__pyx_t_6squish_4core_Matrix2x2 *__pyx_v_self) { + __pyx_t_6squish_4core_Matrix2x2 __pyx_r; + + /* "squish/core.pyx":377 + * + * cdef inline Matrix2x2 m_transpose_c(Matrix2x2* self) nogil: + * return _Matrix2x2(self.a, self.c, self.b, self.d) # <<<<<<<<<<<<<< + */ + __pyx_r = __pyx_f_6squish_4core__Matrix2x2(__pyx_v_self->a, __pyx_v_self->c, __pyx_v_self->b, __pyx_v_self->d); + goto __pyx_L0; + + /* "squish/core.pyx":376 + * ) + * + * cdef inline Matrix2x2 m_transpose_c(Matrix2x2* self) nogil: # <<<<<<<<<<<<<< + * return _Matrix2x2(self.a, self.c, self.b, self.d) + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":735 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -4973,7 +5147,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":736 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":736 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -4987,7 +5161,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":735 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":735 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5006,7 +5180,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":738 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":738 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5023,7 +5197,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":739 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":739 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -5037,7 +5211,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":738 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":738 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5056,7 +5230,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":741 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":741 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5073,7 +5247,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":742 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":742 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -5087,7 +5261,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":741 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":741 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5106,7 +5280,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":744 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":744 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5123,7 +5297,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":745 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":745 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -5137,7 +5311,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":744 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":744 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5156,7 +5330,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":747 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":747 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5173,7 +5347,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":748 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":748 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -5187,7 +5361,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":747 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":747 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5206,7 +5380,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":750 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":750 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -5220,7 +5394,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ int __pyx_t_1; __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":751 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":751 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -5230,7 +5404,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); if (__pyx_t_1) { - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":752 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":752 * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): * return d.subarray.shape # <<<<<<<<<<<<<< @@ -5242,7 +5416,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":751 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":751 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -5251,7 +5425,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ */ } - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":754 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":754 * return d.subarray.shape * else: * return () # <<<<<<<<<<<<<< @@ -5265,7 +5439,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ goto __pyx_L0; } - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":750 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":750 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -5280,7 +5454,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":929 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":929 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -5292,7 +5466,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":930 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":930 * * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< @@ -5301,7 +5475,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":931 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":931 * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< @@ -5310,7 +5484,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":929 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":929 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -5322,7 +5496,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":933 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":933 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -5337,7 +5511,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":934 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":934 * * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< @@ -5346,7 +5520,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ __pyx_v_base = PyArray_BASE(__pyx_v_arr); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":935 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":935 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -5356,7 +5530,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = ((__pyx_v_base == NULL) != 0); if (__pyx_t_1) { - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":936 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":936 * base = PyArray_BASE(arr) * if base is NULL: * return None # <<<<<<<<<<<<<< @@ -5367,7 +5541,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":935 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":935 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -5376,7 +5550,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ } - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":937 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":937 * if base is NULL: * return None * return base # <<<<<<<<<<<<<< @@ -5388,7 +5562,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = ((PyObject *)__pyx_v_base); goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":933 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":933 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -5403,7 +5577,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":941 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":941 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -5427,7 +5601,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("import_array", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":942 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":942 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -5443,7 +5617,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":943 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":943 * cdef inline int import_array() except -1: * try: * __pyx_import_array() # <<<<<<<<<<<<<< @@ -5452,7 +5626,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { */ __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 943, __pyx_L3_error) - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":942 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":942 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -5466,7 +5640,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":944 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":944 * try: * __pyx_import_array() * except Exception: # <<<<<<<<<<<<<< @@ -5481,7 +5655,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":945 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":945 * __pyx_import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< @@ -5497,7 +5671,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":942 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":942 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -5512,7 +5686,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_L8_try_end:; } - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":941 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":941 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -5535,7 +5709,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":947 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":947 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -5559,7 +5733,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("import_umath", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":948 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":948 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -5575,7 +5749,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":949 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":949 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< @@ -5584,7 +5758,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 949, __pyx_L3_error) - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":948 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":948 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -5598,7 +5772,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":950 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":950 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -5613,7 +5787,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":951 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":951 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -5629,7 +5803,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":948 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":948 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -5644,7 +5818,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_L8_try_end:; } - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":947 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":947 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -5667,7 +5841,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":953 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":953 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -5691,7 +5865,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("import_ufunc", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":954 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":954 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -5707,7 +5881,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":955 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":955 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< @@ -5716,7 +5890,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 955, __pyx_L3_error) - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":954 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":954 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -5730,7 +5904,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":956 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":956 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -5745,7 +5919,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":957 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":957 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -5761,7 +5935,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":954 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":954 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -5776,7 +5950,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_L8_try_end:; } - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":953 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":953 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -5799,7 +5973,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":967 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":967 * * * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< @@ -5812,7 +5986,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_timedelta64_object", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":979 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":979 * bool * """ * return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) # <<<<<<<<<<<<<< @@ -5822,7 +5996,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_ __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type)); goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":967 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":967 * * * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< @@ -5836,7 +6010,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_ return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":982 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":982 * * * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< @@ -5849,7 +6023,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_o __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_datetime64_object", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":994 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":994 * bool * """ * return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) # <<<<<<<<<<<<<< @@ -5859,7 +6033,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_o __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type)); goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":982 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":982 * * * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< @@ -5873,7 +6047,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_o return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":997 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":997 * * * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -5884,7 +6058,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_o static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) { npy_datetime __pyx_r; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1004 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1004 * also needed. That can be found using `get_datetime64_unit`. * """ * return (obj).obval # <<<<<<<<<<<<<< @@ -5894,7 +6068,7 @@ static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject * __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval; goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":997 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":997 * * * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -5907,7 +6081,7 @@ static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject * return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1007 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1007 * * * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -5918,7 +6092,7 @@ static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject * static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) { npy_timedelta __pyx_r; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1011 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1011 * returns the int64 value underlying scalar numpy timedelta64 object * """ * return (obj).obval # <<<<<<<<<<<<<< @@ -5928,7 +6102,7 @@ static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval; goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1007 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1007 * * * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< @@ -5941,7 +6115,7 @@ static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject return __pyx_r; } -/* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1014 +/* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1014 * * * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< @@ -5952,7 +6126,7 @@ static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) { NPY_DATETIMEUNIT __pyx_r; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1018 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1018 * returns the unit part of the dtype for a numpy datetime64 object. * """ * return (obj).obmeta.base # <<<<<<<<<<<<<< @@ -5960,7 +6134,7 @@ static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObjec __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base); goto __pyx_L0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1014 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1014 * * * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< @@ -6043,7 +6217,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":945 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":945 * __pyx_import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< @@ -6054,7 +6228,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":951 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":951 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -6308,34 +6482,42 @@ static CYTHON_SMALL_CODE int __pyx_pymod_exec_core(PyObject *__pyx_pyinit_module __pyx_t_6squish_4core_Vector2D *(*__pyx_t_7)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); __pyx_t_6squish_4core_Vector2D *(*__pyx_t_8)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); __pyx_t_6squish_4core_Vector2D *(*__pyx_t_9)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Vector2D (*__pyx_t_10)(__pyx_t_6squish_4core_Vector2D *); - __pyx_t_6squish_4core_Vector2D (*__pyx_t_11)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); - __pyx_t_6squish_4core_Vector2D (*__pyx_t_12)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); + __pyx_t_6squish_4core_Vector2D *(*__pyx_t_10)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Vector2D *(*__pyx_t_11)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Vector2D (*__pyx_t_12)(__pyx_t_6squish_4core_Vector2D *); __pyx_t_6squish_4core_Vector2D (*__pyx_t_13)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_Vector2D (*__pyx_t_14)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); - __pyx_t_6squish_4core_Vector2D (*__pyx_t_15)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Vector2D (*__pyx_t_16)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Vector2D (*__pyx_t_15)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); + __pyx_t_6squish_4core_Vector2D (*__pyx_t_16)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_Vector2D (*__pyx_t_17)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); __pyx_t_6squish_4core_Vector2D (*__pyx_t_18)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_19)(__pyx_t_6squish_4core_Matrix2x2 *); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_20)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_21)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_22)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_23)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_24)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_25)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_26)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_27)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_28)(__pyx_t_6squish_4core_Matrix2x2 *); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_29)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_30)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_31)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_32)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_33)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_34)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_35)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_36)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); - PyObject *__pyx_t_37 = NULL; + __pyx_t_6squish_4core_Vector2D (*__pyx_t_19)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Vector2D (*__pyx_t_20)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Vector2D (*__pyx_t_21)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Vector2D (*__pyx_t_22)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_23)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_24)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_25)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_26)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_27)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_28)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_29)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_30)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_31)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_32)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 *(*__pyx_t_33)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_34)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_35)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_36)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_37)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_38)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_39)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_40)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_41)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_42)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_FLOAT_T); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_43)(__pyx_t_6squish_4core_Matrix2x2 *, __pyx_t_6squish_4core_Matrix2x2); + __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_44)(__pyx_t_6squish_4core_Matrix2x2 *); + PyObject *__pyx_t_45 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -6454,7 +6636,7 @@ if (!__Pyx_RefNanny) { * * VSO.neg, VSO.vadd, VSO.vsub, VSO.vmul, VSO.vdiv, VSO.sadd, VSO.ssub, VSO.smul, VSO.sdiv = \ * v_neg_s, v_vadd_s, v_vsub_s, v_vmul_s, v_vdiv_s, v_sadd_s, v_ssub_s, v_smul_s, v_sdiv_s # <<<<<<<<<<<<<< - * VSO.matmul = v_matmul_s + * VSO.matmul, VSO.rot = v_matmul_s, rot_s * */ __pyx_t_1 = __pyx_f_6squish_4core_v_neg_s; @@ -6472,7 +6654,7 @@ if (!__Pyx_RefNanny) { * * VSO.neg, VSO.vadd, VSO.vsub, VSO.vmul, VSO.vdiv, VSO.sadd, VSO.ssub, VSO.smul, VSO.sdiv = \ # <<<<<<<<<<<<<< * v_neg_s, v_vadd_s, v_vsub_s, v_vmul_s, v_vdiv_s, v_sadd_s, v_ssub_s, v_smul_s, v_sdiv_s - * VSO.matmul = v_matmul_s + * VSO.matmul, VSO.rot = v_matmul_s, rot_s */ __pyx_v_6squish_4core_VSO.neg = __pyx_t_1; __pyx_v_6squish_4core_VSO.vadd = __pyx_t_2; @@ -6487,152 +6669,164 @@ if (!__Pyx_RefNanny) { /* "squish/core.pyx":21 * VSO.neg, VSO.vadd, VSO.vsub, VSO.vmul, VSO.vdiv, VSO.sadd, VSO.ssub, VSO.smul, VSO.sdiv = \ * v_neg_s, v_vadd_s, v_vsub_s, v_vmul_s, v_vdiv_s, v_sadd_s, v_ssub_s, v_smul_s, v_sdiv_s - * VSO.matmul = v_matmul_s # <<<<<<<<<<<<<< + * VSO.matmul, VSO.rot = v_matmul_s, rot_s # <<<<<<<<<<<<<< * * VCO.neg, VCO.vadd, VCO.vsub, VCO.vmul, VCO.vdiv, VCO.sadd, VCO.ssub, VCO.smul, VCO.sdiv = \ */ - __pyx_v_6squish_4core_VSO.matmul = __pyx_f_6squish_4core_v_matmul_s; + __pyx_t_10 = __pyx_f_6squish_4core_v_matmul_s; + __pyx_t_11 = __pyx_f_6squish_4core_rot_s; + __pyx_v_6squish_4core_VSO.matmul = __pyx_t_10; + __pyx_v_6squish_4core_VSO.rot = __pyx_t_11; /* "squish/core.pyx":24 * * VCO.neg, VCO.vadd, VCO.vsub, VCO.vmul, VCO.vdiv, VCO.sadd, VCO.ssub, VCO.smul, VCO.sdiv = \ * v_neg_c, v_vadd_c, v_vsub_c, v_vmul_c, v_vdiv_c, v_sadd_c, v_ssub_c, v_smul_c, v_sdiv_c # <<<<<<<<<<<<<< - * VCO.matmul = v_matmul_c + * VCO.matmul, VCO.rot = v_matmul_c, rot_c * */ - __pyx_t_10 = __pyx_f_6squish_4core_v_neg_c; - __pyx_t_11 = __pyx_f_6squish_4core_v_vadd_c; - __pyx_t_12 = __pyx_f_6squish_4core_v_vsub_c; - __pyx_t_13 = __pyx_f_6squish_4core_v_vmul_c; - __pyx_t_14 = __pyx_f_6squish_4core_v_vdiv_c; - __pyx_t_15 = __pyx_f_6squish_4core_v_sadd_c; - __pyx_t_16 = __pyx_f_6squish_4core_v_ssub_c; - __pyx_t_17 = __pyx_f_6squish_4core_v_smul_c; - __pyx_t_18 = __pyx_f_6squish_4core_v_sdiv_c; + __pyx_t_12 = __pyx_f_6squish_4core_v_neg_c; + __pyx_t_13 = __pyx_f_6squish_4core_v_vadd_c; + __pyx_t_14 = __pyx_f_6squish_4core_v_vsub_c; + __pyx_t_15 = __pyx_f_6squish_4core_v_vmul_c; + __pyx_t_16 = __pyx_f_6squish_4core_v_vdiv_c; + __pyx_t_17 = __pyx_f_6squish_4core_v_sadd_c; + __pyx_t_18 = __pyx_f_6squish_4core_v_ssub_c; + __pyx_t_19 = __pyx_f_6squish_4core_v_smul_c; + __pyx_t_20 = __pyx_f_6squish_4core_v_sdiv_c; /* "squish/core.pyx":23 - * VSO.matmul = v_matmul_s + * VSO.matmul, VSO.rot = v_matmul_s, rot_s * * VCO.neg, VCO.vadd, VCO.vsub, VCO.vmul, VCO.vdiv, VCO.sadd, VCO.ssub, VCO.smul, VCO.sdiv = \ # <<<<<<<<<<<<<< * v_neg_c, v_vadd_c, v_vsub_c, v_vmul_c, v_vdiv_c, v_sadd_c, v_ssub_c, v_smul_c, v_sdiv_c - * VCO.matmul = v_matmul_c + * VCO.matmul, VCO.rot = v_matmul_c, rot_c */ - __pyx_v_6squish_4core_VCO.neg = __pyx_t_10; - __pyx_v_6squish_4core_VCO.vadd = __pyx_t_11; - __pyx_v_6squish_4core_VCO.vsub = __pyx_t_12; - __pyx_v_6squish_4core_VCO.vmul = __pyx_t_13; - __pyx_v_6squish_4core_VCO.vdiv = __pyx_t_14; - __pyx_v_6squish_4core_VCO.sadd = __pyx_t_15; - __pyx_v_6squish_4core_VCO.ssub = __pyx_t_16; - __pyx_v_6squish_4core_VCO.smul = __pyx_t_17; - __pyx_v_6squish_4core_VCO.sdiv = __pyx_t_18; + __pyx_v_6squish_4core_VCO.neg = __pyx_t_12; + __pyx_v_6squish_4core_VCO.vadd = __pyx_t_13; + __pyx_v_6squish_4core_VCO.vsub = __pyx_t_14; + __pyx_v_6squish_4core_VCO.vmul = __pyx_t_15; + __pyx_v_6squish_4core_VCO.vdiv = __pyx_t_16; + __pyx_v_6squish_4core_VCO.sadd = __pyx_t_17; + __pyx_v_6squish_4core_VCO.ssub = __pyx_t_18; + __pyx_v_6squish_4core_VCO.smul = __pyx_t_19; + __pyx_v_6squish_4core_VCO.sdiv = __pyx_t_20; /* "squish/core.pyx":25 * VCO.neg, VCO.vadd, VCO.vsub, VCO.vmul, VCO.vdiv, VCO.sadd, VCO.ssub, VCO.smul, VCO.sdiv = \ * v_neg_c, v_vadd_c, v_vsub_c, v_vmul_c, v_vdiv_c, v_sadd_c, v_ssub_c, v_smul_c, v_sdiv_c - * VCO.matmul = v_matmul_c # <<<<<<<<<<<<<< + * VCO.matmul, VCO.rot = v_matmul_c, rot_c # <<<<<<<<<<<<<< * * MSO.neg, MSO.madd, MSO.msub, MSO.mmul, MSO.mdiv, MSO.sadd, MSO.ssub, MSO.smul, MSO.sdiv = \ */ - __pyx_v_6squish_4core_VCO.matmul = __pyx_f_6squish_4core_v_matmul_c; + __pyx_t_21 = __pyx_f_6squish_4core_v_matmul_c; + __pyx_t_22 = __pyx_f_6squish_4core_rot_c; + __pyx_v_6squish_4core_VCO.matmul = __pyx_t_21; + __pyx_v_6squish_4core_VCO.rot = __pyx_t_22; /* "squish/core.pyx":28 * * MSO.neg, MSO.madd, MSO.msub, MSO.mmul, MSO.mdiv, MSO.sadd, MSO.ssub, MSO.smul, MSO.sdiv = \ * m_neg_s, m_madd_s, m_msub_s, m_mmul_s, m_mdiv_s, m_sadd_s, m_ssub_s, m_smul_s, m_sdiv_s # <<<<<<<<<<<<<< - * MSO.matmul = m_matmul_s + * MSO.matmul, MSO.T = m_matmul_s, m_transpose_s * */ - __pyx_t_19 = __pyx_f_6squish_4core_m_neg_s; - __pyx_t_20 = __pyx_f_6squish_4core_m_madd_s; - __pyx_t_21 = __pyx_f_6squish_4core_m_msub_s; - __pyx_t_22 = __pyx_f_6squish_4core_m_mmul_s; - __pyx_t_23 = __pyx_f_6squish_4core_m_mdiv_s; - __pyx_t_24 = __pyx_f_6squish_4core_m_sadd_s; - __pyx_t_25 = __pyx_f_6squish_4core_m_ssub_s; - __pyx_t_26 = __pyx_f_6squish_4core_m_smul_s; - __pyx_t_27 = __pyx_f_6squish_4core_m_sdiv_s; + __pyx_t_23 = __pyx_f_6squish_4core_m_neg_s; + __pyx_t_24 = __pyx_f_6squish_4core_m_madd_s; + __pyx_t_25 = __pyx_f_6squish_4core_m_msub_s; + __pyx_t_26 = __pyx_f_6squish_4core_m_mmul_s; + __pyx_t_27 = __pyx_f_6squish_4core_m_mdiv_s; + __pyx_t_28 = __pyx_f_6squish_4core_m_sadd_s; + __pyx_t_29 = __pyx_f_6squish_4core_m_ssub_s; + __pyx_t_30 = __pyx_f_6squish_4core_m_smul_s; + __pyx_t_31 = __pyx_f_6squish_4core_m_sdiv_s; /* "squish/core.pyx":27 - * VCO.matmul = v_matmul_c + * VCO.matmul, VCO.rot = v_matmul_c, rot_c * * MSO.neg, MSO.madd, MSO.msub, MSO.mmul, MSO.mdiv, MSO.sadd, MSO.ssub, MSO.smul, MSO.sdiv = \ # <<<<<<<<<<<<<< * m_neg_s, m_madd_s, m_msub_s, m_mmul_s, m_mdiv_s, m_sadd_s, m_ssub_s, m_smul_s, m_sdiv_s - * MSO.matmul = m_matmul_s + * MSO.matmul, MSO.T = m_matmul_s, m_transpose_s */ - __pyx_v_6squish_4core_MSO.neg = __pyx_t_19; - __pyx_v_6squish_4core_MSO.madd = __pyx_t_20; - __pyx_v_6squish_4core_MSO.msub = __pyx_t_21; - __pyx_v_6squish_4core_MSO.mmul = __pyx_t_22; - __pyx_v_6squish_4core_MSO.mdiv = __pyx_t_23; - __pyx_v_6squish_4core_MSO.sadd = __pyx_t_24; - __pyx_v_6squish_4core_MSO.ssub = __pyx_t_25; - __pyx_v_6squish_4core_MSO.smul = __pyx_t_26; - __pyx_v_6squish_4core_MSO.sdiv = __pyx_t_27; + __pyx_v_6squish_4core_MSO.neg = __pyx_t_23; + __pyx_v_6squish_4core_MSO.madd = __pyx_t_24; + __pyx_v_6squish_4core_MSO.msub = __pyx_t_25; + __pyx_v_6squish_4core_MSO.mmul = __pyx_t_26; + __pyx_v_6squish_4core_MSO.mdiv = __pyx_t_27; + __pyx_v_6squish_4core_MSO.sadd = __pyx_t_28; + __pyx_v_6squish_4core_MSO.ssub = __pyx_t_29; + __pyx_v_6squish_4core_MSO.smul = __pyx_t_30; + __pyx_v_6squish_4core_MSO.sdiv = __pyx_t_31; /* "squish/core.pyx":29 * MSO.neg, MSO.madd, MSO.msub, MSO.mmul, MSO.mdiv, MSO.sadd, MSO.ssub, MSO.smul, MSO.sdiv = \ * m_neg_s, m_madd_s, m_msub_s, m_mmul_s, m_mdiv_s, m_sadd_s, m_ssub_s, m_smul_s, m_sdiv_s - * MSO.matmul = m_matmul_s # <<<<<<<<<<<<<< + * MSO.matmul, MSO.T = m_matmul_s, m_transpose_s # <<<<<<<<<<<<<< * * MCO.neg, MCO.madd, MCO.msub, MCO.mmul, MCO.mdiv, MCO.sadd, MCO.ssub, MCO.smul, MCO.sdiv = \ */ - __pyx_v_6squish_4core_MSO.matmul = __pyx_f_6squish_4core_m_matmul_s; + __pyx_t_32 = __pyx_f_6squish_4core_m_matmul_s; + __pyx_t_33 = __pyx_f_6squish_4core_m_transpose_s; + __pyx_v_6squish_4core_MSO.matmul = __pyx_t_32; + __pyx_v_6squish_4core_MSO.T = __pyx_t_33; /* "squish/core.pyx":32 * * MCO.neg, MCO.madd, MCO.msub, MCO.mmul, MCO.mdiv, MCO.sadd, MCO.ssub, MCO.smul, MCO.sdiv = \ * m_neg_c, m_madd_c, m_msub_c, m_mmul_c, m_mdiv_c, m_sadd_c, m_ssub_c, m_smul_c, m_sdiv_c # <<<<<<<<<<<<<< - * MCO.matmul = m_matmul_c + * MCO.matmul, MCO.T = m_matmul_c, m_transpose_c * */ - __pyx_t_28 = __pyx_f_6squish_4core_m_neg_c; - __pyx_t_29 = __pyx_f_6squish_4core_m_madd_c; - __pyx_t_30 = __pyx_f_6squish_4core_m_msub_c; - __pyx_t_31 = __pyx_f_6squish_4core_m_mmul_c; - __pyx_t_32 = __pyx_f_6squish_4core_m_mdiv_c; - __pyx_t_33 = __pyx_f_6squish_4core_m_sadd_c; - __pyx_t_34 = __pyx_f_6squish_4core_m_ssub_c; - __pyx_t_35 = __pyx_f_6squish_4core_m_smul_c; - __pyx_t_36 = __pyx_f_6squish_4core_m_sdiv_c; + __pyx_t_34 = __pyx_f_6squish_4core_m_neg_c; + __pyx_t_35 = __pyx_f_6squish_4core_m_madd_c; + __pyx_t_36 = __pyx_f_6squish_4core_m_msub_c; + __pyx_t_37 = __pyx_f_6squish_4core_m_mmul_c; + __pyx_t_38 = __pyx_f_6squish_4core_m_mdiv_c; + __pyx_t_39 = __pyx_f_6squish_4core_m_sadd_c; + __pyx_t_40 = __pyx_f_6squish_4core_m_ssub_c; + __pyx_t_41 = __pyx_f_6squish_4core_m_smul_c; + __pyx_t_42 = __pyx_f_6squish_4core_m_sdiv_c; /* "squish/core.pyx":31 - * MSO.matmul = m_matmul_s + * MSO.matmul, MSO.T = m_matmul_s, m_transpose_s * * MCO.neg, MCO.madd, MCO.msub, MCO.mmul, MCO.mdiv, MCO.sadd, MCO.ssub, MCO.smul, MCO.sdiv = \ # <<<<<<<<<<<<<< * m_neg_c, m_madd_c, m_msub_c, m_mmul_c, m_mdiv_c, m_sadd_c, m_ssub_c, m_smul_c, m_sdiv_c - * MCO.matmul = m_matmul_c + * MCO.matmul, MCO.T = m_matmul_c, m_transpose_c */ - __pyx_v_6squish_4core_MCO.neg = __pyx_t_28; - __pyx_v_6squish_4core_MCO.madd = __pyx_t_29; - __pyx_v_6squish_4core_MCO.msub = __pyx_t_30; - __pyx_v_6squish_4core_MCO.mmul = __pyx_t_31; - __pyx_v_6squish_4core_MCO.mdiv = __pyx_t_32; - __pyx_v_6squish_4core_MCO.sadd = __pyx_t_33; - __pyx_v_6squish_4core_MCO.ssub = __pyx_t_34; - __pyx_v_6squish_4core_MCO.smul = __pyx_t_35; - __pyx_v_6squish_4core_MCO.sdiv = __pyx_t_36; + __pyx_v_6squish_4core_MCO.neg = __pyx_t_34; + __pyx_v_6squish_4core_MCO.madd = __pyx_t_35; + __pyx_v_6squish_4core_MCO.msub = __pyx_t_36; + __pyx_v_6squish_4core_MCO.mmul = __pyx_t_37; + __pyx_v_6squish_4core_MCO.mdiv = __pyx_t_38; + __pyx_v_6squish_4core_MCO.sadd = __pyx_t_39; + __pyx_v_6squish_4core_MCO.ssub = __pyx_t_40; + __pyx_v_6squish_4core_MCO.smul = __pyx_t_41; + __pyx_v_6squish_4core_MCO.sdiv = __pyx_t_42; /* "squish/core.pyx":33 * MCO.neg, MCO.madd, MCO.msub, MCO.mmul, MCO.mdiv, MCO.sadd, MCO.ssub, MCO.smul, MCO.sdiv = \ * m_neg_c, m_madd_c, m_msub_c, m_mmul_c, m_mdiv_c, m_sadd_c, m_ssub_c, m_smul_c, m_sdiv_c - * MCO.matmul = m_matmul_c # <<<<<<<<<<<<<< + * MCO.matmul, MCO.T = m_matmul_c, m_transpose_c # <<<<<<<<<<<<<< * * """ */ - __pyx_v_6squish_4core_MCO.matmul = __pyx_f_6squish_4core_m_matmul_c; + __pyx_t_43 = __pyx_f_6squish_4core_m_matmul_c; + __pyx_t_44 = __pyx_f_6squish_4core_m_transpose_c; + __pyx_v_6squish_4core_MCO.matmul = __pyx_t_43; + __pyx_v_6squish_4core_MCO.T = __pyx_t_44; /* "squish/core.pyx":1 * from libc.stdlib cimport calloc, free # <<<<<<<<<<<<<< * from libc.math cimport sqrt * from squish.core cimport INT_T, FLOAT_T, Pair, \ */ - __pyx_t_37 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_37); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_37) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0; + __pyx_t_45 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_45)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_45); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_45) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_45); __pyx_t_45 = 0; - /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":1014 + /* ".venv/lib/python3.8/site-packages/numpy/__init__.pxd":1014 * * * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< @@ -6644,7 +6838,7 @@ if (!__Pyx_RefNanny) { goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_37); + __Pyx_XDECREF(__pyx_t_45); if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init squish.core", __pyx_clineno, __pyx_lineno, __pyx_filename); diff --git a/squish/core.pxd b/squish/core.pxd index 2385ba1..dba44dd 100644 --- a/squish/core.pxd +++ b/squish/core.pxd @@ -51,6 +51,7 @@ ctypedef Matrix2x2 (*MatrixCopySclOp)(Matrix2x2*, FLOAT_T) nogil ctypedef struct VectorSelfOps: Vector2D* (*neg)(Vector2D*) nogil + Vector2D* (*rot)(Vector2D*) nogil VectorSelfVecOp vadd VectorSelfVecOp vsub @@ -66,6 +67,7 @@ ctypedef struct VectorSelfOps: ctypedef struct VectorCopyOps: Vector2D (*neg)(Vector2D*) nogil + Vector2D (*rot)(Vector2D*) nogil VectorCopyVecOp vadd VectorCopyVecOp vsub @@ -81,6 +83,7 @@ ctypedef struct VectorCopyOps: ctypedef struct MatrixSelfOps: Matrix2x2* (*neg)(Matrix2x2*) nogil + Matrix2x2* (*T)(Matrix2x2*) nogil MatrixSelfMatOp madd MatrixSelfMatOp msub @@ -96,6 +99,7 @@ ctypedef struct MatrixSelfOps: ctypedef struct MatrixCopyOps: Matrix2x2 (*neg)(Matrix2x2*) nogil + Matrix2x2 (*T)(Matrix2x2*) nogil MatrixCopyMatOp madd MatrixCopyMatOp msub @@ -115,7 +119,7 @@ ctypedef struct Vector2D: VectorCopyOps copy bint (*equals)(Vector2D*, Vector2D) nogil - Vector2D (*rot)(Vector2D*) nogil + Matrix2x2 (*vecmul)(Vector2D*, Vector2D) nogil FLOAT_T (*dot)(Vector2D*, Vector2D) nogil FLOAT_T (*mag)(Vector2D*) nogil diff --git a/squish/core.pyx b/squish/core.pyx index c37ad91..a93ddde 100644 --- a/squish/core.pyx +++ b/squish/core.pyx @@ -18,19 +18,19 @@ cdef MatrixCopyOps MCO VSO.neg, VSO.vadd, VSO.vsub, VSO.vmul, VSO.vdiv, VSO.sadd, VSO.ssub, VSO.smul, VSO.sdiv = \ v_neg_s, v_vadd_s, v_vsub_s, v_vmul_s, v_vdiv_s, v_sadd_s, v_ssub_s, v_smul_s, v_sdiv_s -VSO.matmul = v_matmul_s +VSO.matmul, VSO.rot = v_matmul_s, rot_s VCO.neg, VCO.vadd, VCO.vsub, VCO.vmul, VCO.vdiv, VCO.sadd, VCO.ssub, VCO.smul, VCO.sdiv = \ v_neg_c, v_vadd_c, v_vsub_c, v_vmul_c, v_vdiv_c, v_sadd_c, v_ssub_c, v_smul_c, v_sdiv_c -VCO.matmul = v_matmul_c +VCO.matmul, VCO.rot = v_matmul_c, rot_c MSO.neg, MSO.madd, MSO.msub, MSO.mmul, MSO.mdiv, MSO.sadd, MSO.ssub, MSO.smul, MSO.sdiv = \ m_neg_s, m_madd_s, m_msub_s, m_mmul_s, m_mdiv_s, m_sadd_s, m_ssub_s, m_smul_s, m_sdiv_s -MSO.matmul = m_matmul_s +MSO.matmul, MSO.T = m_matmul_s, m_transpose_s MCO.neg, MCO.madd, MCO.msub, MCO.mmul, MCO.mdiv, MCO.sadd, MCO.ssub, MCO.smul, MCO.sdiv = \ m_neg_c, m_madd_c, m_msub_c, m_mmul_c, m_mdiv_c, m_sadd_c, m_ssub_c, m_smul_c, m_sdiv_c -MCO.matmul = m_matmul_c +MCO.matmul, MCO.T = m_matmul_c, m_transpose_c """ If bound checking is desired, uncomment out ..._valid_indices functions. @@ -143,7 +143,7 @@ cdef inline Vector2D _Vector2D(FLOAT_T x, FLOAT_T y) nogil: vec.x, vec.y = x, y vec.self, vec.copy = VSO, VCO - vec.equals, vec.rot, vec.dot, vec.mag = &v_equals, &rot, &dot, &mag + vec.equals, vec.vecmul, vec.dot, vec.mag = &v_equals, &v_vecmul, &dot, &mag return vec @@ -200,6 +200,10 @@ cdef inline Vector2D* v_matmul_s(Vector2D* self, Matrix2x2 m) nogil: self.x, self.y = self.x*m.a + self.y*m.c, self.x*m.b + self.y*m.d return self +cdef inline Vector2D* rot_s(Vector2D* self) nogil: + self.x, self.y = -self.y, self.x + return self + cdef inline Vector2D v_neg_c(Vector2D* self) nogil: return _Vector2D(-self.x, -self.y) @@ -232,7 +236,7 @@ cdef inline Vector2D v_matmul_c(Vector2D* self, Matrix2x2 m) nogil: self.x*m.a + self.y*m.c, self.x*m.b + self.y*m.d ) -cdef inline Vector2D rot(Vector2D* self) nogil: +cdef inline Vector2D rot_c(Vector2D* self) nogil: return _Vector2D(-self.y, self.x) cdef inline FLOAT_T dot(Vector2D* self, Vector2D w) nogil: @@ -241,6 +245,9 @@ cdef inline FLOAT_T dot(Vector2D* self, Vector2D w) nogil: cdef inline FLOAT_T mag(Vector2D* self) nogil: return sqrt((self.x*self.x + self.y*self.y)) +cdef inline Matrix2x2 v_vecmul(Vector2D* self, Vector2D v) nogil: + return _Matrix2x2(self.x*v.x, self.x*v.y, self.y*v.x, self.y*v.y) + #### Matrix2x2 Methods #### @@ -329,6 +336,10 @@ cdef inline Matrix2x2* m_matmul_s(Matrix2x2* self, Matrix2x2 m) nogil: self.c*m.a + self.d*m.c, self.c*m.b + self.d*m.d return self +cdef inline Matrix2x2* m_transpose_s(Matrix2x2* self) nogil: + self.b, self.c = self.c, self.b + return self + cdef inline Matrix2x2 m_neg_c(Matrix2x2* self) nogil: return _Matrix2x2(-self.a, -self.b, -self.c, -self.d) @@ -361,3 +372,6 @@ cdef inline Matrix2x2 m_matmul_c(Matrix2x2* self, Matrix2x2 m) nogil: self.a*m.a + self.b*m.c, self.a*m.b + self.b*m.d, self.c*m.a + self.d*m.c, self.c*m.b + self.d*m.d ) + +cdef inline Matrix2x2 m_transpose_c(Matrix2x2* self) nogil: + return _Matrix2x2(self.a, self.c, self.b, self.d) \ No newline at end of file diff --git a/squish/diagram.py b/squish/diagram.py index db3f937..932907d 100644 --- a/squish/diagram.py +++ b/squish/diagram.py @@ -1,7 +1,13 @@ from __future__ import annotations from typing import Tuple, List, Optional -import matplotlib.pyplot as plt, numpy as np, os +import matplotlib as mpl +import matplotlib.cm as cm +import matplotlib.pyplot as plt +import matplotlib.gridspec as gridspec +from mpl_toolkits.axes_grid1.axes_divider import make_axes_locatable + +import numpy as np, os, math from matplotlib.ticker import MaxNLocator, FormatStrFormatter from scipy.spatial import Voronoi, voronoi_plot_2d from multiprocessing import Pool, cpu_count @@ -123,18 +129,49 @@ class Diagram: raise ValueError("Not a valid mode for diagrams!") shape = self.diagrams.shape - fig, axes = plt.subplots(*shape, figsize=(shape[1] * 8, shape[0] * 8)) + + plt.rcParams.update( + { + "axes.titlesize": 45, + "axes.labelsize": 45, + "xtick.labelsize": 40, + "ytick.labelsize": 40, + "xtick.major.width": 2, + "ytick.major.width": 2, + "xtick.major.size": 5, + "ytick.major.size": 5, + "xtick.minor.width": 1, + "ytick.minor.width": 1, + "xtick.minor.size": 3, + "ytick.minor.size": 3, + "legend.fontsize": 40, + "lines.linewidth": 3, + "font.family": "cm", + "font.size": 40, + "text.usetex": True, + "text.latex.preamble": r"\usepackage{amsmath}", + "figure.constrained_layout.use": True, + } + ) + + fig = plt.figure(figsize=(shape[1] * 15, shape[0] * 15)) + gs = fig.add_gridspec(shape[0], shape[1]) + # fig, axes = plt.subplots(*shape, figsize=(shape[1] * 15, shape[0] * 15)) + if self.diagrams.shape == (1, 1): - getattr(self, str(self.diagrams[0][0]) + "_plot")(frame, axes) + ax = fig.add_subplot(gs[0]) + getattr(self, str(self.diagrams[0][0]) + "_plot")(frame, ax) else: - axes = np.atleast_2d(axes) + # axes = np.atleast_2d(axes) it = np.nditer(self.diagrams, flags=["multi_index"]) for diagram in it: if diagram == "": continue - getattr(self, str(diagram) + "_plot")(frame, axes[it.multi_index]) - plt.tight_layout() + ax = fig.add_subplot(gs[it.multi_index]) + getattr(self, str(diagram) + "_plot")(frame, ax) + + # plt.tight_layout() if name is None: name = f"img{frame:05}.png" @@ -148,28 +185,60 @@ class Diagram: domain = self.sim.domains[i] n, w, h = domain.n, domain.w, domain.h scale = 1.5 - area = n <= 60 + area = n <= 50 + + offset = ( + 2 + - 2 * domain.r * (6 * 3 ** (-0.25) * math.sqrt(2) * math.atanh(0.5)) + + 2 * math.pi * domain.r ** 2 + ) + + # Make color map axis. + divider = make_axes_locatable(ax) + cax = divider.append_axes("right", size="5%", pad=0.05) voronoi_plot_2d( - self.sim.voronois[i], ax, show_vertices=False, point_size=7 - n / 100 + self.sim.voronois[i], ax, show_vertices=False, show_points=False ) - ax.plot([-w, 2 * w], [0, 0], "r") - ax.plot([-w, 2 * w], [h, h], "r") - ax.plot([0, 0], [-h, 2 * h], "r") - ax.plot([w, w], [-h, 2 * h], "r") + + # Mark location axis with 3 ticks. + ax.set_xticks([0, w / 2, w]) + ax.set_yticks([0, h / 2, h]) + + # Obtain site energies, and make color map. + energies = self.sim.stats[i]["site_energies"][:n] + norm = mpl.colors.Normalize(vmin=-2, vmax=2, clip=True) + mapper = cm.ScalarMappable(norm=norm, cmap=cm.magma) + cbar = plt.colorbar(mapper, cax=cax, ticks=np.linspace(-2, 2, 5)) + + # Fill polygons with energy colormap. + for j, p in enumerate(self.sim.voronois[i].point_region): + region = self.sim.voronois[i].regions[p] + if not -1 in region: + polygon = [self.sim.voronois[i].vertices[k] for k in region] + ax.fill( + *zip(*polygon), + color=mapper.to_rgba(energies[j % n] - offset), + zorder=0, + ) + + line_color, point_color = "white", "lightseagreen" + + # Periodic border + ax.plot([-w, 2 * w], [0, 0], line_color, linewidth="4") + ax.plot([-w, 2 * w], [h, h], line_color, linewidth="4") + ax.plot([0, 0], [-h, 2 * h], line_color, linewidth="4") + ax.plot([w, w], [-h, 2 * h], line_color, linewidth="4") ax.axis("equal") - ax.set_xlim([(1 - scale) * w / 2, (1 + scale) * w / 2]) + ax.set_xlim([(1 - 0.85 * scale) * w / 2, (1 + 0.85 * scale) * w / 2]) ax.set_ylim([(1 - scale) * h / 2, (1 + scale) * h / 2]) - ax.title.set_text("Voronoi Visualization") - - props = dict(boxstyle="round", facecolor="wheat", alpha=0.8) + ax.set_title("Voronoi Tessellation") + # Marking sites and defects. defects = {5: {"x": [], "y": []}, 7: {"x": [], "y": []}} - for j in range(n): for s in SYMM: vec = self.sim.voronois[i].points[j] + s * self.sim.domains[i].dim - if area: txt = ax.text( *vec, str(round(self.sim.stats[i]["site_areas"][j], 3)) @@ -182,16 +251,35 @@ class Diagram: elif self.sim.stats[i]["site_edge_count"][j] == 7: defects[7]["x"].append(vec[0]) defects[7]["y"].append(vec[1]) + else: + ax.scatter( + vec[0], vec[1], s=(40 - n / 100), color=point_color, zorder=1 + ) - ax.scatter(defects[5]["x"], defects[5]["y"], marker="p", color="C0") - ax.scatter(defects[7]["x"], defects[7]["y"], marker="*", color="C0") + ax.scatter( + defects[5]["x"], + defects[5]["y"], + marker="p", + s=(200 - n / 100), + color=point_color, + zorder=1, + ) + ax.scatter( + defects[7]["x"], + defects[7]["y"], + marker="*", + s=(200 - n / 100), + color=point_color, + zorder=1, + ) + # Make VEE text in top left. + props = dict(boxstyle="round", facecolor="white", alpha=0.8, zorder=20) ax.text( - 0.05, - 0.95, - f"Energy: {self.sim.energies[i]}", + 0.065, + 0.935, + f"VEE: {round(sum(energies)/n - offset, 8)}", transform=ax.transAxes, - fontsize=14, verticalalignment="top", bbox=props, ) @@ -305,14 +393,32 @@ class Diagram: def eigs_plot(self, i: int, ax: AxesSubplot) -> None: try: eigs = self.sim.stats[i]["eigs"] + for i, eig in enumerate(eigs): + if eig > 1e-4: + ax.annotate( + f"Coercivity: {eig:.5f}", + xy=(i, eig), + xytext=(50, -50), + textcoords="offset points", + arrowprops={"arrowstyle": "->", "color": "black"}, + ) + break + ax.plot( - list(range(len(eigs))), eigs, marker="o", linestyle="dashed", color="C0" + list(range(40)), + eigs[:40], + marker="o", + linestyle="dashed", + color="C0", + markersize=8, ) - ax.plot([0, len(eigs)], [0, 0], color="red") + + ax.plot([0, 40], [0, 0], color="red") except KeyError: ax.text(0.5, 0.5, "Not Computed") - ax.title.set_text("Hessian Eigenvalues") + ax.grid() + ax.set_title("Sorted Hessian Eigenvalues") ax.set_xlabel("") ax.set_ylabel("Value") diff --git a/squish/energy.c b/squish/energy.c index 3dac634..6a4c866 100644 --- a/squish/energy.c +++ b/squish/energy.c @@ -1425,10 +1425,11 @@ typedef __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_6squish_4core_MatrixCopySclOp) * * ctypedef struct VectorSelfOps: # <<<<<<<<<<<<<< * Vector2D* (*neg)(Vector2D*) nogil - * + * Vector2D* (*rot)(Vector2D*) nogil */ struct __pyx_t_6squish_4core_VectorSelfOps { __pyx_t_6squish_4core_Vector2D *(*neg)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Vector2D *(*rot)(__pyx_t_6squish_4core_Vector2D *); __pyx_t_6squish_4core_VectorSelfVecOp vadd; __pyx_t_6squish_4core_VectorSelfVecOp vsub; __pyx_t_6squish_4core_VectorSelfVecOp vmul; @@ -1440,15 +1441,16 @@ struct __pyx_t_6squish_4core_VectorSelfOps { __pyx_t_6squish_4core_VectorSelfSclOp sdiv; }; -/* "squish/core.pxd":67 +/* "squish/core.pxd":68 * * * ctypedef struct VectorCopyOps: # <<<<<<<<<<<<<< * Vector2D (*neg)(Vector2D*) nogil - * + * Vector2D (*rot)(Vector2D*) nogil */ struct __pyx_t_6squish_4core_VectorCopyOps { __pyx_t_6squish_4core_Vector2D (*neg)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Vector2D (*rot)(__pyx_t_6squish_4core_Vector2D *); __pyx_t_6squish_4core_VectorCopyVecOp vadd; __pyx_t_6squish_4core_VectorCopyVecOp vsub; __pyx_t_6squish_4core_VectorCopyVecOp vmul; @@ -1460,15 +1462,16 @@ struct __pyx_t_6squish_4core_VectorCopyOps { __pyx_t_6squish_4core_VectorCopySclOp sdiv; }; -/* "squish/core.pxd":82 +/* "squish/core.pxd":84 * * * ctypedef struct MatrixSelfOps: # <<<<<<<<<<<<<< * Matrix2x2* (*neg)(Matrix2x2*) nogil - * + * Matrix2x2* (*T)(Matrix2x2*) nogil */ struct __pyx_t_6squish_4core_MatrixSelfOps { __pyx_t_6squish_4core_Matrix2x2 *(*neg)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 *(*T)(__pyx_t_6squish_4core_Matrix2x2 *); __pyx_t_6squish_4core_MatrixSelfMatOp madd; __pyx_t_6squish_4core_MatrixSelfMatOp msub; __pyx_t_6squish_4core_MatrixSelfMatOp mmul; @@ -1480,15 +1483,16 @@ struct __pyx_t_6squish_4core_MatrixSelfOps { __pyx_t_6squish_4core_MatrixSelfSclOp sdiv; }; -/* "squish/core.pxd":97 +/* "squish/core.pxd":100 * * * ctypedef struct MatrixCopyOps: # <<<<<<<<<<<<<< * Matrix2x2 (*neg)(Matrix2x2*) nogil - * + * Matrix2x2 (*T)(Matrix2x2*) nogil */ struct __pyx_t_6squish_4core_MatrixCopyOps { __pyx_t_6squish_4core_Matrix2x2 (*neg)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 (*T)(__pyx_t_6squish_4core_Matrix2x2 *); __pyx_t_6squish_4core_MatrixCopyMatOp madd; __pyx_t_6squish_4core_MatrixCopyMatOp msub; __pyx_t_6squish_4core_MatrixCopyMatOp mmul; @@ -1500,7 +1504,7 @@ struct __pyx_t_6squish_4core_MatrixCopyOps { __pyx_t_6squish_4core_MatrixCopySclOp sdiv; }; -/* "squish/core.pxd":112 +/* "squish/core.pxd":116 * * # Psuedo-class for a 2-dimensional vector. No orientation. * ctypedef struct Vector2D: # <<<<<<<<<<<<<< @@ -1513,12 +1517,12 @@ struct __pyx_t_6squish_4core_Vector2D { __pyx_t_6squish_4core_VectorSelfOps self; __pyx_t_6squish_4core_VectorCopyOps copy; int (*equals)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); - __pyx_t_6squish_4core_Vector2D (*rot)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Matrix2x2 (*vecmul)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*dot)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*mag)(__pyx_t_6squish_4core_Vector2D *); }; -/* "squish/core.pxd":123 +/* "squish/core.pxd":127 * * # Psuedo-class for a 2x2 matrix. * ctypedef struct Matrix2x2: # <<<<<<<<<<<<<< @@ -1675,6 +1679,7 @@ struct __pyx_obj_6squish_7voronoi_VoronoiContainer { __Pyx_memviewslice site_cache; __Pyx_memviewslice edge_cache; __Pyx_memviewslice grad; + __Pyx_memviewslice hess; __Pyx_memviewslice sites; __Pyx_memviewslice edges; __pyx_t_6squish_7voronoi_EdgeCacheMap *edge_cache_map; @@ -1686,32 +1691,32 @@ struct __pyx_obj_6squish_7voronoi_VoronoiContainer { * cdef EdgeCacheMap RADIALT_ECM = _EdgeCacheMap(0, 4, 6, 8, -1, 10, 11, 12, 13, 14) * * cdef class AreaEnergy(VoronoiContainer): # <<<<<<<<<<<<<< - * """ - * Class for formulas relevant to the Area energy. + * """ + * Class for formulas relevant to the Area energy. */ struct __pyx_obj_6squish_6energy_AreaEnergy { struct __pyx_obj_6squish_7voronoi_VoronoiContainer __pyx_base; }; -/* "squish/energy.pyx":116 +/* "squish/energy.pyx":139 * * * cdef class RadialALEnergy(VoronoiContainer): # <<<<<<<<<<<<<< - * """ - * Class for formulas relevant to the Area energy. + * """ + * Class for formulas relevant to the Area energy. */ struct __pyx_obj_6squish_6energy_RadialALEnergy { struct __pyx_obj_6squish_7voronoi_VoronoiContainer __pyx_base; }; -/* "squish/energy.pyx":152 +/* "squish/energy.pyx":178 * * * cdef class RadialTEnergy(VoronoiContainer): # <<<<<<<<<<<<<< - * """ - * Class for formulas relevant to the Area energy. + * """ + * Class for formulas relevant to the Area energy. */ struct __pyx_obj_6squish_6energy_RadialTEnergy { struct __pyx_obj_6squish_7voronoi_VoronoiContainer __pyx_base; @@ -1810,6 +1815,7 @@ struct __pyx_vtabstruct_6squish_7voronoi_VoronoiContainer { void (*common_cache)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); void (*precompute)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); void (*calc_grad)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); + void (*calc_hess)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); void (*get_statistics)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); __pyx_t_6squish_4core_Matrix2x2 (*calc_H)(__pyx_t_6squish_7voronoi_HalfEdge, __pyx_t_6squish_7voronoi_HalfEdge); int (*sign)(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice); @@ -1821,8 +1827,8 @@ static struct __pyx_vtabstruct_6squish_7voronoi_VoronoiContainer *__pyx_vtabptr_ * cdef EdgeCacheMap RADIALT_ECM = _EdgeCacheMap(0, 4, 6, 8, -1, 10, 11, 12, 13, 14) * * cdef class AreaEnergy(VoronoiContainer): # <<<<<<<<<<<<<< - * """ - * Class for formulas relevant to the Area energy. + * """ + * Class for formulas relevant to the Area energy. */ struct __pyx_vtabstruct_6squish_6energy_AreaEnergy { @@ -1831,12 +1837,12 @@ struct __pyx_vtabstruct_6squish_6energy_AreaEnergy { static struct __pyx_vtabstruct_6squish_6energy_AreaEnergy *__pyx_vtabptr_6squish_6energy_AreaEnergy; -/* "squish/energy.pyx":116 +/* "squish/energy.pyx":139 * * * cdef class RadialALEnergy(VoronoiContainer): # <<<<<<<<<<<<<< - * """ - * Class for formulas relevant to the Area energy. + * """ + * Class for formulas relevant to the Area energy. */ struct __pyx_vtabstruct_6squish_6energy_RadialALEnergy { @@ -1845,12 +1851,12 @@ struct __pyx_vtabstruct_6squish_6energy_RadialALEnergy { static struct __pyx_vtabstruct_6squish_6energy_RadialALEnergy *__pyx_vtabptr_6squish_6energy_RadialALEnergy; -/* "squish/energy.pyx":152 +/* "squish/energy.pyx":178 * * * cdef class RadialTEnergy(VoronoiContainer): # <<<<<<<<<<<<<< - * """ - * Class for formulas relevant to the Area energy. + * """ + * Class for formulas relevant to the Area energy. */ struct __pyx_vtabstruct_6squish_6energy_RadialTEnergy { @@ -2185,6 +2191,53 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); +/* PyIntCompare.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* ObjectGetItem.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); +#else +#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) +#endif + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); +#else +#define __Pyx_PyInt_TrueDivideObjC(op1, op2, intval, inplace, zerodivision_check)\ + (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2)) +#endif + /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); @@ -2245,35 +2298,6 @@ static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/ /* GetAttr.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* ObjectGetItem.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); -#else -#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) -#endif - /* decode_c_string_utf16.proto */ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { int byteorder = 0; @@ -2533,6 +2557,9 @@ static CYTHON_INLINE int __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T(cons /* ObjectToMemviewSlice.proto */ static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_6squish_4core_FLOAT_T(PyObject *, int writable_flag); +/* ObjectToMemviewSlice.proto */ +static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_6squish_4core_FLOAT_T(PyObject *, int writable_flag); + /* RealImag.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus @@ -2644,6 +2671,9 @@ static CYTHON_INLINE npy_int64 __Pyx_PyInt_As_npy_int64(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_int64(npy_int64 value); +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); @@ -2653,9 +2683,6 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - /* CIntFromPy.proto */ static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *); @@ -2673,10 +2700,13 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6squish_6energy_AreaEnergy *__pyx_v_self); /* proto*/ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squish_6energy_AreaEnergy *__pyx_v_self); /* proto*/ +static void __pyx_f_6squish_6energy_10AreaEnergy_calc_hess(struct __pyx_obj_6squish_6energy_AreaEnergy *__pyx_v_self); /* proto*/ static void __pyx_f_6squish_6energy_14RadialALEnergy_precompute(struct __pyx_obj_6squish_6energy_RadialALEnergy *__pyx_v_self); /* proto*/ static void __pyx_f_6squish_6energy_14RadialALEnergy_calc_grad(struct __pyx_obj_6squish_6energy_RadialALEnergy *__pyx_v_self); /* proto*/ +static void __pyx_f_6squish_6energy_14RadialALEnergy_calc_hess(CYTHON_UNUSED struct __pyx_obj_6squish_6energy_RadialALEnergy *__pyx_v_self); /* proto*/ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_6squish_6energy_RadialTEnergy *__pyx_v_self); /* proto*/ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6squish_6energy_RadialTEnergy *__pyx_v_self); /* proto*/ +static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_hess(struct __pyx_obj_6squish_6energy_RadialTEnergy *__pyx_v_self); /* proto*/ static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/ static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/ static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/ @@ -2803,16 +2833,17 @@ int __pyx_module_is_main_squish__energy = 0; /* Implementation of 'squish.energy' */ static PyObject *__pyx_builtin_super; +static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_TypeError; static PyObject *__pyx_builtin_ImportError; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_MemoryError; static PyObject *__pyx_builtin_enumerate; -static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_Ellipsis; static PyObject *__pyx_builtin_id; static PyObject *__pyx_builtin_IndexError; static const char __pyx_k_O[] = "O"; +static const char __pyx_k_T[] = "T"; static const char __pyx_k_c[] = "c"; static const char __pyx_k_h[] = "h"; static const char __pyx_k_n[] = "n"; @@ -2827,6 +2858,7 @@ static const char __pyx_k_sum[] = "sum"; static const char __pyx_k_Area[] = "Area"; static const char __pyx_k_area[] = "area"; static const char __pyx_k_base[] = "base"; +static const char __pyx_k_copy[] = "copy"; static const char __pyx_k_dict[] = "__dict__"; static const char __pyx_k_full[] = "full"; static const char __pyx_k_init[] = "__init__"; @@ -2861,6 +2893,8 @@ static const char __pyx_k_reduce[] = "__reduce__"; static const char __pyx_k_struct[] = "struct"; static const char __pyx_k_unpack[] = "unpack"; static const char __pyx_k_update[] = "update"; +static const char __pyx_k_asarray[] = "asarray"; +static const char __pyx_k_flatten[] = "flatten"; static const char __pyx_k_float64[] = "float64"; static const char __pyx_k_fortran[] = "fortran"; static const char __pyx_k_memview[] = "memview"; @@ -2869,6 +2903,7 @@ static const char __pyx_k_Ellipsis[] = "Ellipsis"; static const char __pyx_k_Radial_T[] = "Radial[T]"; static const char __pyx_k_attr_str[] = "attr_str"; static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_gradient[] = "gradient"; static const char __pyx_k_itemsize[] = "itemsize"; static const char __pyx_k_pyx_type[] = "__pyx_type"; static const char __pyx_k_radial_t[] = "radial-t"; @@ -2957,12 +2992,14 @@ static PyObject *__pyx_n_s_RadialALEnergy; static PyObject *__pyx_n_s_RadialTEnergy; static PyObject *__pyx_kp_u_Radial_AL; static PyObject *__pyx_kp_u_Radial_T; +static PyObject *__pyx_n_s_T; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_View_MemoryView; static PyObject *__pyx_n_s_allocate_buffer; static PyObject *__pyx_n_u_area; +static PyObject *__pyx_n_s_asarray; static PyObject *__pyx_n_s_attr_str; static PyObject *__pyx_n_s_base; static PyObject *__pyx_n_s_c; @@ -2971,6 +3008,7 @@ static PyObject *__pyx_n_s_class; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_kp_s_contiguous_and_direct; static PyObject *__pyx_kp_s_contiguous_and_indirect; +static PyObject *__pyx_n_s_copy; static PyObject *__pyx_n_s_dict; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dtype_is_object; @@ -2978,6 +3016,7 @@ static PyObject *__pyx_n_s_encode; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_error; static PyObject *__pyx_n_s_flags; +static PyObject *__pyx_n_s_flatten; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_format; static PyObject *__pyx_n_s_fortran; @@ -2985,6 +3024,7 @@ static PyObject *__pyx_n_u_fortran; static PyObject *__pyx_n_s_full; static PyObject *__pyx_n_s_getstate; static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi; +static PyObject *__pyx_n_s_gradient; static PyObject *__pyx_n_s_h; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_import; @@ -3111,7 +3151,7 @@ static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; static PyObject *__pyx_int_184977713; static PyObject *__pyx_int_neg_1; -static PyObject *__pyx_tuple_; +static PyObject *__pyx_slice_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; static PyObject *__pyx_tuple__4; @@ -3120,7 +3160,6 @@ static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; -static PyObject *__pyx_slice__23; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; @@ -3134,6 +3173,7 @@ static PyObject *__pyx_tuple__19; static PyObject *__pyx_tuple__20; static PyObject *__pyx_tuple__21; static PyObject *__pyx_tuple__22; +static PyObject *__pyx_tuple__23; static PyObject *__pyx_tuple__24; static PyObject *__pyx_tuple__25; static PyObject *__pyx_tuple__26; @@ -3147,11 +3187,11 @@ static PyObject *__pyx_codeobj__33; /* Late includes */ /* "squish/energy.pyx":33 - * title_str = "Area" + * title_str = "Area" * - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &AREA_ECM + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &AREA_ECM */ /* Python wrapper */ @@ -3285,28 +3325,28 @@ static int __pyx_pf_6squish_6energy_10AreaEnergy___init__(struct __pyx_obj_6squi __pyx_pybuffernd_site_arr.diminfo[0].strides = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_site_arr.diminfo[0].shape = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_site_arr.diminfo[1].strides = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_site_arr.diminfo[1].shape = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.shape[1]; /* "squish/energy.pyx":35 - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &AREA_ECM # <<<<<<<<<<<<<< - * self.energy = 0.0 + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &AREA_ECM # <<<<<<<<<<<<<< + * self.energy = 0.0 * */ __pyx_v_self->__pyx_base.edge_cache_map = (&__pyx_v_6squish_6energy_AREA_ECM); /* "squish/energy.pyx":36 - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &AREA_ECM - * self.energy = 0.0 # <<<<<<<<<<<<<< + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &AREA_ECM + * self.energy = 0.0 # <<<<<<<<<<<<<< * - * super().__init__(n, w, h, r, site_arr) + * super().__init__(n, w, h, r, site_arr) */ __pyx_v_self->__pyx_base.energy = 0.0; /* "squish/energy.pyx":38 - * self.energy = 0.0 + * self.energy = 0.0 * - * super().__init__(n, w, h, r, site_arr) # <<<<<<<<<<<<<< - * self.minimum = (n)*(w*h/(n)-PI*r**2)**2 + * super().__init__(n, w, h, r, site_arr) # <<<<<<<<<<<<<< + * self.minimum = (n)*(w*h/(n)-PI*r**2)**2 * */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error) @@ -3397,8 +3437,8 @@ static int __pyx_pf_6squish_6energy_10AreaEnergy___init__(struct __pyx_obj_6squi /* "squish/energy.pyx":39 * - * super().__init__(n, w, h, r, site_arr) - * self.minimum = (n)*(w*h/(n)-PI*r**2)**2 # <<<<<<<<<<<<<< + * super().__init__(n, w, h, r, site_arr) + * self.minimum = (n)*(w*h/(n)-PI*r**2)**2 # <<<<<<<<<<<<<< * * */ @@ -3408,11 +3448,11 @@ static int __pyx_pf_6squish_6energy_10AreaEnergy___init__(struct __pyx_obj_6squi __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "squish/energy.pyx":33 - * title_str = "Area" + * title_str = "Area" * - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &AREA_ECM + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &AREA_ECM */ /* function exit code */ @@ -3446,9 +3486,9 @@ static int __pyx_pf_6squish_6energy_10AreaEnergy___init__(struct __pyx_obj_6squi /* "squish/energy.pyx":42 * * - * cdef void precompute(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6squish_6energy_AreaEnergy *__pyx_v_self) { @@ -3486,9 +3526,9 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq /* "squish/energy.pyx":43 * - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 43, __pyx_L1_error)} @@ -3496,11 +3536,11 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 43, __pyx_L1_error)} /* "squish/energy.pyx":44 - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< * - * cdef Site xi + * cdef Site xi */ if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 44, __pyx_L1_error)} if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 44, __pyx_L1_error)} @@ -3508,19 +3548,19 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq /* "squish/energy.pyx":43 * - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->__pyx_base.sites, __pyx_v_self->__pyx_base.edges, __pyx_v_self->__pyx_base.points, __pyx_v_self->__pyx_base.vertices, __pyx_v_self->__pyx_base.site_cache, __pyx_v_self->__pyx_base.edge_cache, __pyx_v_self->__pyx_base.edge_cache_map); /* "squish/energy.pyx":50 - * cdef Vector2D vdiff + * cdef Vector2D vdiff * - * cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], PI*self.r**2) # <<<<<<<<<<<<<< + * cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], PI*self.r**2) # <<<<<<<<<<<<<< * - * cdef INT_T i, j + * cdef INT_T i, j */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); @@ -3589,10 +3629,10 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq /* "squish/energy.pyx":53 * - * cdef INT_T i, j - * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ { #ifdef WITH_THREAD @@ -3628,28 +3668,28 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq __pyx_v_j = ((__pyx_t_6squish_4core_INT_T)0xbad0bad0); /* "squish/energy.pyx":54 - * cdef INT_T i, j - * for i in prange(self.sites.shape[0], nogil=True): - * xi = _Site(i, &info) # <<<<<<<<<<<<<< - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.sites.shape[0], nogil=True): + * xi = _Site(i, &info) # <<<<<<<<<<<<<< + * e = xi.edge(&xi) * */ __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); /* "squish/energy.pyx":55 - * for i in prange(self.sites.shape[0], nogil=True): - * xi = _Site(i, &info) - * e = xi.edge(&xi) # <<<<<<<<<<<<<< + * for i in prange(self.sites.shape[0], nogil=True): + * xi = _Site(i, &info) + * e = xi.edge(&xi) # <<<<<<<<<<<<<< * - * site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 + * site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 */ __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); /* "squish/energy.pyx":57 - * e = xi.edge(&xi) + * e = xi.edge(&xi) * - * site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 # <<<<<<<<<<<<<< - * xi.cache.energy(&xi, site_energy[i]) + * site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 # <<<<<<<<<<<<<< + * xi.cache.energy(&xi, site_energy[i]) * */ __pyx_t_12 = __pyx_v_i; @@ -3658,40 +3698,40 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq /* "squish/energy.pyx":58 * - * site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 - * xi.cache.energy(&xi, site_energy[i]) # <<<<<<<<<<<<<< + * site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 + * xi.cache.energy(&xi, site_energy[i]) # <<<<<<<<<<<<<< * - * j = 0 + * j = 0 */ __pyx_t_12 = __pyx_v_i; (void)(__pyx_v_xi.cache->energy((&__pyx_v_xi), (*((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_site_energy.data + __pyx_t_12 * __pyx_v_site_energy.strides[0]) ))))); /* "squish/energy.pyx":60 - * xi.cache.energy(&xi, site_energy[i]) + * xi.cache.energy(&xi, site_energy[i]) * - * j = 0 # <<<<<<<<<<<<<< - * while j < xi.edge_num(&xi): - * em, ep = e.prev(&e), e.next(&e) + * j = 0 # <<<<<<<<<<<<<< + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) */ __pyx_v_j = 0; /* "squish/energy.pyx":61 * - * j = 0 - * while j < xi.edge_num(&xi): # <<<<<<<<<<<<<< - * em, ep = e.prev(&e), e.next(&e) - * vdiff = em.origin(&em) + * j = 0 + * while j < xi.edge_num(&xi): # <<<<<<<<<<<<<< + * em, ep = e.prev(&e), e.next(&e) + * vdiff = em.origin(&em) */ while (1) { __pyx_t_14 = ((__pyx_v_j < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); if (!__pyx_t_14) break; /* "squish/energy.pyx":62 - * j = 0 - * while j < xi.edge_num(&xi): - * em, ep = e.prev(&e), e.next(&e) # <<<<<<<<<<<<<< - * vdiff = em.origin(&em) - * vdiff.self.vsub(&vdiff, ep.origin(&ep)) + * j = 0 + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) # <<<<<<<<<<<<<< + * vdiff = em.origin(&em) + * vdiff.self.vsub(&vdiff, ep.origin(&ep)) */ __pyx_t_15 = __pyx_v_e.prev((&__pyx_v_e)); __pyx_t_16 = __pyx_v_e.next((&__pyx_v_e)); @@ -3699,56 +3739,56 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq __pyx_v_ep = __pyx_t_16; /* "squish/energy.pyx":63 - * while j < xi.edge_num(&xi): - * em, ep = e.prev(&e), e.next(&e) - * vdiff = em.origin(&em) # <<<<<<<<<<<<<< - * vdiff.self.vsub(&vdiff, ep.origin(&ep)) - * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) + * vdiff = em.origin(&em) # <<<<<<<<<<<<<< + * vdiff.self.vsub(&vdiff, ep.origin(&ep)) + * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) */ __pyx_v_vdiff = __pyx_v_em.origin((&__pyx_v_em)); /* "squish/energy.pyx":64 - * em, ep = e.prev(&e), e.next(&e) - * vdiff = em.origin(&em) - * vdiff.self.vsub(&vdiff, ep.origin(&ep)) # <<<<<<<<<<<<<< - * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) - * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + * em, ep = e.prev(&e), e.next(&e) + * vdiff = em.origin(&em) + * vdiff.self.vsub(&vdiff, ep.origin(&ep)) # <<<<<<<<<<<<<< + * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) */ (void)(__pyx_v_vdiff.self.vsub((&__pyx_v_vdiff), __pyx_v_ep.origin((&__pyx_v_ep)))); /* "squish/energy.pyx":65 - * vdiff = em.origin(&em) - * vdiff.self.vsub(&vdiff, ep.origin(&ep)) - * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) # <<<<<<<<<<<<<< - * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + * vdiff = em.origin(&em) + * vdiff.self.vsub(&vdiff, ep.origin(&ep)) + * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) # <<<<<<<<<<<<<< + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) * */ (void)(__pyx_v_e.cache->dVdv((&__pyx_v_e), __pyx_v_6squish_7voronoi_R.vecmul((&__pyx_v_6squish_7voronoi_R), __pyx_v_vdiff))); /* "squish/energy.pyx":66 - * vdiff.self.vsub(&vdiff, ep.origin(&ep)) - * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) - * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) # <<<<<<<<<<<<<< + * vdiff.self.vsub(&vdiff, ep.origin(&ep)) + * e.cache.dVdv(&e, R.vecmul(&R, vdiff)) + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) # <<<<<<<<<<<<<< * - * e = e.next(&e) + * e = e.next(&e) */ (void)(__pyx_v_e.cache->H((&__pyx_v_e), __pyx_vtabptr_6squish_7voronoi_VoronoiContainer->calc_H(__pyx_v_em, __pyx_v_e))); /* "squish/energy.pyx":68 - * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) * - * e = e.next(&e) # <<<<<<<<<<<<<< - * j = j + 1 + * e = e.next(&e) # <<<<<<<<<<<<<< + * j = j + 1 * */ __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); /* "squish/energy.pyx":69 * - * e = e.next(&e) - * j = j + 1 # <<<<<<<<<<<<<< + * e = e.next(&e) + * j = j + 1 # <<<<<<<<<<<<<< * - * self.energy = np.sum(site_energy[:self.n]) + * self.energy = np.sum(site_energy[:self.n]) */ __pyx_v_j = (__pyx_v_j + 1); } @@ -3767,10 +3807,10 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq /* "squish/energy.pyx":53 * - * cdef INT_T i, j - * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ /*finally:*/ { /*normal exit:*/{ @@ -3792,9 +3832,9 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_precompute(struct __pyx_obj_6sq } /* "squish/energy.pyx":71 - * j = j + 1 + * j = j + 1 * - * self.energy = np.sum(site_energy[:self.n]) # <<<<<<<<<<<<<< + * self.energy = np.sum(site_energy[:self.n]) # <<<<<<<<<<<<<< * * */ @@ -3852,9 +3892,9 @@ __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p /* "squish/energy.pyx":42 * * - * cdef void precompute(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ /* function exit code */ @@ -3876,9 +3916,9 @@ __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p /* "squish/energy.pyx":74 * * - * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squish_6energy_AreaEnergy *__pyx_v_self) { @@ -3913,9 +3953,9 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ /* "squish/energy.pyx":75 * - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 75, __pyx_L1_error)} @@ -3923,11 +3963,11 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 75, __pyx_L1_error)} /* "squish/energy.pyx":76 - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< * - * cdef Site xi, xf + * cdef Site xi, xf */ if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 76, __pyx_L1_error)} if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 76, __pyx_L1_error)} @@ -3935,18 +3975,18 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ /* "squish/energy.pyx":75 * - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->__pyx_base.sites, __pyx_v_self->__pyx_base.edges, __pyx_v_self->__pyx_base.points, __pyx_v_self->__pyx_base.vertices, __pyx_v_self->__pyx_base.site_cache, __pyx_v_self->__pyx_base.edge_cache, __pyx_v_self->__pyx_base.edge_cache_map); /* "squish/energy.pyx":83 - * cdef BitSet edge_set + * cdef BitSet edge_set * - * cdef INT_T num_edges = self.edges.shape[0] # <<<<<<<<<<<<<< - * cdef FLOAT_T A = PI*self.r**2 + * cdef INT_T num_edges = self.edges.shape[0] # <<<<<<<<<<<<<< + * cdef FLOAT_T A = PI*self.r**2 * */ if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 83, __pyx_L1_error)} @@ -3954,19 +3994,19 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ /* "squish/energy.pyx":84 * - * cdef INT_T num_edges = self.edges.shape[0] - * cdef FLOAT_T A = PI*self.r**2 # <<<<<<<<<<<<<< + * cdef INT_T num_edges = self.edges.shape[0] + * cdef FLOAT_T A = PI*self.r**2 # <<<<<<<<<<<<<< * - * cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) + * cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) */ __pyx_v_A = (M_PI * pow(__pyx_v_self->__pyx_base.r, 2.0)); /* "squish/energy.pyx":86 - * cdef FLOAT_T A = PI*self.r**2 + * cdef FLOAT_T A = PI*self.r**2 * - * cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) # <<<<<<<<<<<<<< + * cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) # <<<<<<<<<<<<<< * - * cdef INT_T i, j + * cdef INT_T i, j */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -4007,10 +4047,10 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ /* "squish/energy.pyx":89 * - * cdef INT_T i, j - * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ { #ifdef WITH_THREAD @@ -4045,121 +4085,121 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ __pyx_v_j = ((__pyx_t_6squish_4core_INT_T)0xbad0bad0); /* "squish/energy.pyx":90 - * cdef INT_T i, j - * for i in prange(self.n, nogil=True): - * xi = _Site(i, &info) # <<<<<<<<<<<<<< - * e = xi.edge(&xi) - * edge_set = _BitSet(num_edges) + * cdef INT_T i, j + * for i in prange(self.n, nogil=True): + * xi = _Site(i, &info) # <<<<<<<<<<<<<< + * e = xi.edge(&xi) + * edge_set = _BitSet(num_edges) */ __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); /* "squish/energy.pyx":91 - * for i in prange(self.n, nogil=True): - * xi = _Site(i, &info) - * e = xi.edge(&xi) # <<<<<<<<<<<<<< - * edge_set = _BitSet(num_edges) - * j = 0 + * for i in prange(self.n, nogil=True): + * xi = _Site(i, &info) + * e = xi.edge(&xi) # <<<<<<<<<<<<<< + * edge_set = _BitSet(num_edges) + * j = 0 */ __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); /* "squish/energy.pyx":92 - * xi = _Site(i, &info) - * e = xi.edge(&xi) - * edge_set = _BitSet(num_edges) # <<<<<<<<<<<<<< - * j = 0 - * while j < xi.edge_num(&xi): # Looping through site edges. + * xi = _Site(i, &info) + * e = xi.edge(&xi) + * edge_set = _BitSet(num_edges) # <<<<<<<<<<<<<< + * j = 0 + * while j < xi.edge_num(&xi): # Looping through site edges. */ __pyx_v_edge_set = __pyx_f_6squish_4core__BitSet(__pyx_v_num_edges); /* "squish/energy.pyx":93 - * e = xi.edge(&xi) - * edge_set = _BitSet(num_edges) - * j = 0 # <<<<<<<<<<<<<< - * while j < xi.edge_num(&xi): # Looping through site edges. - * f = e + * e = xi.edge(&xi) + * edge_set = _BitSet(num_edges) + * j = 0 # <<<<<<<<<<<<<< + * while j < xi.edge_num(&xi): # Looping through site edges. + * f = e */ __pyx_v_j = 0; /* "squish/energy.pyx":94 - * edge_set = _BitSet(num_edges) - * j = 0 - * while j < xi.edge_num(&xi): # Looping through site edges. # <<<<<<<<<<<<<< - * f = e - * while True: # Circling this vertex. + * edge_set = _BitSet(num_edges) + * j = 0 + * while j < xi.edge_num(&xi): # Looping through site edges. # <<<<<<<<<<<<<< + * f = e + * while True: # Circling this vertex. */ while (1) { __pyx_t_9 = ((__pyx_v_j < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); if (!__pyx_t_9) break; /* "squish/energy.pyx":95 - * j = 0 - * while j < xi.edge_num(&xi): # Looping through site edges. - * f = e # <<<<<<<<<<<<<< - * while True: # Circling this vertex. - * if not edge_set.add(&edge_set, f.arr_index): + * j = 0 + * while j < xi.edge_num(&xi): # Looping through site edges. + * f = e # <<<<<<<<<<<<<< + * while True: # Circling this vertex. + * if not edge_set.add(&edge_set, f.arr_index): */ __pyx_v_f = __pyx_v_e; /* "squish/energy.pyx":96 - * while j < xi.edge_num(&xi): # Looping through site edges. - * f = e - * while True: # Circling this vertex. # <<<<<<<<<<<<<< - * if not edge_set.add(&edge_set, f.arr_index): - * xf = f.face(&f) + * while j < xi.edge_num(&xi): # Looping through site edges. + * f = e + * while True: # Circling this vertex. # <<<<<<<<<<<<<< + * if not edge_set.add(&edge_set, f.arr_index): + * xf = f.face(&f) */ while (1) { /* "squish/energy.pyx":97 - * f = e - * while True: # Circling this vertex. - * if not edge_set.add(&edge_set, f.arr_index): # <<<<<<<<<<<<<< - * xf = f.face(&f) - * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv + * f = e + * while True: # Circling this vertex. + * if not edge_set.add(&edge_set, f.arr_index): # <<<<<<<<<<<<<< + * xf = f.face(&f) + * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv */ __pyx_t_9 = ((!(__pyx_v_edge_set.add((&__pyx_v_edge_set), __pyx_v_f.arr_index) != 0)) != 0); if (__pyx_t_9) { /* "squish/energy.pyx":98 - * while True: # Circling this vertex. - * if not edge_set.add(&edge_set, f.arr_index): - * xf = f.face(&f) # <<<<<<<<<<<<<< - * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv - * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) + * while True: # Circling this vertex. + * if not edge_set.add(&edge_set, f.arr_index): + * xf = f.face(&f) # <<<<<<<<<<<<<< + * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv + * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) */ __pyx_v_xf = __pyx_v_f.face((&__pyx_v_f)); /* "squish/energy.pyx":99 - * if not edge_set.add(&edge_set, f.arr_index): - * xf = f.face(&f) - * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv # <<<<<<<<<<<<<< - * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) - * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) + * if not edge_set.add(&edge_set, f.arr_index): + * xf = f.face(&f) + * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv # <<<<<<<<<<<<<< + * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) + * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) */ __pyx_v_dedxi_p = __pyx_v_f.cache->dVdv((&__pyx_v_f), __pyx_v_6squish_7voronoi_NAN_VECTOR); /* "squish/energy.pyx":100 - * xf = f.face(&f) - * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv - * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) # <<<<<<<<<<<<<< - * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) - * dedx[i][0] += dedxi_p.x + * xf = f.face(&f) + * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv + * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) # <<<<<<<<<<<<<< + * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) + * dedx[i][0] += dedxi_p.x */ (void)(__pyx_v_dedxi_p.self.smul((&__pyx_v_dedxi_p), (__pyx_v_xf.cache->area((&__pyx_v_xf), NAN) - __pyx_v_A))); /* "squish/energy.pyx":101 - * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv - * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) - * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) # <<<<<<<<<<<<<< - * dedx[i][0] += dedxi_p.x - * dedx[i][1] += dedxi_p.y + * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv + * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) + * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) # <<<<<<<<<<<<<< + * dedx[i][0] += dedxi_p.x + * dedx[i][1] += dedxi_p.y */ (void)(__pyx_v_dedxi_p.self.matmul((&__pyx_v_dedxi_p), __pyx_v_e.cache->H((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_MATRIX))); /* "squish/energy.pyx":102 - * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) - * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) - * dedx[i][0] += dedxi_p.x # <<<<<<<<<<<<<< - * dedx[i][1] += dedxi_p.y + * dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) + * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) + * dedx[i][0] += dedxi_p.x # <<<<<<<<<<<<<< + * dedx[i][1] += dedxi_p.y * */ __pyx_t_10 = __pyx_v_i; @@ -4167,67 +4207,67 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ ((char *) (((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_dedx.data + __pyx_t_10 * __pyx_v_dedx.strides[0]) )) + __pyx_t_11)) )) += __pyx_v_dedxi_p.x; /* "squish/energy.pyx":103 - * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) - * dedx[i][0] += dedxi_p.x - * dedx[i][1] += dedxi_p.y # <<<<<<<<<<<<<< + * dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) + * dedx[i][0] += dedxi_p.x + * dedx[i][1] += dedxi_p.y # <<<<<<<<<<<<<< * - * f = f.twin(&f) + * f = f.twin(&f) */ __pyx_t_10 = __pyx_v_i; __pyx_t_11 = 1; *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ ((char *) (((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_dedx.data + __pyx_t_10 * __pyx_v_dedx.strides[0]) )) + __pyx_t_11)) )) += __pyx_v_dedxi_p.y; /* "squish/energy.pyx":97 - * f = e - * while True: # Circling this vertex. - * if not edge_set.add(&edge_set, f.arr_index): # <<<<<<<<<<<<<< - * xf = f.face(&f) - * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv + * f = e + * while True: # Circling this vertex. + * if not edge_set.add(&edge_set, f.arr_index): # <<<<<<<<<<<<<< + * xf = f.face(&f) + * dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv */ } /* "squish/energy.pyx":105 - * dedx[i][1] += dedxi_p.y + * dedx[i][1] += dedxi_p.y * - * f = f.twin(&f) # <<<<<<<<<<<<<< - * f = f.next(&f) - * if f.arr_index == e.arr_index: + * f = f.twin(&f) # <<<<<<<<<<<<<< + * f = f.next(&f) + * if f.arr_index == e.arr_index: */ __pyx_v_f = __pyx_v_f.twin((&__pyx_v_f)); /* "squish/energy.pyx":106 * - * f = f.twin(&f) - * f = f.next(&f) # <<<<<<<<<<<<<< - * if f.arr_index == e.arr_index: - * break + * f = f.twin(&f) + * f = f.next(&f) # <<<<<<<<<<<<<< + * if f.arr_index == e.arr_index: + * break */ __pyx_v_f = __pyx_v_f.next((&__pyx_v_f)); /* "squish/energy.pyx":107 - * f = f.twin(&f) - * f = f.next(&f) - * if f.arr_index == e.arr_index: # <<<<<<<<<<<<<< - * break + * f = f.twin(&f) + * f = f.next(&f) + * if f.arr_index == e.arr_index: # <<<<<<<<<<<<<< + * break * */ __pyx_t_9 = ((__pyx_v_f.arr_index == __pyx_v_e.arr_index) != 0); if (__pyx_t_9) { /* "squish/energy.pyx":108 - * f = f.next(&f) - * if f.arr_index == e.arr_index: - * break # <<<<<<<<<<<<<< + * f = f.next(&f) + * if f.arr_index == e.arr_index: + * break # <<<<<<<<<<<<<< * - * e = e.next(&e) + * e = e.next(&e) */ goto __pyx_L13_break; /* "squish/energy.pyx":107 - * f = f.twin(&f) - * f = f.next(&f) - * if f.arr_index == e.arr_index: # <<<<<<<<<<<<<< - * break + * f = f.twin(&f) + * f = f.next(&f) + * if f.arr_index == e.arr_index: # <<<<<<<<<<<<<< + * break * */ } @@ -4235,29 +4275,29 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ __pyx_L13_break:; /* "squish/energy.pyx":110 - * break + * break * - * e = e.next(&e) # <<<<<<<<<<<<<< - * j = j + 1 - * edge_set.free(&edge_set) + * e = e.next(&e) # <<<<<<<<<<<<<< + * j = j + 1 + * edge_set.free(&edge_set) */ __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); /* "squish/energy.pyx":111 * - * e = e.next(&e) - * j = j + 1 # <<<<<<<<<<<<<< - * edge_set.free(&edge_set) - * self.grad = dedx + * e = e.next(&e) + * j = j + 1 # <<<<<<<<<<<<<< + * edge_set.free(&edge_set) + * self.grad = dedx */ __pyx_v_j = (__pyx_v_j + 1); } /* "squish/energy.pyx":112 - * e = e.next(&e) - * j = j + 1 - * edge_set.free(&edge_set) # <<<<<<<<<<<<<< - * self.grad = dedx + * e = e.next(&e) + * j = j + 1 + * edge_set.free(&edge_set) # <<<<<<<<<<<<<< + * self.grad = dedx * */ __pyx_v_edge_set.free((&__pyx_v_edge_set)); @@ -4276,10 +4316,10 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ /* "squish/energy.pyx":89 * - * cdef INT_T i, j - * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ /*finally:*/ { /*normal exit:*/{ @@ -4294,9 +4334,9 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ } /* "squish/energy.pyx":113 - * j = j + 1 - * edge_set.free(&edge_set) - * self.grad = dedx # <<<<<<<<<<<<<< + * j = j + 1 + * edge_set.free(&edge_set) + * self.grad = dedx # <<<<<<<<<<<<<< * * */ @@ -4307,9 +4347,9 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ /* "squish/energy.pyx":74 * * - * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ /* function exit code */ @@ -4326,6 +4366,768 @@ static void __pyx_f_6squish_6energy_10AreaEnergy_calc_grad(struct __pyx_obj_6squ __Pyx_RefNannyFinishContext(); } +/* "squish/energy.pyx":116 + * + * + * cdef void calc_hess(self) except *: # <<<<<<<<<<<<<< + * d = 10e-5 + * HE = np.zeros((2*self.n, 2*self.n)) + */ + +static void __pyx_f_6squish_6energy_10AreaEnergy_calc_hess(struct __pyx_obj_6squish_6energy_AreaEnergy *__pyx_v_self) { + double __pyx_v_d; + PyObject *__pyx_v_HE = NULL; + PyObject *__pyx_v_new_sites = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_j = NULL; + PyObject *__pyx_v_mod = NULL; + PyObject *__pyx_v_Ep = NULL; + PyObject *__pyx_v_Em = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *(*__pyx_t_7)(PyObject *); + long __pyx_t_8; + int __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + int __pyx_t_13; + PyObject *__pyx_t_14 = NULL; + Py_ssize_t __pyx_t_15; + PyObject *(*__pyx_t_16)(PyObject *); + __Pyx_memviewslice __pyx_t_17 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("calc_hess", 0); + + /* "squish/energy.pyx":117 + * + * cdef void calc_hess(self) except *: + * d = 10e-5 # <<<<<<<<<<<<<< + * HE = np.zeros((2*self.n, 2*self.n)) + * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. + */ + __pyx_v_d = 10e-5; + + /* "squish/energy.pyx":118 + * cdef void calc_hess(self) except *: + * d = 10e-5 + * HE = np.zeros((2*self.n, 2*self.n)) # <<<<<<<<<<<<<< + * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. + * for i in range(self.n): + */ + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->__pyx_base.n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->__pyx_base.n)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_HE = __pyx_t_1; + __pyx_t_1 = 0; + + /* "squish/energy.pyx":119 + * d = 10e-5 + * HE = np.zeros((2*self.n, 2*self.n)) + * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. # <<<<<<<<<<<<<< + * for i in range(self.n): + * for j in range(2): + */ + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_site_arr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_new_sites = __pyx_t_1; + __pyx_t_1 = 0; + + /* "squish/energy.pyx":120 + * HE = np.zeros((2*self.n, 2*self.n)) + * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. + * for i in range(self.n): # <<<<<<<<<<<<<< + * for j in range(2): + * mod = self.w if j == 0 else self.h + */ + __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->__pyx_base.n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { + __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 120, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + for (;;) { + if (likely(!__pyx_t_7)) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 120, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 120, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_7(__pyx_t_1); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 120, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5); + __pyx_t_5 = 0; + + /* "squish/energy.pyx":121 + * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. + * for i in range(self.n): + * for j in range(2): # <<<<<<<<<<<<<< + * mod = self.w if j == 0 else self.h + * new_sites[i][j] = (new_sites[i][j] + d) % mod + */ + for (__pyx_t_8 = 0; __pyx_t_8 < 2; __pyx_t_8+=1) { + __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_5); + __pyx_t_5 = 0; + + /* "squish/energy.pyx":122 + * for i in range(self.n): + * for j in range(2): + * mod = self.w if j == 0 else self.h # <<<<<<<<<<<<<< + * new_sites[i][j] = (new_sites[i][j] + d) % mod + * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) + */ + __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_v_j, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_9) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __pyx_t_3; + __pyx_t_3 = 0; + } else { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.h); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 122, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __pyx_t_3; + __pyx_t_3 = 0; + } + __Pyx_XDECREF_SET(__pyx_v_mod, __pyx_t_5); + __pyx_t_5 = 0; + + /* "squish/energy.pyx":123 + * for j in range(2): + * mod = self.w if j == 0 else self.h + * new_sites[i][j] = (new_sites[i][j] + d) % mod # <<<<<<<<<<<<<< + * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) + * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod + */ + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Remainder(__pyx_t_4, __pyx_v_mod); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_v_j, __pyx_t_5) < 0)) __PYX_ERR(0, 123, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "squish/energy.pyx":124 + * mod = self.w if j == 0 else self.h + * new_sites[i][j] = (new_sites[i][j] + d) % mod + * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) # <<<<<<<<<<<<<< + * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod + * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->__pyx_base.n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.r); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_12 = NULL; + __pyx_t_13 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_13 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[6] = {__pyx_t_12, __pyx_t_3, __pyx_t_2, __pyx_t_10, __pyx_t_11, __pyx_v_new_sites}; + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[6] = {__pyx_t_12, __pyx_t_3, __pyx_t_2, __pyx_t_10, __pyx_t_11, __pyx_v_new_sites}; + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } else + #endif + { + __pyx_t_14 = PyTuple_New(5+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + if (__pyx_t_12) { + __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_13, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_13, __pyx_t_11); + __Pyx_INCREF(__pyx_v_new_sites); + __Pyx_GIVEREF(__pyx_v_new_sites); + PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_13, __pyx_v_new_sites); + __pyx_t_3 = 0; + __pyx_t_2 = 0; + __pyx_t_10 = 0; + __pyx_t_11 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_Ep, __pyx_t_5); + __pyx_t_5 = 0; + + /* "squish/energy.pyx":125 + * new_sites[i][j] = (new_sites[i][j] + d) % mod + * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) + * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod # <<<<<<<<<<<<<< + * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) + * new_sites[i][j] = (new_sites[i][j] + d) % mod + */ + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyFloat_FromDouble((2.0 * __pyx_v_d)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_14 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Remainder(__pyx_t_14, __pyx_v_mod); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + if (unlikely(PyObject_SetItem(__pyx_t_14, __pyx_v_j, __pyx_t_5) < 0)) __PYX_ERR(0, 125, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "squish/energy.pyx":126 + * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) + * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod + * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) # <<<<<<<<<<<<<< + * new_sites[i][j] = (new_sites[i][j] + d) % mod + * + */ + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->__pyx_base.n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.w); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_10 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.r); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + __pyx_t_13 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_14); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_14, function); + __pyx_t_13 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_14)) { + PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_t_4, __pyx_t_11, __pyx_t_10, __pyx_t_2, __pyx_v_new_sites}; + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) { + PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_t_4, __pyx_t_11, __pyx_t_10, __pyx_t_2, __pyx_v_new_sites}; + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(5+__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_13, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_13, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_13, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_13, __pyx_t_2); + __Pyx_INCREF(__pyx_v_new_sites); + __Pyx_GIVEREF(__pyx_v_new_sites); + PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_13, __pyx_v_new_sites); + __pyx_t_4 = 0; + __pyx_t_11 = 0; + __pyx_t_10 = 0; + __pyx_t_2 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_XDECREF_SET(__pyx_v_Em, __pyx_t_5); + __pyx_t_5 = 0; + + /* "squish/energy.pyx":127 + * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod + * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) + * new_sites[i][j] = (new_sites[i][j] + d) % mod # <<<<<<<<<<<<<< + * + * HE[:, 2*i+j] = ((Ep.gradient - Em.gradient)/(2*d)).flatten() + */ + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_12 = PyNumber_Add(__pyx_t_14, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Remainder(__pyx_t_12, __pyx_v_mod); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (unlikely(PyObject_SetItem(__pyx_t_12, __pyx_v_j, __pyx_t_5) < 0)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "squish/energy.pyx":129 + * new_sites[i][j] = (new_sites[i][j] + d) % mod + * + * HE[:, 2*i+j] = ((Ep.gradient - Em.gradient)/(2*d)).flatten() # <<<<<<<<<<<<<< + * + * # Average out discrepencies, since it should be symmetric. + */ + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ep, __pyx_n_s_gradient); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_Em, __pyx_n_s_gradient); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_2 = PyNumber_Subtract(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = PyFloat_FromDouble((2.0 * __pyx_v_d)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_12 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_flatten); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_14); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_14, function); + } + } + __pyx_t_5 = (__pyx_t_12) ? __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_12) : __Pyx_PyObject_CallNoArg(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = PyNumber_Multiply(__pyx_int_2, __pyx_v_i); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_12 = PyNumber_Add(__pyx_t_14, __pyx_v_j); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_INCREF(__pyx_slice_); + __Pyx_GIVEREF(__pyx_slice_); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_slice_); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_12); + __pyx_t_12 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_HE, __pyx_t_14, __pyx_t_5) < 0)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + + /* "squish/energy.pyx":120 + * HE = np.zeros((2*self.n, 2*self.n)) + * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. + * for i in range(self.n): # <<<<<<<<<<<<<< + * for j in range(2): + * mod = self.w if j == 0 else self.h + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "squish/energy.pyx":132 + * + * # Average out discrepencies, since it should be symmetric. + * for i in range(2*self.n): # <<<<<<<<<<<<<< + * for j in range(i, 2*self.n): + * HE[i][j] = (HE[i][j] + HE[j][i])/2 + */ + __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->__pyx_base.n)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { + __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 132, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + for (;;) { + if (likely(!__pyx_t_7)) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 132, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 132, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_7(__pyx_t_1); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 132, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5); + __pyx_t_5 = 0; + + /* "squish/energy.pyx":133 + * # Average out discrepencies, since it should be symmetric. + * for i in range(2*self.n): + * for j in range(i, 2*self.n): # <<<<<<<<<<<<<< + * HE[i][j] = (HE[i][j] + HE[j][i])/2 + * HE[j][i] = HE[i][j] + */ + __pyx_t_5 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->__pyx_base.n)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_i); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { + __pyx_t_14 = __pyx_t_5; __Pyx_INCREF(__pyx_t_14); __pyx_t_15 = 0; + __pyx_t_16 = NULL; + } else { + __pyx_t_15 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_16 = Py_TYPE(__pyx_t_14)->tp_iternext; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 133, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + for (;;) { + if (likely(!__pyx_t_16)) { + if (likely(PyList_CheckExact(__pyx_t_14))) { + if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_14)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 133, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_14, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_14)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 133, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_14, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_16(__pyx_t_14); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 133, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_5); + __pyx_t_5 = 0; + + /* "squish/energy.pyx":134 + * for i in range(2*self.n): + * for j in range(i, 2*self.n): + * HE[i][j] = (HE[i][j] + HE[j][i])/2 # <<<<<<<<<<<<<< + * HE[j][i] = HE[i][j] + * self.hess = HE + */ + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_j); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_5, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_v_j, __pyx_t_2) < 0)) __PYX_ERR(0, 134, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "squish/energy.pyx":135 + * for j in range(i, 2*self.n): + * HE[i][j] = (HE[i][j] + HE[j][i])/2 + * HE[j][i] = HE[i][j] # <<<<<<<<<<<<<< + * self.hess = HE + * + */ + __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_j); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_v_i, __pyx_t_5) < 0)) __PYX_ERR(0, 135, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "squish/energy.pyx":133 + * # Average out discrepencies, since it should be symmetric. + * for i in range(2*self.n): + * for j in range(i, 2*self.n): # <<<<<<<<<<<<<< + * HE[i][j] = (HE[i][j] + HE[j][i])/2 + * HE[j][i] = HE[i][j] + */ + } + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "squish/energy.pyx":132 + * + * # Average out discrepencies, since it should be symmetric. + * for i in range(2*self.n): # <<<<<<<<<<<<<< + * for j in range(i, 2*self.n): + * HE[i][j] = (HE[i][j] + HE[j][i])/2 + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "squish/energy.pyx":136 + * HE[i][j] = (HE[i][j] + HE[j][i])/2 + * HE[j][i] = HE[i][j] + * self.hess = HE # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_17 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_v_HE, PyBUF_WRITABLE); if (unlikely(!__pyx_t_17.memview)) __PYX_ERR(0, 136, __pyx_L1_error) + __PYX_XDEC_MEMVIEW(&__pyx_v_self->__pyx_base.hess, 0); + __pyx_v_self->__pyx_base.hess = __pyx_t_17; + __pyx_t_17.memview = NULL; + __pyx_t_17.data = NULL; + + /* "squish/energy.pyx":116 + * + * + * cdef void calc_hess(self) except *: # <<<<<<<<<<<<<< + * d = 10e-5 + * HE = np.zeros((2*self.n, 2*self.n)) + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_14); + __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1); + __Pyx_AddTraceback("squish.energy.AreaEnergy.calc_hess", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_HE); + __Pyx_XDECREF(__pyx_v_new_sites); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_j); + __Pyx_XDECREF(__pyx_v_mod); + __Pyx_XDECREF(__pyx_v_Ep); + __Pyx_XDECREF(__pyx_v_Em); + __Pyx_RefNannyFinishContext(); +} + /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") @@ -4360,7 +5162,7 @@ static PyObject *__pyx_pf_6squish_6energy_10AreaEnergy_2__reduce_cython__(CYTHON * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4416,7 +5218,7 @@ static PyObject *__pyx_pf_6squish_6energy_10AreaEnergy_4__setstate_cython__(CYTH * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4439,12 +5241,12 @@ static PyObject *__pyx_pf_6squish_6energy_10AreaEnergy_4__setstate_cython__(CYTH return __pyx_r; } -/* "squish/energy.pyx":130 +/* "squish/energy.pyx":153 * * - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * #self.edge_cache_map = &AREA_EDGE_CACHE_MAP + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * #self.edge_cache_map = &AREA_EDGE_CACHE_MAP */ /* Python wrapper */ @@ -4490,29 +5292,29 @@ static int __pyx_pw_6squish_6energy_14RadialALEnergy_1__init__(PyObject *__pyx_v case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 130, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 153, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 130, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 153, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_r)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 130, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 153, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_site_arr)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 130, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 153, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 130, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 153, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -4523,21 +5325,21 @@ static int __pyx_pw_6squish_6energy_14RadialALEnergy_1__init__(PyObject *__pyx_v values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } - __pyx_v_n = __Pyx_PyInt_As_npy_int64(values[0]); if (unlikely((__pyx_v_n == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L3_error) - __pyx_v_w = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_w == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L3_error) - __pyx_v_h = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_h == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L3_error) - __pyx_v_r = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_r == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L3_error) + __pyx_v_n = __Pyx_PyInt_As_npy_int64(values[0]); if (unlikely((__pyx_v_n == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error) + __pyx_v_w = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_w == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error) + __pyx_v_h = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_h == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error) + __pyx_v_r = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_r == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error) __pyx_v_site_arr = ((PyArrayObject *)values[4]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 130, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 153, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("squish.energy.RadialALEnergy.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_site_arr), __pyx_ptype_5numpy_ndarray, 1, "site_arr", 0))) __PYX_ERR(0, 131, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_site_arr), __pyx_ptype_5numpy_ndarray, 1, "site_arr", 0))) __PYX_ERR(0, 154, __pyx_L1_error) __pyx_r = __pyx_pf_6squish_6energy_14RadialALEnergy___init__(((struct __pyx_obj_6squish_6energy_RadialALEnergy *)__pyx_v_self), __pyx_v_n, __pyx_v_w, __pyx_v_h, __pyx_v_r, __pyx_v_site_arr); /* function exit code */ @@ -4573,27 +5375,27 @@ static int __pyx_pf_6squish_6energy_14RadialALEnergy___init__(struct __pyx_obj_6 __pyx_pybuffernd_site_arr.rcbuffer = &__pyx_pybuffer_site_arr; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_site_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_site_arr, &__Pyx_TypeInfo_nn___pyx_t_6squish_4core_FLOAT_T, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 130, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_site_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_site_arr, &__Pyx_TypeInfo_nn___pyx_t_6squish_4core_FLOAT_T, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 153, __pyx_L1_error) } __pyx_pybuffernd_site_arr.diminfo[0].strides = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_site_arr.diminfo[0].shape = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_site_arr.diminfo[1].strides = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_site_arr.diminfo[1].shape = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.shape[1]; - /* "squish/energy.pyx":133 - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * #self.edge_cache_map = &AREA_EDGE_CACHE_MAP - * self.energy = 0.0 # <<<<<<<<<<<<<< + /* "squish/energy.pyx":156 + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * #self.edge_cache_map = &AREA_EDGE_CACHE_MAP + * self.energy = 0.0 # <<<<<<<<<<<<<< * - * super().__init__(n, w, h, r, site_arr) + * super().__init__(n, w, h, r, site_arr) */ __pyx_v_self->__pyx_base.energy = 0.0; - /* "squish/energy.pyx":135 - * self.energy = 0.0 + /* "squish/energy.pyx":158 + * self.energy = 0.0 * - * super().__init__(n, w, h, r, site_arr) # <<<<<<<<<<<<<< + * super().__init__(n, w, h, r, site_arr) # <<<<<<<<<<<<<< * * */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_ptype_6squish_6energy_RadialALEnergy)); __Pyx_GIVEREF(((PyObject *)__pyx_ptype_6squish_6energy_RadialALEnergy)); @@ -4601,19 +5403,19 @@ static int __pyx_pf_6squish_6energy_14RadialALEnergy___init__(struct __pyx_obj_6 __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self)); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; @@ -4630,7 +5432,7 @@ static int __pyx_pf_6squish_6energy_14RadialALEnergy___init__(struct __pyx_obj_6 #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, ((PyObject *)__pyx_v_site_arr)}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -4642,7 +5444,7 @@ static int __pyx_pf_6squish_6energy_14RadialALEnergy___init__(struct __pyx_obj_6 #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, ((PyObject *)__pyx_v_site_arr)}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -4652,7 +5454,7 @@ static int __pyx_pf_6squish_6energy_14RadialALEnergy___init__(struct __pyx_obj_6 } else #endif { - __pyx_t_9 = PyTuple_New(5+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(5+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; @@ -4672,19 +5474,19 @@ static int __pyx_pf_6squish_6energy_14RadialALEnergy___init__(struct __pyx_obj_6 __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "squish/energy.pyx":130 + /* "squish/energy.pyx":153 * * - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * #self.edge_cache_map = &AREA_EDGE_CACHE_MAP + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * #self.edge_cache_map = &AREA_EDGE_CACHE_MAP */ /* function exit code */ @@ -4715,12 +5517,12 @@ static int __pyx_pf_6squish_6energy_14RadialALEnergy___init__(struct __pyx_obj_6 return __pyx_r; } -/* "squish/energy.pyx":138 +/* "squish/energy.pyx":161 * * - * cdef void precompute(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ static void __pyx_f_6squish_6energy_14RadialALEnergy_precompute(struct __pyx_obj_6squish_6energy_RadialALEnergy *__pyx_v_self) { @@ -4731,43 +5533,43 @@ static void __pyx_f_6squish_6energy_14RadialALEnergy_precompute(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("precompute", 0); - /* "squish/energy.pyx":139 + /* "squish/energy.pyx":162 * - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ - if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 139, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 139, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 139, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 162, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 162, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 162, __pyx_L1_error)} - /* "squish/energy.pyx":140 - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< + /* "squish/energy.pyx":163 + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< * - * pass + * pass */ - if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 140, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 140, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 140, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 163, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 163, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 163, __pyx_L1_error)} - /* "squish/energy.pyx":139 + /* "squish/energy.pyx":162 * - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->__pyx_base.sites, __pyx_v_self->__pyx_base.edges, __pyx_v_self->__pyx_base.points, __pyx_v_self->__pyx_base.vertices, __pyx_v_self->__pyx_base.site_cache, __pyx_v_self->__pyx_base.edge_cache, __pyx_v_self->__pyx_base.edge_cache_map); - /* "squish/energy.pyx":138 + /* "squish/energy.pyx":161 * * - * cdef void precompute(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ /* function exit code */ @@ -4778,12 +5580,12 @@ static void __pyx_f_6squish_6energy_14RadialALEnergy_precompute(struct __pyx_obj __Pyx_RefNannyFinishContext(); } -/* "squish/energy.pyx":145 +/* "squish/energy.pyx":168 * * - * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ static void __pyx_f_6squish_6energy_14RadialALEnergy_calc_grad(struct __pyx_obj_6squish_6energy_RadialALEnergy *__pyx_v_self) { @@ -4794,43 +5596,43 @@ static void __pyx_f_6squish_6energy_14RadialALEnergy_calc_grad(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("calc_grad", 0); - /* "squish/energy.pyx":146 + /* "squish/energy.pyx":169 * - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ - if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 146, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 146, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 146, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 169, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 169, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 169, __pyx_L1_error)} - /* "squish/energy.pyx":147 - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< + /* "squish/energy.pyx":170 + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< * - * pass + * pass */ - if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 147, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 147, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 147, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 170, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 170, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 170, __pyx_L1_error)} - /* "squish/energy.pyx":146 + /* "squish/energy.pyx":169 * - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->__pyx_base.sites, __pyx_v_self->__pyx_base.edges, __pyx_v_self->__pyx_base.points, __pyx_v_self->__pyx_base.vertices, __pyx_v_self->__pyx_base.site_cache, __pyx_v_self->__pyx_base.edge_cache, __pyx_v_self->__pyx_base.edge_cache_map); - /* "squish/energy.pyx":145 + /* "squish/energy.pyx":168 * * - * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ /* function exit code */ @@ -4841,6 +5643,22 @@ static void __pyx_f_6squish_6energy_14RadialALEnergy_calc_grad(struct __pyx_obj_ __Pyx_RefNannyFinishContext(); } +/* "squish/energy.pyx":174 + * pass + * + * cdef void calc_hess(self) except *: # <<<<<<<<<<<<<< + * pass + * + */ + +static void __pyx_f_6squish_6energy_14RadialALEnergy_calc_hess(CYTHON_UNUSED struct __pyx_obj_6squish_6energy_RadialALEnergy *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("calc_hess", 0); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") @@ -4875,7 +5693,7 @@ static PyObject *__pyx_pf_6squish_6energy_14RadialALEnergy_2__reduce_cython__(CY * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4931,7 +5749,7 @@ static PyObject *__pyx_pf_6squish_6energy_14RadialALEnergy_4__setstate_cython__( * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4954,12 +5772,12 @@ static PyObject *__pyx_pf_6squish_6energy_14RadialALEnergy_4__setstate_cython__( return __pyx_r; } -/* "squish/energy.pyx":164 - * attr_str = "radial-t" - * title_str = "Radial[T]" - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &RADIALT_ECM +/* "squish/energy.pyx":190 + * attr_str = "radial-t" + * title_str = "Radial[T]" + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &RADIALT_ECM */ /* Python wrapper */ @@ -5005,29 +5823,29 @@ static int __pyx_pw_6squish_6energy_13RadialTEnergy_1__init__(PyObject *__pyx_v_ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 164, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 190, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 164, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 190, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_r)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 164, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 190, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_site_arr)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 164, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 190, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 164, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 190, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; @@ -5038,21 +5856,21 @@ static int __pyx_pw_6squish_6energy_13RadialTEnergy_1__init__(PyObject *__pyx_v_ values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } - __pyx_v_n = __Pyx_PyInt_As_npy_int64(values[0]); if (unlikely((__pyx_v_n == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) - __pyx_v_w = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_w == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) - __pyx_v_h = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_h == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) - __pyx_v_r = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_r == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) + __pyx_v_n = __Pyx_PyInt_As_npy_int64(values[0]); if (unlikely((__pyx_v_n == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) + __pyx_v_w = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_w == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) + __pyx_v_h = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_h == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) + __pyx_v_r = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_r == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L3_error) __pyx_v_site_arr = ((PyArrayObject *)values[4]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 164, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 190, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("squish.energy.RadialTEnergy.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_site_arr), __pyx_ptype_5numpy_ndarray, 1, "site_arr", 0))) __PYX_ERR(0, 165, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_site_arr), __pyx_ptype_5numpy_ndarray, 1, "site_arr", 0))) __PYX_ERR(0, 191, __pyx_L1_error) __pyx_r = __pyx_pf_6squish_6energy_13RadialTEnergy___init__(((struct __pyx_obj_6squish_6energy_RadialTEnergy *)__pyx_v_self), __pyx_v_n, __pyx_v_w, __pyx_v_h, __pyx_v_r, __pyx_v_site_arr); /* function exit code */ @@ -5088,36 +5906,36 @@ static int __pyx_pf_6squish_6energy_13RadialTEnergy___init__(struct __pyx_obj_6s __pyx_pybuffernd_site_arr.rcbuffer = &__pyx_pybuffer_site_arr; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_site_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_site_arr, &__Pyx_TypeInfo_nn___pyx_t_6squish_4core_FLOAT_T, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 164, __pyx_L1_error) + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_site_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_site_arr, &__Pyx_TypeInfo_nn___pyx_t_6squish_4core_FLOAT_T, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 190, __pyx_L1_error) } __pyx_pybuffernd_site_arr.diminfo[0].strides = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_site_arr.diminfo[0].shape = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_site_arr.diminfo[1].strides = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_site_arr.diminfo[1].shape = __pyx_pybuffernd_site_arr.rcbuffer->pybuffer.shape[1]; - /* "squish/energy.pyx":166 - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &RADIALT_ECM # <<<<<<<<<<<<<< - * self.energy = 0.0 + /* "squish/energy.pyx":192 + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &RADIALT_ECM # <<<<<<<<<<<<<< + * self.energy = 0.0 * */ __pyx_v_self->__pyx_base.edge_cache_map = (&__pyx_v_6squish_6energy_RADIALT_ECM); - /* "squish/energy.pyx":167 - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &RADIALT_ECM - * self.energy = 0.0 # <<<<<<<<<<<<<< + /* "squish/energy.pyx":193 + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &RADIALT_ECM + * self.energy = 0.0 # <<<<<<<<<<<<<< * - * super().__init__(n, w, h, r, site_arr) + * super().__init__(n, w, h, r, site_arr) */ __pyx_v_self->__pyx_base.energy = 0.0; - /* "squish/energy.pyx":169 - * self.energy = 0.0 + /* "squish/energy.pyx":195 + * self.energy = 0.0 * - * super().__init__(n, w, h, r, site_arr) # <<<<<<<<<<<<<< + * super().__init__(n, w, h, r, site_arr) # <<<<<<<<<<<<<< * * */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_ptype_6squish_6energy_RadialTEnergy)); __Pyx_GIVEREF(((PyObject *)__pyx_ptype_6squish_6energy_RadialTEnergy)); @@ -5125,19 +5943,19 @@ static int __pyx_pf_6squish_6energy_13RadialTEnergy___init__(struct __pyx_obj_6s __Pyx_INCREF(((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self)); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; @@ -5154,7 +5972,7 @@ static int __pyx_pf_6squish_6energy_13RadialTEnergy___init__(struct __pyx_obj_6s #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, ((PyObject *)__pyx_v_site_arr)}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -5166,7 +5984,7 @@ static int __pyx_pf_6squish_6energy_13RadialTEnergy___init__(struct __pyx_obj_6s #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, ((PyObject *)__pyx_v_site_arr)}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 5+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -5176,7 +5994,7 @@ static int __pyx_pf_6squish_6energy_13RadialTEnergy___init__(struct __pyx_obj_6s } else #endif { - __pyx_t_9 = PyTuple_New(5+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(5+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; @@ -5196,19 +6014,19 @@ static int __pyx_pf_6squish_6energy_13RadialTEnergy___init__(struct __pyx_obj_6s __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "squish/energy.pyx":164 - * attr_str = "radial-t" - * title_str = "Radial[T]" - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< - * np.ndarray[FLOAT_T, ndim=2] site_arr): - * self.edge_cache_map = &RADIALT_ECM + /* "squish/energy.pyx":190 + * attr_str = "radial-t" + * title_str = "Radial[T]" + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, # <<<<<<<<<<<<<< + * np.ndarray[FLOAT_T, ndim=2] site_arr): + * self.edge_cache_map = &RADIALT_ECM */ /* function exit code */ @@ -5239,12 +6057,12 @@ static int __pyx_pf_6squish_6energy_13RadialTEnergy___init__(struct __pyx_obj_6s return __pyx_r; } -/* "squish/energy.pyx":172 +/* "squish/energy.pyx":198 * * - * cdef void precompute(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_6squish_6energy_RadialTEnergy *__pyx_v_self) { @@ -5280,53 +6098,53 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("precompute", 0); - /* "squish/energy.pyx":173 + /* "squish/energy.pyx":199 * - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ - if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 173, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 173, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 173, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 199, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 199, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 199, __pyx_L1_error)} - /* "squish/energy.pyx":174 - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< + /* "squish/energy.pyx":200 + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< * - * cdef Site xi + * cdef Site xi */ - if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 174, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 174, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 174, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 200, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 200, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 200, __pyx_L1_error)} - /* "squish/energy.pyx":173 + /* "squish/energy.pyx":199 * - * cdef void precompute(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->__pyx_base.sites, __pyx_v_self->__pyx_base.edges, __pyx_v_self->__pyx_base.points, __pyx_v_self->__pyx_base.vertices, __pyx_v_self->__pyx_base.site_cache, __pyx_v_self->__pyx_base.edge_cache, __pyx_v_self->__pyx_base.edge_cache_map); - /* "squish/energy.pyx":181 + /* "squish/energy.pyx":207 * - * # All energy has a 2pir_0 term. - * cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], 2*PI*self.r**2) # <<<<<<<<<<<<<< - * cdef FLOAT_T [:] avg_radii = np.zeros(self.sites.shape[0]) - * cdef FLOAT_T sm, sp + * # All energy has a 2pir_0 term. + * cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], 2*PI*self.r**2) # <<<<<<<<<<<<<< + * cdef FLOAT_T [:] avg_radii = np.zeros(self.sites.shape[0]) + * cdef FLOAT_T sm, sp */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_full); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_full); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 181, __pyx_L1_error)} - __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_self->__pyx_base.sites.shape[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 207, __pyx_L1_error)} + __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_self->__pyx_base.sites.shape[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyFloat_FromDouble(((2.0 * M_PI) * pow(__pyx_v_self->__pyx_base.r, 2.0))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(((2.0 * M_PI) * pow(__pyx_v_self->__pyx_base.r, 2.0))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; @@ -5343,7 +6161,7 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -5353,7 +6171,7 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -5361,7 +6179,7 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ } else #endif { - __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; @@ -5372,31 +6190,31 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_site_energy = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "squish/energy.pyx":182 - * # All energy has a 2pir_0 term. - * cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], 2*PI*self.r**2) - * cdef FLOAT_T [:] avg_radii = np.zeros(self.sites.shape[0]) # <<<<<<<<<<<<<< - * cdef FLOAT_T sm, sp + /* "squish/energy.pyx":208 + * # All energy has a 2pir_0 term. + * cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], 2*PI*self.r**2) + * cdef FLOAT_T [:] avg_radii = np.zeros(self.sites.shape[0]) # <<<<<<<<<<<<<< + * cdef FLOAT_T sm, sp * */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 182, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 182, __pyx_L1_error)} - __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_self->__pyx_base.sites.shape[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error) + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 208, __pyx_L1_error)} + __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_self->__pyx_base.sites.shape[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { @@ -5411,21 +6229,21 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 182, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_avg_radii = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; - /* "squish/energy.pyx":186 + /* "squish/energy.pyx":212 * - * cdef INT_T i, j - * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ { #ifdef WITH_THREAD @@ -5434,7 +6252,7 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ __Pyx_FastGIL_Remember(); #endif /*try:*/ { - if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 186, __pyx_L4_error)} + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 212, __pyx_L4_error)} __pyx_t_9 = (__pyx_v_self->__pyx_base.sites.shape[0]); if ((1 == 0)) abort(); { @@ -5462,163 +6280,163 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ __pyx_v_sm = ((__pyx_t_6squish_4core_FLOAT_T)__PYX_NAN()); __pyx_v_sp = ((__pyx_t_6squish_4core_FLOAT_T)__PYX_NAN()); - /* "squish/energy.pyx":187 - * cdef INT_T i, j - * for i in prange(self.sites.shape[0], nogil=True): - * xi = _Site(i, &info) # <<<<<<<<<<<<<< - * e = xi.edge(&xi) - * j = 0 + /* "squish/energy.pyx":213 + * cdef INT_T i, j + * for i in prange(self.sites.shape[0], nogil=True): + * xi = _Site(i, &info) # <<<<<<<<<<<<<< + * e = xi.edge(&xi) + * j = 0 */ __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); - /* "squish/energy.pyx":188 - * for i in prange(self.sites.shape[0], nogil=True): - * xi = _Site(i, &info) - * e = xi.edge(&xi) # <<<<<<<<<<<<<< - * j = 0 - * while j < xi.edge_num(&xi): + /* "squish/energy.pyx":214 + * for i in prange(self.sites.shape[0], nogil=True): + * xi = _Site(i, &info) + * e = xi.edge(&xi) # <<<<<<<<<<<<<< + * j = 0 + * while j < xi.edge_num(&xi): */ __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); - /* "squish/energy.pyx":189 - * xi = _Site(i, &info) - * e = xi.edge(&xi) - * j = 0 # <<<<<<<<<<<<<< - * while j < xi.edge_num(&xi): - * ep = e.next(&e) + /* "squish/energy.pyx":215 + * xi = _Site(i, &info) + * e = xi.edge(&xi) + * j = 0 # <<<<<<<<<<<<<< + * while j < xi.edge_num(&xi): + * ep = e.next(&e) */ __pyx_v_j = 0; - /* "squish/energy.pyx":190 - * e = xi.edge(&xi) - * j = 0 - * while j < xi.edge_num(&xi): # <<<<<<<<<<<<<< - * ep = e.next(&e) - * #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + /* "squish/energy.pyx":216 + * e = xi.edge(&xi) + * j = 0 + * while j < xi.edge_num(&xi): # <<<<<<<<<<<<<< + * ep = e.next(&e) + * #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) */ while (1) { __pyx_t_12 = ((__pyx_v_j < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); if (!__pyx_t_12) break; - /* "squish/energy.pyx":191 - * j = 0 - * while j < xi.edge_num(&xi): - * ep = e.next(&e) # <<<<<<<<<<<<<< - * #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + /* "squish/energy.pyx":217 + * j = 0 + * while j < xi.edge_num(&xi): + * ep = e.next(&e) # <<<<<<<<<<<<<< + * #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) * */ __pyx_v_ep = __pyx_v_e.next((&__pyx_v_e)); - /* "squish/energy.pyx":194 - * #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + /* "squish/energy.pyx":220 + * #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) * - * la = e.cache.la(&e, NAN_VECTOR) # <<<<<<<<<<<<<< - * sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la - * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la + * la = e.cache.la(&e, NAN_VECTOR) # <<<<<<<<<<<<<< + * sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la + * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la */ __pyx_v_la = __pyx_v_e.cache->la((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); - /* "squish/energy.pyx":195 + /* "squish/energy.pyx":221 * - * la = e.cache.la(&e, NAN_VECTOR) - * sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la # <<<<<<<<<<<<<< - * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la + * la = e.cache.la(&e, NAN_VECTOR) + * sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la # <<<<<<<<<<<<<< + * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la * */ __pyx_v_sp = __pyx_v_la.dot((&__pyx_v_la), __pyx_v_ep.cache->da((&__pyx_v_ep), __pyx_v_6squish_7voronoi_NAN_VECTOR)); - /* "squish/energy.pyx":196 - * la = e.cache.la(&e, NAN_VECTOR) - * sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la - * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la # <<<<<<<<<<<<<< + /* "squish/energy.pyx":222 + * la = e.cache.la(&e, NAN_VECTOR) + * sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la + * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la # <<<<<<<<<<<<<< * - * sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) + * sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) */ __pyx_v_sm = __pyx_v_la.dot((&__pyx_v_la), __pyx_v_e.cache->da((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR)); - /* "squish/energy.pyx":198 - * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la + /* "squish/energy.pyx":224 + * sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la * - * sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) # <<<<<<<<<<<<<< - * sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) + * sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) # <<<<<<<<<<<<<< + * sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) * */ __pyx_v_sp = (__pyx_v_sp / (__pyx_v_ep.cache->da_mag((&__pyx_v_ep), NAN) * __pyx_v_e.cache->la_mag((&__pyx_v_e), NAN))); - /* "squish/energy.pyx":199 + /* "squish/energy.pyx":225 * - * sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) - * sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) # <<<<<<<<<<<<<< + * sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) + * sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) # <<<<<<<<<<<<<< * - * e.cache.calI(&e, (atanh(sp) - atanh(sm))) + * e.cache.calI(&e, (atanh(sp) - atanh(sm))) */ __pyx_v_sm = (__pyx_v_sm / (__pyx_v_e.cache->da_mag((&__pyx_v_e), NAN) * __pyx_v_e.cache->la_mag((&__pyx_v_e), NAN))); - /* "squish/energy.pyx":201 - * sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) + /* "squish/energy.pyx":227 + * sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) * - * e.cache.calI(&e, (atanh(sp) - atanh(sm))) # <<<<<<<<<<<<<< + * e.cache.calI(&e, (atanh(sp) - atanh(sm))) # <<<<<<<<<<<<<< * - * avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 + * avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 */ (void)(__pyx_v_e.cache->calI((&__pyx_v_e), ((__pyx_t_6squish_4core_FLOAT_T)(atanh(((double)__pyx_v_sp)) - atanh(((double)__pyx_v_sm)))))); - /* "squish/energy.pyx":203 - * e.cache.calI(&e, (atanh(sp) - atanh(sm))) + /* "squish/energy.pyx":229 + * e.cache.calI(&e, (atanh(sp) - atanh(sm))) * - * avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 # <<<<<<<<<<<<<< + * avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 # <<<<<<<<<<<<<< * - * e = e.next(&e) + * e = e.next(&e) */ __pyx_t_13 = __pyx_v_i; *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_avg_radii.data + __pyx_t_13 * __pyx_v_avg_radii.strides[0]) )) += ((__pyx_v_e.cache->ya_mag((&__pyx_v_e), NAN) * __pyx_v_e.cache->calI((&__pyx_v_e), NAN)) / 2.0); - /* "squish/energy.pyx":205 - * avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 + /* "squish/energy.pyx":231 + * avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 * - * e = e.next(&e) # <<<<<<<<<<<<<< - * j = j + 1 + * e = e.next(&e) # <<<<<<<<<<<<<< + * j = j + 1 * */ __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); - /* "squish/energy.pyx":206 + /* "squish/energy.pyx":232 * - * e = e.next(&e) - * j = j + 1 # <<<<<<<<<<<<<< + * e = e.next(&e) + * j = j + 1 # <<<<<<<<<<<<<< * - * site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) + * site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) */ __pyx_v_j = (__pyx_v_j + 1); } - /* "squish/energy.pyx":208 - * j = j + 1 + /* "squish/energy.pyx":234 + * j = j + 1 * - * site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) # <<<<<<<<<<<<<< + * site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) # <<<<<<<<<<<<<< * - * xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) + * xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) */ __pyx_t_13 = __pyx_v_i; __pyx_t_14 = __pyx_v_i; *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_site_energy.data + __pyx_t_14 * __pyx_v_site_energy.strides[0]) )) += (2.0 * (__pyx_v_xi.cache->area((&__pyx_v_xi), NAN) - (__pyx_v_self->__pyx_base.r * (*((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_avg_radii.data + __pyx_t_13 * __pyx_v_avg_radii.strides[0]) )))))); - /* "squish/energy.pyx":210 - * site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) + /* "squish/energy.pyx":236 + * site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) * - * xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) # <<<<<<<<<<<<<< - * xi.cache.energy(&xi, site_energy[i]) + * xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) # <<<<<<<<<<<<<< + * xi.cache.energy(&xi, site_energy[i]) * */ __pyx_t_13 = __pyx_v_i; (void)(__pyx_v_xi.cache->avg_radius((&__pyx_v_xi), ((*((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_avg_radii.data + __pyx_t_13 * __pyx_v_avg_radii.strides[0]) ))) / ((__pyx_t_6squish_4core_FLOAT_T)(2.0 * M_PI))))); - /* "squish/energy.pyx":211 + /* "squish/energy.pyx":237 * - * xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) - * xi.cache.energy(&xi, site_energy[i]) # <<<<<<<<<<<<<< + * xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) + * xi.cache.energy(&xi, site_energy[i]) # <<<<<<<<<<<<<< * - * self.energy = np.sum(site_energy[:self.n]) + * self.energy = np.sum(site_energy[:self.n]) */ __pyx_t_13 = __pyx_v_i; (void)(__pyx_v_xi.cache->energy((&__pyx_v_xi), (*((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_site_energy.data + __pyx_t_13 * __pyx_v_site_energy.strides[0]) ))))); @@ -5635,12 +6453,12 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ #endif } - /* "squish/energy.pyx":186 + /* "squish/energy.pyx":212 * - * cdef INT_T i, j - * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ /*finally:*/ { /*normal exit:*/{ @@ -5661,16 +6479,16 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ } } - /* "squish/energy.pyx":213 - * xi.cache.energy(&xi, site_energy[i]) + /* "squish/energy.pyx":239 + * xi.cache.energy(&xi, site_energy[i]) * - * self.energy = np.sum(site_energy[:self.n]) # <<<<<<<<<<<<<< + * self.energy = np.sum(site_energy[:self.n]) # <<<<<<<<<<<<<< * * */ - __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 213, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8.data = __pyx_v_site_energy.data; @@ -5691,10 +6509,10 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_precompute(struct __pyx_obj_ 0, 1) < 0)) { - __PYX_ERR(0, 213, __pyx_L1_error) + __PYX_ERR(0, 239, __pyx_L1_error) } -__pyx_t_7 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 213, __pyx_L1_error) +__pyx_t_7 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __pyx_t_8.memview = NULL; @@ -5712,19 +6530,19 @@ __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_15 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 213, __pyx_L1_error) + __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_15 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->__pyx_base.energy = __pyx_t_15; - /* "squish/energy.pyx":172 + /* "squish/energy.pyx":198 * * - * cdef void precompute(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void precompute(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ /* function exit code */ @@ -5744,12 +6562,12 @@ __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_t_8, 1, (PyObject *(*)(char *)) __p __Pyx_RefNannyFinishContext(); } -/* "squish/energy.pyx":216 +/* "squish/energy.pyx":242 * * - * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6squish_6energy_RadialTEnergy *__pyx_v_self) { @@ -5777,52 +6595,52 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("calc_grad", 0); - /* "squish/energy.pyx":217 + /* "squish/energy.pyx":243 * - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ - if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 217, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 217, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 217, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 243, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 243, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 243, __pyx_L1_error)} - /* "squish/energy.pyx":218 - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< + /* "squish/energy.pyx":244 + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< * - * cdef Site xi + * cdef Site xi */ - if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 218, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 218, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 218, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 244, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 244, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 244, __pyx_L1_error)} - /* "squish/energy.pyx":217 + /* "squish/energy.pyx":243 * - * cdef void calc_grad(self) except *: - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->__pyx_base.sites, __pyx_v_self->__pyx_base.edges, __pyx_v_self->__pyx_base.points, __pyx_v_self->__pyx_base.vertices, __pyx_v_self->__pyx_base.site_cache, __pyx_v_self->__pyx_base.edge_cache, __pyx_v_self->__pyx_base.edge_cache_map); - /* "squish/energy.pyx":224 - * cdef Vector2D dedxi_p + /* "squish/energy.pyx":250 + * cdef Vector2D dedxi_p * - * cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) # <<<<<<<<<<<<<< + * cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) # <<<<<<<<<<<<<< * - * cdef INT_T i, j + * cdef INT_T i, j */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->__pyx_base.n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->__pyx_base.n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -5830,34 +6648,34 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6 __Pyx_GIVEREF(__pyx_int_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 224, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 224, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_dedx = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL; - /* "squish/energy.pyx":227 + /* "squish/energy.pyx":253 * - * cdef INT_T i, j - * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ { #ifdef WITH_THREAD @@ -5891,99 +6709,99 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6 /* Initialize private variables to invalid values */ __pyx_v_j = ((__pyx_t_6squish_4core_INT_T)0xbad0bad0); - /* "squish/energy.pyx":228 - * cdef INT_T i, j - * for i in prange(self.n, nogil=True): - * xi = _Site(i, &info) # <<<<<<<<<<<<<< - * e = xi.edge(&xi) + /* "squish/energy.pyx":254 + * cdef INT_T i, j + * for i in prange(self.n, nogil=True): + * xi = _Site(i, &info) # <<<<<<<<<<<<<< + * e = xi.edge(&xi) * */ __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); - /* "squish/energy.pyx":229 - * for i in prange(self.n, nogil=True): - * xi = _Site(i, &info) - * e = xi.edge(&xi) # <<<<<<<<<<<<<< + /* "squish/energy.pyx":255 + * for i in prange(self.n, nogil=True): + * xi = _Site(i, &info) + * e = xi.edge(&xi) # <<<<<<<<<<<<<< * - * j = 0 + * j = 0 */ __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); - /* "squish/energy.pyx":231 - * e = xi.edge(&xi) + /* "squish/energy.pyx":257 + * e = xi.edge(&xi) * - * j = 0 # <<<<<<<<<<<<<< - * while j < xi.edge_num(&xi): # Looping through site edges. - * dedxi_p = e.cache.ya(&e, NAN_VECTOR) + * j = 0 # <<<<<<<<<<<<<< + * while j < xi.edge_num(&xi): # Looping through site edges. + * dedxi_p = e.cache.ya(&e, NAN_VECTOR) */ __pyx_v_j = 0; - /* "squish/energy.pyx":232 + /* "squish/energy.pyx":258 * - * j = 0 - * while j < xi.edge_num(&xi): # Looping through site edges. # <<<<<<<<<<<<<< - * dedxi_p = e.cache.ya(&e, NAN_VECTOR) - * dedxi_p.self.smul( + * j = 0 + * while j < xi.edge_num(&xi): # Looping through site edges. # <<<<<<<<<<<<<< + * dedxi_p = e.cache.ya(&e, NAN_VECTOR) + * dedxi_p.self.smul( */ while (1) { __pyx_t_9 = ((__pyx_v_j < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); if (!__pyx_t_9) break; - /* "squish/energy.pyx":233 - * j = 0 - * while j < xi.edge_num(&xi): # Looping through site edges. - * dedxi_p = e.cache.ya(&e, NAN_VECTOR) # <<<<<<<<<<<<<< - * dedxi_p.self.smul( - * &dedxi_p, + /* "squish/energy.pyx":259 + * j = 0 + * while j < xi.edge_num(&xi): # Looping through site edges. + * dedxi_p = e.cache.ya(&e, NAN_VECTOR) # <<<<<<<<<<<<<< + * dedxi_p.self.smul( + * &dedxi_p, */ __pyx_v_dedxi_p = __pyx_v_e.cache->ya((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); - /* "squish/energy.pyx":234 - * while j < xi.edge_num(&xi): # Looping through site edges. - * dedxi_p = e.cache.ya(&e, NAN_VECTOR) - * dedxi_p.self.smul( # <<<<<<<<<<<<<< - * &dedxi_p, - * e.cache.calI(&e, NAN) / e.cache.ya_mag(&e, NAN) + /* "squish/energy.pyx":260 + * while j < xi.edge_num(&xi): # Looping through site edges. + * dedxi_p = e.cache.ya(&e, NAN_VECTOR) + * dedxi_p.self.smul( # <<<<<<<<<<<<<< + * &dedxi_p, + * e.cache.calI(&e, NAN) / e.cache.ya_mag(&e, NAN) */ (void)(__pyx_v_dedxi_p.self.smul((&__pyx_v_dedxi_p), (__pyx_v_e.cache->calI((&__pyx_v_e), NAN) / __pyx_v_e.cache->ya_mag((&__pyx_v_e), NAN)))); - /* "squish/energy.pyx":239 - * ) + /* "squish/energy.pyx":265 + * ) * - * dedx[i][0] += 2*self.r*dedxi_p.x # <<<<<<<<<<<<<< - * dedx[i][1] += 2*self.r*dedxi_p.y + * dedx[i][0] += 2*self.r*dedxi_p.x # <<<<<<<<<<<<<< + * dedx[i][1] += 2*self.r*dedxi_p.y * */ __pyx_t_10 = __pyx_v_i; __pyx_t_11 = 0; *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ ((char *) (((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_dedx.data + __pyx_t_10 * __pyx_v_dedx.strides[0]) )) + __pyx_t_11)) )) += ((2.0 * __pyx_v_self->__pyx_base.r) * __pyx_v_dedxi_p.x); - /* "squish/energy.pyx":240 + /* "squish/energy.pyx":266 * - * dedx[i][0] += 2*self.r*dedxi_p.x - * dedx[i][1] += 2*self.r*dedxi_p.y # <<<<<<<<<<<<<< + * dedx[i][0] += 2*self.r*dedxi_p.x + * dedx[i][1] += 2*self.r*dedxi_p.y # <<<<<<<<<<<<<< * - * e = e.next(&e) + * e = e.next(&e) */ __pyx_t_10 = __pyx_v_i; __pyx_t_11 = 1; *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ ((char *) (((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=0 */ (__pyx_v_dedx.data + __pyx_t_10 * __pyx_v_dedx.strides[0]) )) + __pyx_t_11)) )) += ((2.0 * __pyx_v_self->__pyx_base.r) * __pyx_v_dedxi_p.y); - /* "squish/energy.pyx":242 - * dedx[i][1] += 2*self.r*dedxi_p.y + /* "squish/energy.pyx":268 + * dedx[i][1] += 2*self.r*dedxi_p.y * - * e = e.next(&e) # <<<<<<<<<<<<<< - * j = j + 1 + * e = e.next(&e) # <<<<<<<<<<<<<< + * j = j + 1 * */ __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); - /* "squish/energy.pyx":243 + /* "squish/energy.pyx":269 * - * e = e.next(&e) - * j = j + 1 # <<<<<<<<<<<<<< + * e = e.next(&e) + * j = j + 1 # <<<<<<<<<<<<<< * - * self.grad = dedx + * self.grad = dedx */ __pyx_v_j = (__pyx_v_j + 1); } @@ -6000,12 +6818,12 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6 #endif } - /* "squish/energy.pyx":227 + /* "squish/energy.pyx":253 * - * cdef INT_T i, j - * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) + * cdef INT_T i, j + * for i in prange(self.n, nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) */ /*finally:*/ { /*normal exit:*/{ @@ -6019,21 +6837,23 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6 } } - /* "squish/energy.pyx":245 - * j = j + 1 + /* "squish/energy.pyx":271 + * j = j + 1 * - * self.grad = dedx # <<<<<<<<<<<<<< + * self.grad = dedx # <<<<<<<<<<<<<< + * + * cdef void calc_hess(self) except *: */ __PYX_XDEC_MEMVIEW(&__pyx_v_self->__pyx_base.grad, 0); __PYX_INC_MEMVIEW(&__pyx_v_dedx, 0); __pyx_v_self->__pyx_base.grad = __pyx_v_dedx; - /* "squish/energy.pyx":216 + /* "squish/energy.pyx":242 * * - * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + * cdef void calc_grad(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) */ /* function exit code */ @@ -6050,6 +6870,1129 @@ static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_grad(struct __pyx_obj_6 __Pyx_RefNannyFinishContext(); } +/* "squish/energy.pyx":273 + * self.grad = dedx + * + * cdef void calc_hess(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, + */ + +static void __pyx_f_6squish_6energy_13RadialTEnergy_calc_hess(struct __pyx_obj_6squish_6energy_RadialTEnergy *__pyx_v_self) { + __pyx_t_6squish_7voronoi_VoronoiInfo __pyx_v_info; + __pyx_t_6squish_7voronoi_Site __pyx_v_xi; + __pyx_t_6squish_7voronoi_Site __pyx_v_xk; + __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_em; + __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_e; + __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_ep; + __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_f; + __pyx_t_6squish_4core_Vector2D __pyx_v_temp1; + __pyx_t_6squish_4core_Vector2D __pyx_v_temp2; + __pyx_t_6squish_4core_Matrix2x2 __pyx_v_dsite; + __pyx_t_6squish_4core_Matrix2x2 __pyx_v_q; + __pyx_t_6squish_4core_Matrix2x2 __pyx_v_tempm; + __pyx_t_6squish_4core_BitSet __pyx_v_edge_set; + __pyx_t_6squish_4core_INT_T __pyx_v_num_edges; + __Pyx_memviewslice __pyx_v_HE = { 0, 0, { 0 }, { 0 }, { 0 } }; + __pyx_t_6squish_4core_INT_T __pyx_v_i; + __pyx_t_6squish_4core_INT_T __pyx_v_j; + __pyx_t_6squish_4core_INT_T __pyx_v_k; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } }; + Py_ssize_t __pyx_t_7; + __pyx_t_6squish_4core_INT_T __pyx_t_8; + __pyx_t_6squish_4core_INT_T __pyx_t_9; + int __pyx_t_10; + __pyx_t_6squish_7voronoi_HalfEdge __pyx_t_11; + __pyx_t_6squish_7voronoi_HalfEdge __pyx_t_12; + __pyx_t_6squish_4core_INT_T __pyx_t_13; + __pyx_t_6squish_4core_INT_T __pyx_t_14; + __pyx_t_6squish_4core_INT_T __pyx_t_15; + __Pyx_memviewslice __pyx_t_16 = { 0, 0, { 0 }, { 0 }, { 0 } }; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("calc_hess", 0); + + /* "squish/energy.pyx":274 + * + * cdef void calc_hess(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, + * self.edge_cache, self.edge_cache_map) + */ + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 274, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 274, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 274, __pyx_L1_error)} + + /* "squish/energy.pyx":275 + * cdef void calc_hess(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, # <<<<<<<<<<<<<< + * self.edge_cache, self.edge_cache_map) + * cdef Site xi, xk + */ + if (unlikely(!__pyx_v_self->__pyx_base.vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 275, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->__pyx_base.site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 275, __pyx_L1_error)} + + /* "squish/energy.pyx":276 + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, + * self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< + * cdef Site xi, xk + * cdef HalfEdge em, e, ep, f + */ + if (unlikely(!__pyx_v_self->__pyx_base.edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 276, __pyx_L1_error)} + + /* "squish/energy.pyx":274 + * + * cdef void calc_hess(self) except *: + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< + * self.vertices, self.site_cache, + * self.edge_cache, self.edge_cache_map) + */ + __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->__pyx_base.sites, __pyx_v_self->__pyx_base.edges, __pyx_v_self->__pyx_base.points, __pyx_v_self->__pyx_base.vertices, __pyx_v_self->__pyx_base.site_cache, __pyx_v_self->__pyx_base.edge_cache, __pyx_v_self->__pyx_base.edge_cache_map); + + /* "squish/energy.pyx":283 + * cdef BitSet edge_set + * + * cdef INT_T num_edges = self.edges.shape[0] # <<<<<<<<<<<<<< + * + * cdef FLOAT_T [:,:] HE = np.zeros((2*self.n, 2*self.n)) + */ + if (unlikely(!__pyx_v_self->__pyx_base.edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 283, __pyx_L1_error)} + __pyx_v_num_edges = (__pyx_v_self->__pyx_base.edges.shape[0]); + + /* "squish/energy.pyx":285 + * cdef INT_T num_edges = self.edges.shape[0] + * + * cdef FLOAT_T [:,:] HE = np.zeros((2*self.n, 2*self.n)) # <<<<<<<<<<<<<< + * + * cdef INT_T i, j, k + */ + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->__pyx_base.n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->__pyx_base.n)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 285, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_HE = __pyx_t_6; + __pyx_t_6.memview = NULL; + __pyx_t_6.data = NULL; + + /* "squish/energy.pyx":288 + * + * cdef INT_T i, j, k + * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) + */ + { + #ifdef WITH_THREAD + PyThreadState *_save; + Py_UNBLOCK_THREADS + __Pyx_FastGIL_Remember(); + #endif + /*try:*/ { + if (unlikely(!__pyx_v_self->__pyx_base.sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 288, __pyx_L4_error)} + __pyx_t_7 = (__pyx_v_self->__pyx_base.sites.shape[0]); + if ((1 == 0)) abort(); + { + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + #undef likely + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + #endif + __pyx_t_9 = (__pyx_t_7 - 0 + 1 - 1/abs(1)) / 1; + if (__pyx_t_9 > 0) + { + #ifdef _OPENMP + #pragma omp parallel private(__pyx_t_10, __pyx_t_11, __pyx_t_12) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_e) lastprivate(__pyx_v_em) lastprivate(__pyx_v_ep) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_xi) + #endif /* _OPENMP */ + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_9; __pyx_t_8++){ + { + __pyx_v_i = (__pyx_t_6squish_4core_INT_T)(0 + 1 * __pyx_t_8); + /* Initialize private variables to invalid values */ + __pyx_v_j = ((__pyx_t_6squish_4core_INT_T)0xbad0bad0); + + /* "squish/energy.pyx":289 + * cdef INT_T i, j, k + * for i in prange(self.sites.shape[0], nogil=True): + * xi = _Site(i, &info) # <<<<<<<<<<<<<< + * e = xi.edge(&xi) + * + */ + __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); + + /* "squish/energy.pyx":290 + * for i in prange(self.sites.shape[0], nogil=True): + * xi = _Site(i, &info) + * e = xi.edge(&xi) # <<<<<<<<<<<<<< + * + * j = 0 + */ + __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); + + /* "squish/energy.pyx":292 + * e = xi.edge(&xi) + * + * j = 0 # <<<<<<<<<<<<<< + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) + */ + __pyx_v_j = 0; + + /* "squish/energy.pyx":293 + * + * j = 0 + * while j < xi.edge_num(&xi): # <<<<<<<<<<<<<< + * em, ep = e.prev(&e), e.next(&e) + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + */ + while (1) { + __pyx_t_10 = ((__pyx_v_j < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); + if (!__pyx_t_10) break; + + /* "squish/energy.pyx":294 + * j = 0 + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) # <<<<<<<<<<<<<< + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + * + */ + __pyx_t_11 = __pyx_v_e.prev((&__pyx_v_e)); + __pyx_t_12 = __pyx_v_e.next((&__pyx_v_e)); + __pyx_v_em = __pyx_t_11; + __pyx_v_ep = __pyx_t_12; + + /* "squish/energy.pyx":295 + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) # <<<<<<<<<<<<<< + * + * e = e.next(&e) + */ + (void)(__pyx_v_e.cache->H((&__pyx_v_e), __pyx_vtabptr_6squish_7voronoi_VoronoiContainer->calc_H(__pyx_v_em, __pyx_v_e))); + + /* "squish/energy.pyx":297 + * e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + * + * e = e.next(&e) # <<<<<<<<<<<<<< + * j = j + 1 + * + */ + __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); + + /* "squish/energy.pyx":298 + * + * e = e.next(&e) + * j = j + 1 # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_j = (__pyx_v_j + 1); + } + } + } + } + } + } + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + #undef likely + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + #endif + } + + /* "squish/energy.pyx":288 + * + * cdef INT_T i, j, k + * for i in prange(self.sites.shape[0], nogil=True): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } + __pyx_L5:; + } + } + + /* "squish/energy.pyx":301 + * + * + * for i in range(self.n): # <<<<<<<<<<<<<< + * xi = _Site(i, &info) + * e = xi.edge(&xi) + */ + __pyx_t_9 = __pyx_v_self->__pyx_base.n; + __pyx_t_8 = __pyx_t_9; + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_8; __pyx_t_13+=1) { + __pyx_v_i = __pyx_t_13; + + /* "squish/energy.pyx":302 + * + * for i in range(self.n): + * xi = _Site(i, &info) # <<<<<<<<<<<<<< + * e = xi.edge(&xi) + * edge_set = _BitSet(num_edges) + */ + __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); + + /* "squish/energy.pyx":303 + * for i in range(self.n): + * xi = _Site(i, &info) + * e = xi.edge(&xi) # <<<<<<<<<<<<<< + * edge_set = _BitSet(num_edges) + * + */ + __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); + + /* "squish/energy.pyx":304 + * xi = _Site(i, &info) + * e = xi.edge(&xi) + * edge_set = _BitSet(num_edges) # <<<<<<<<<<<<<< + * + * j = 0 + */ + __pyx_v_edge_set = __pyx_f_6squish_4core__BitSet(__pyx_v_num_edges); + + /* "squish/energy.pyx":306 + * edge_set = _BitSet(num_edges) + * + * j = 0 # <<<<<<<<<<<<<< + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) + */ + __pyx_v_j = 0; + + /* "squish/energy.pyx":307 + * + * j = 0 + * while j < xi.edge_num(&xi): # <<<<<<<<<<<<<< + * em, ep = e.prev(&e), e.next(&e) + * + */ + while (1) { + __pyx_t_10 = ((__pyx_v_j < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); + if (!__pyx_t_10) break; + + /* "squish/energy.pyx":308 + * j = 0 + * while j < xi.edge_num(&xi): + * em, ep = e.prev(&e), e.next(&e) # <<<<<<<<<<<<<< + * + * # Calculating of p + */ + __pyx_t_12 = __pyx_v_e.prev((&__pyx_v_e)); + __pyx_t_11 = __pyx_v_e.next((&__pyx_v_e)); + __pyx_v_em = __pyx_t_12; + __pyx_v_ep = __pyx_t_11; + + /* "squish/energy.pyx":311 + * + * # Calculating of p + * temp1 = em.cache.la(&em, NAN_VECTOR) # <<<<<<<<<<<<<< + * temp1.self.rot(&temp1) + * temp1.self.sdiv( + */ + __pyx_v_temp1 = __pyx_v_em.cache->la((&__pyx_v_em), __pyx_v_6squish_7voronoi_NAN_VECTOR); + + /* "squish/energy.pyx":312 + * # Calculating of p + * temp1 = em.cache.la(&em, NAN_VECTOR) + * temp1.self.rot(&temp1) # <<<<<<<<<<<<<< + * temp1.self.sdiv( + * &temp1, + */ + (void)(__pyx_v_temp1.self.rot((&__pyx_v_temp1))); + + /* "squish/energy.pyx":313 + * temp1 = em.cache.la(&em, NAN_VECTOR) + * temp1.self.rot(&temp1) + * temp1.self.sdiv( # <<<<<<<<<<<<<< + * &temp1, + * em.cache.la_mag(&em, NAN) * em.cache.ya_mag(&em, NAN) / 2 + */ + (void)(__pyx_v_temp1.self.sdiv((&__pyx_v_temp1), ((__pyx_v_em.cache->la_mag((&__pyx_v_em), NAN) * __pyx_v_em.cache->ya_mag((&__pyx_v_em), NAN)) / 2.0))); + + /* "squish/energy.pyx":317 + * em.cache.la_mag(&em, NAN) * em.cache.ya_mag(&em, NAN) / 2 + * ) + * temp2 = e.cache.la(&e, NAN_VECTOR) # <<<<<<<<<<<<<< + * temp2.self.rot(&temp2) + * temp2.self.sdiv( + */ + __pyx_v_temp2 = __pyx_v_e.cache->la((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); + + /* "squish/energy.pyx":318 + * ) + * temp2 = e.cache.la(&e, NAN_VECTOR) + * temp2.self.rot(&temp2) # <<<<<<<<<<<<<< + * temp2.self.sdiv( + * &temp2, + */ + (void)(__pyx_v_temp2.self.rot((&__pyx_v_temp2))); + + /* "squish/energy.pyx":319 + * temp2 = e.cache.la(&e, NAN_VECTOR) + * temp2.self.rot(&temp2) + * temp2.self.sdiv( # <<<<<<<<<<<<<< + * &temp2, + * e.cache.la_mag(&e, NAN) * e.cache.ya_mag(&e, NAN) / 2 + */ + (void)(__pyx_v_temp2.self.sdiv((&__pyx_v_temp2), ((__pyx_v_e.cache->la_mag((&__pyx_v_e), NAN) * __pyx_v_e.cache->ya_mag((&__pyx_v_e), NAN)) / 2.0))); + + /* "squish/energy.pyx":324 + * ) + * + * temp1.self.vsub(&temp1, temp2) # (lm/Am - l/A) # <<<<<<<<<<<<<< + * + * temp2 = e.cache.da(&e, NAN_VECTOR) # rot(d) / |d| + */ + (void)(__pyx_v_temp1.self.vsub((&__pyx_v_temp1), __pyx_v_temp2)); + + /* "squish/energy.pyx":326 + * temp1.self.vsub(&temp1, temp2) # (lm/Am - l/A) + * + * temp2 = e.cache.da(&e, NAN_VECTOR) # rot(d) / |d| # <<<<<<<<<<<<<< + * temp2.self.sdiv(&temp2, e.cache.da_mag(&e, NAN)) + * temp2.self.rot(&temp2) + */ + __pyx_v_temp2 = __pyx_v_e.cache->da((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); + + /* "squish/energy.pyx":327 + * + * temp2 = e.cache.da(&e, NAN_VECTOR) # rot(d) / |d| + * temp2.self.sdiv(&temp2, e.cache.da_mag(&e, NAN)) # <<<<<<<<<<<<<< + * temp2.self.rot(&temp2) + * + */ + (void)(__pyx_v_temp2.self.sdiv((&__pyx_v_temp2), __pyx_v_e.cache->da_mag((&__pyx_v_e), NAN))); + + /* "squish/energy.pyx":328 + * temp2 = e.cache.da(&e, NAN_VECTOR) # rot(d) / |d| + * temp2.self.sdiv(&temp2, e.cache.da_mag(&e, NAN)) + * temp2.self.rot(&temp2) # <<<<<<<<<<<<<< + * + * dsite = temp1.vecmul(&temp1, temp2) + */ + (void)(__pyx_v_temp2.self.rot((&__pyx_v_temp2))); + + /* "squish/energy.pyx":330 + * temp2.self.rot(&temp2) + * + * dsite = temp1.vecmul(&temp1, temp2) # <<<<<<<<<<<<<< + * + * HE[2*i, 2*i] -= dsite.a + */ + __pyx_v_dsite = __pyx_v_temp1.vecmul((&__pyx_v_temp1), __pyx_v_temp2); + + /* "squish/energy.pyx":332 + * dsite = temp1.vecmul(&temp1, temp2) + * + * HE[2*i, 2*i] -= dsite.a # <<<<<<<<<<<<<< + * HE[2*i, 2*i+1] -= dsite.b + * HE[2*i+1, 2*i] -= dsite.c + */ + __pyx_t_14 = (2 * __pyx_v_i); + __pyx_t_15 = (2 * __pyx_v_i); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_14 * __pyx_v_HE.strides[0]) ) + __pyx_t_15 * __pyx_v_HE.strides[1]) )) -= __pyx_v_dsite.a; + + /* "squish/energy.pyx":333 + * + * HE[2*i, 2*i] -= dsite.a + * HE[2*i, 2*i+1] -= dsite.b # <<<<<<<<<<<<<< + * HE[2*i+1, 2*i] -= dsite.c + * HE[2*i+1, 2*i+1] -= dsite.d + */ + __pyx_t_15 = (2 * __pyx_v_i); + __pyx_t_14 = ((2 * __pyx_v_i) + 1); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_15 * __pyx_v_HE.strides[0]) ) + __pyx_t_14 * __pyx_v_HE.strides[1]) )) -= __pyx_v_dsite.b; + + /* "squish/energy.pyx":334 + * HE[2*i, 2*i] -= dsite.a + * HE[2*i, 2*i+1] -= dsite.b + * HE[2*i+1, 2*i] -= dsite.c # <<<<<<<<<<<<<< + * HE[2*i+1, 2*i+1] -= dsite.d + * + */ + __pyx_t_14 = ((2 * __pyx_v_i) + 1); + __pyx_t_15 = (2 * __pyx_v_i); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_14 * __pyx_v_HE.strides[0]) ) + __pyx_t_15 * __pyx_v_HE.strides[1]) )) -= __pyx_v_dsite.c; + + /* "squish/energy.pyx":335 + * HE[2*i, 2*i+1] -= dsite.b + * HE[2*i+1, 2*i] -= dsite.c + * HE[2*i+1, 2*i+1] -= dsite.d # <<<<<<<<<<<<<< + * + * # Calculating of q + */ + __pyx_t_15 = ((2 * __pyx_v_i) + 1); + __pyx_t_14 = ((2 * __pyx_v_i) + 1); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_15 * __pyx_v_HE.strides[0]) ) + __pyx_t_14 * __pyx_v_HE.strides[1]) )) -= __pyx_v_dsite.d; + + /* "squish/energy.pyx":338 + * + * # Calculating of q + * temp2 = e.cache.la(&e, NAN_VECTOR) # <<<<<<<<<<<<<< + * temp1 = temp2.copy.rot(&temp2) + * q = temp1.vecmul(&temp1, temp2) + */ + __pyx_v_temp2 = __pyx_v_e.cache->la((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); + + /* "squish/energy.pyx":339 + * # Calculating of q + * temp2 = e.cache.la(&e, NAN_VECTOR) + * temp1 = temp2.copy.rot(&temp2) # <<<<<<<<<<<<<< + * q = temp1.vecmul(&temp1, temp2) + * q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) + */ + __pyx_v_temp1 = __pyx_v_temp2.copy.rot((&__pyx_v_temp2)); + + /* "squish/energy.pyx":340 + * temp2 = e.cache.la(&e, NAN_VECTOR) + * temp1 = temp2.copy.rot(&temp2) + * q = temp1.vecmul(&temp1, temp2) # <<<<<<<<<<<<<< + * q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) + * + */ + __pyx_v_q = __pyx_v_temp1.vecmul((&__pyx_v_temp1), __pyx_v_temp2); + + /* "squish/energy.pyx":341 + * temp1 = temp2.copy.rot(&temp2) + * q = temp1.vecmul(&temp1, temp2) + * q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) # <<<<<<<<<<<<<< + * + * q.self.msub(&q, R) + */ + (void)(__pyx_v_q.self.sdiv((&__pyx_v_q), pow(__pyx_v_e.cache->la_mag((&__pyx_v_e), NAN), 2.0))); + + /* "squish/energy.pyx":343 + * q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) + * + * q.self.msub(&q, R) # <<<<<<<<<<<<<< + * q.self.smul( + * &q, + */ + (void)(__pyx_v_q.self.msub((&__pyx_v_q), __pyx_v_6squish_7voronoi_R)); + + /* "squish/energy.pyx":344 + * + * q.self.msub(&q, R) + * q.self.smul( # <<<<<<<<<<<<<< + * &q, + * e.cache.calI(&e, NAN) / e.cache.la_mag(&e, NAN) + */ + (void)(__pyx_v_q.self.smul((&__pyx_v_q), (__pyx_v_e.cache->calI((&__pyx_v_e), NAN) / __pyx_v_e.cache->la_mag((&__pyx_v_e), NAN)))); + + /* "squish/energy.pyx":349 + * ) + * + * temp1 = e.cache.la(&e, NAN_VECTOR) # <<<<<<<<<<<<<< + * temp1.self.rot(&temp1) + * tempm = temp1.vecmul(&temp1, temp1) + */ + __pyx_v_temp1 = __pyx_v_e.cache->la((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); + + /* "squish/energy.pyx":350 + * + * temp1 = e.cache.la(&e, NAN_VECTOR) + * temp1.self.rot(&temp1) # <<<<<<<<<<<<<< + * tempm = temp1.vecmul(&temp1, temp1) + * tempm.self.smul( + */ + (void)(__pyx_v_temp1.self.rot((&__pyx_v_temp1))); + + /* "squish/energy.pyx":351 + * temp1 = e.cache.la(&e, NAN_VECTOR) + * temp1.self.rot(&temp1) + * tempm = temp1.vecmul(&temp1, temp1) # <<<<<<<<<<<<<< + * tempm.self.smul( + * &tempm, + */ + __pyx_v_tempm = __pyx_v_temp1.vecmul((&__pyx_v_temp1), __pyx_v_temp1); + + /* "squish/energy.pyx":352 + * temp1.self.rot(&temp1) + * tempm = temp1.vecmul(&temp1, temp1) + * tempm.self.smul( # <<<<<<<<<<<<<< + * &tempm, + * ep.cache.da_mag(&ep, NAN) - e.cache.da_mag(&e, NAN) + */ + (void)(__pyx_v_tempm.self.smul((&__pyx_v_tempm), (__pyx_v_ep.cache->da_mag((&__pyx_v_ep), NAN) - __pyx_v_e.cache->da_mag((&__pyx_v_e), NAN)))); + + /* "squish/energy.pyx":356 + * ep.cache.da_mag(&ep, NAN) - e.cache.da_mag(&e, NAN) + * ) + * tempm.self.sdiv( # <<<<<<<<<<<<<< + * &tempm, + * e.cache.la_mag(&e, NAN)**3 * e.cache.ya_mag(&e, NAN) / 2 + */ + (void)(__pyx_v_tempm.self.sdiv((&__pyx_v_tempm), ((pow(__pyx_v_e.cache->la_mag((&__pyx_v_e), NAN), 3.0) * __pyx_v_e.cache->ya_mag((&__pyx_v_e), NAN)) / 2.0))); + + /* "squish/energy.pyx":361 + * ) + * + * q.self.madd(&q, tempm) # <<<<<<<<<<<<<< + * + * # Minus portion + */ + (void)(__pyx_v_q.self.madd((&__pyx_v_q), __pyx_v_tempm)); + + /* "squish/energy.pyx":364 + * + * # Minus portion + * temp2 = em.cache.la(&em, NAN_VECTOR) # <<<<<<<<<<<<<< + * temp1 = temp2.copy.rot(&temp2) + * tempm = temp1.vecmul(&temp1, temp2) + */ + __pyx_v_temp2 = __pyx_v_em.cache->la((&__pyx_v_em), __pyx_v_6squish_7voronoi_NAN_VECTOR); + + /* "squish/energy.pyx":365 + * # Minus portion + * temp2 = em.cache.la(&em, NAN_VECTOR) + * temp1 = temp2.copy.rot(&temp2) # <<<<<<<<<<<<<< + * tempm = temp1.vecmul(&temp1, temp2) + * tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) + */ + __pyx_v_temp1 = __pyx_v_temp2.copy.rot((&__pyx_v_temp2)); + + /* "squish/energy.pyx":366 + * temp2 = em.cache.la(&em, NAN_VECTOR) + * temp1 = temp2.copy.rot(&temp2) + * tempm = temp1.vecmul(&temp1, temp2) # <<<<<<<<<<<<<< + * tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) + * + */ + __pyx_v_tempm = __pyx_v_temp1.vecmul((&__pyx_v_temp1), __pyx_v_temp2); + + /* "squish/energy.pyx":367 + * temp1 = temp2.copy.rot(&temp2) + * tempm = temp1.vecmul(&temp1, temp2) + * tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) # <<<<<<<<<<<<<< + * + * tempm = R.copy.msub(&R, tempm) + */ + (void)(__pyx_v_tempm.self.sdiv((&__pyx_v_tempm), pow(__pyx_v_em.cache->la_mag((&__pyx_v_em), NAN), 2.0))); + + /* "squish/energy.pyx":369 + * tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) + * + * tempm = R.copy.msub(&R, tempm) # <<<<<<<<<<<<<< + * tempm.self.smul( + * &tempm, + */ + __pyx_v_tempm = __pyx_v_6squish_7voronoi_R.copy.msub((&__pyx_v_6squish_7voronoi_R), __pyx_v_tempm); + + /* "squish/energy.pyx":370 + * + * tempm = R.copy.msub(&R, tempm) + * tempm.self.smul( # <<<<<<<<<<<<<< + * &tempm, + * em.cache.calI(&em, NAN) / em.cache.la_mag(&em, NAN) + */ + (void)(__pyx_v_tempm.self.smul((&__pyx_v_tempm), (__pyx_v_em.cache->calI((&__pyx_v_em), NAN) / __pyx_v_em.cache->la_mag((&__pyx_v_em), NAN)))); + + /* "squish/energy.pyx":375 + * ) + * + * q.self.madd(&q, tempm) # <<<<<<<<<<<<<< + * + * temp1 = em.cache.la(&em, NAN_VECTOR) + */ + (void)(__pyx_v_q.self.madd((&__pyx_v_q), __pyx_v_tempm)); + + /* "squish/energy.pyx":377 + * q.self.madd(&q, tempm) + * + * temp1 = em.cache.la(&em, NAN_VECTOR) # <<<<<<<<<<<<<< + * temp1.self.rot(&temp1) + * tempm = temp1.vecmul(&temp1, temp1) + */ + __pyx_v_temp1 = __pyx_v_em.cache->la((&__pyx_v_em), __pyx_v_6squish_7voronoi_NAN_VECTOR); + + /* "squish/energy.pyx":378 + * + * temp1 = em.cache.la(&em, NAN_VECTOR) + * temp1.self.rot(&temp1) # <<<<<<<<<<<<<< + * tempm = temp1.vecmul(&temp1, temp1) + * tempm.self.smul( + */ + (void)(__pyx_v_temp1.self.rot((&__pyx_v_temp1))); + + /* "squish/energy.pyx":379 + * temp1 = em.cache.la(&em, NAN_VECTOR) + * temp1.self.rot(&temp1) + * tempm = temp1.vecmul(&temp1, temp1) # <<<<<<<<<<<<<< + * tempm.self.smul( + * &tempm, + */ + __pyx_v_tempm = __pyx_v_temp1.vecmul((&__pyx_v_temp1), __pyx_v_temp1); + + /* "squish/energy.pyx":380 + * temp1.self.rot(&temp1) + * tempm = temp1.vecmul(&temp1, temp1) + * tempm.self.smul( # <<<<<<<<<<<<<< + * &tempm, + * e.cache.da_mag(&e, NAN) - em.cache.da_mag(&em, NAN) + */ + (void)(__pyx_v_tempm.self.smul((&__pyx_v_tempm), (__pyx_v_e.cache->da_mag((&__pyx_v_e), NAN) - __pyx_v_em.cache->da_mag((&__pyx_v_em), NAN)))); + + /* "squish/energy.pyx":384 + * e.cache.da_mag(&e, NAN) - em.cache.da_mag(&em, NAN) + * ) + * tempm.self.sdiv( # <<<<<<<<<<<<<< + * &tempm, + * em.cache.la_mag(&em, NAN)**3 * em.cache.ya_mag(&em, NAN) / 2 + */ + (void)(__pyx_v_tempm.self.sdiv((&__pyx_v_tempm), ((pow(__pyx_v_em.cache->la_mag((&__pyx_v_em), NAN), 3.0) * __pyx_v_em.cache->ya_mag((&__pyx_v_em), NAN)) / 2.0))); + + /* "squish/energy.pyx":389 + * ) + * + * q.self.msub(&q, tempm) # <<<<<<<<<<<<<< + * + * # Add p to q, so p = p, q = p+q + */ + (void)(__pyx_v_q.self.msub((&__pyx_v_q), __pyx_v_tempm)); + + /* "squish/energy.pyx":392 + * + * # Add p to q, so p = p, q = p+q + * q.self.madd(&q, dsite) # <<<<<<<<<<<<<< + * + * f = e + */ + (void)(__pyx_v_q.self.madd((&__pyx_v_q), __pyx_v_dsite)); + + /* "squish/energy.pyx":394 + * q.self.madd(&q, dsite) + * + * f = e # <<<<<<<<<<<<<< + * while True: + * xk = f.face(&f) + */ + __pyx_v_f = __pyx_v_e; + + /* "squish/energy.pyx":395 + * + * f = e + * while True: # <<<<<<<<<<<<<< + * xk = f.face(&f) + * k = xk.index(&xk) % self.n + */ + while (1) { + + /* "squish/energy.pyx":396 + * f = e + * while True: + * xk = f.face(&f) # <<<<<<<<<<<<<< + * k = xk.index(&xk) % self.n + * if k < 0: + */ + __pyx_v_xk = __pyx_v_f.face((&__pyx_v_f)); + + /* "squish/energy.pyx":397 + * while True: + * xk = f.face(&f) + * k = xk.index(&xk) % self.n # <<<<<<<<<<<<<< + * if k < 0: + * k = k + self.n + */ + __pyx_v_k = (__pyx_v_xk.index((&__pyx_v_xk)) % __pyx_v_self->__pyx_base.n); + + /* "squish/energy.pyx":398 + * xk = f.face(&f) + * k = xk.index(&xk) % self.n + * if k < 0: # <<<<<<<<<<<<<< + * k = k + self.n + * + */ + __pyx_t_10 = ((__pyx_v_k < 0) != 0); + if (__pyx_t_10) { + + /* "squish/energy.pyx":399 + * k = xk.index(&xk) % self.n + * if k < 0: + * k = k + self.n # <<<<<<<<<<<<<< + * + * if not edge_set.add(&edge_set, f.arr_index): + */ + __pyx_v_k = (__pyx_v_k + __pyx_v_self->__pyx_base.n); + + /* "squish/energy.pyx":398 + * xk = f.face(&f) + * k = xk.index(&xk) % self.n + * if k < 0: # <<<<<<<<<<<<<< + * k = k + self.n + * + */ + } + + /* "squish/energy.pyx":401 + * k = k + self.n + * + * if not edge_set.add(&edge_set, f.arr_index): # <<<<<<<<<<<<<< + * tempm = q.copy.matmul(&q, f.cache.H(&f, NAN_MATRIX)) + * + */ + __pyx_t_10 = ((!(__pyx_v_edge_set.add((&__pyx_v_edge_set), __pyx_v_f.arr_index) != 0)) != 0); + if (__pyx_t_10) { + + /* "squish/energy.pyx":402 + * + * if not edge_set.add(&edge_set, f.arr_index): + * tempm = q.copy.matmul(&q, f.cache.H(&f, NAN_MATRIX)) # <<<<<<<<<<<<<< + * + * HE[2*i, 2*k] += tempm.a + */ + __pyx_v_tempm = __pyx_v_q.copy.matmul((&__pyx_v_q), __pyx_v_f.cache->H((&__pyx_v_f), __pyx_v_6squish_7voronoi_NAN_MATRIX)); + + /* "squish/energy.pyx":404 + * tempm = q.copy.matmul(&q, f.cache.H(&f, NAN_MATRIX)) + * + * HE[2*i, 2*k] += tempm.a # <<<<<<<<<<<<<< + * HE[2*i, 2*k+1] += tempm.b + * HE[2*i+1, 2*k] += tempm.c + */ + __pyx_t_14 = (2 * __pyx_v_i); + __pyx_t_15 = (2 * __pyx_v_k); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_14 * __pyx_v_HE.strides[0]) ) + __pyx_t_15 * __pyx_v_HE.strides[1]) )) += __pyx_v_tempm.a; + + /* "squish/energy.pyx":405 + * + * HE[2*i, 2*k] += tempm.a + * HE[2*i, 2*k+1] += tempm.b # <<<<<<<<<<<<<< + * HE[2*i+1, 2*k] += tempm.c + * HE[2*i+1, 2*k+1] += tempm.d + */ + __pyx_t_15 = (2 * __pyx_v_i); + __pyx_t_14 = ((2 * __pyx_v_k) + 1); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_15 * __pyx_v_HE.strides[0]) ) + __pyx_t_14 * __pyx_v_HE.strides[1]) )) += __pyx_v_tempm.b; + + /* "squish/energy.pyx":406 + * HE[2*i, 2*k] += tempm.a + * HE[2*i, 2*k+1] += tempm.b + * HE[2*i+1, 2*k] += tempm.c # <<<<<<<<<<<<<< + * HE[2*i+1, 2*k+1] += tempm.d + * + */ + __pyx_t_14 = ((2 * __pyx_v_i) + 1); + __pyx_t_15 = (2 * __pyx_v_k); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_14 * __pyx_v_HE.strides[0]) ) + __pyx_t_15 * __pyx_v_HE.strides[1]) )) += __pyx_v_tempm.c; + + /* "squish/energy.pyx":407 + * HE[2*i, 2*k+1] += tempm.b + * HE[2*i+1, 2*k] += tempm.c + * HE[2*i+1, 2*k+1] += tempm.d # <<<<<<<<<<<<<< + * + * f = f.twin(&f) + */ + __pyx_t_15 = ((2 * __pyx_v_i) + 1); + __pyx_t_14 = ((2 * __pyx_v_k) + 1); + *((__pyx_t_6squish_4core_FLOAT_T *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_HE.data + __pyx_t_15 * __pyx_v_HE.strides[0]) ) + __pyx_t_14 * __pyx_v_HE.strides[1]) )) += __pyx_v_tempm.d; + + /* "squish/energy.pyx":401 + * k = k + self.n + * + * if not edge_set.add(&edge_set, f.arr_index): # <<<<<<<<<<<<<< + * tempm = q.copy.matmul(&q, f.cache.H(&f, NAN_MATRIX)) + * + */ + } + + /* "squish/energy.pyx":409 + * HE[2*i+1, 2*k+1] += tempm.d + * + * f = f.twin(&f) # <<<<<<<<<<<<<< + * f = f.next(&f) + * if f.arr_index == e.arr_index: + */ + __pyx_v_f = __pyx_v_f.twin((&__pyx_v_f)); + + /* "squish/energy.pyx":410 + * + * f = f.twin(&f) + * f = f.next(&f) # <<<<<<<<<<<<<< + * if f.arr_index == e.arr_index: + * break + */ + __pyx_v_f = __pyx_v_f.next((&__pyx_v_f)); + + /* "squish/energy.pyx":411 + * f = f.twin(&f) + * f = f.next(&f) + * if f.arr_index == e.arr_index: # <<<<<<<<<<<<<< + * break + * + */ + __pyx_t_10 = ((__pyx_v_f.arr_index == __pyx_v_e.arr_index) != 0); + if (__pyx_t_10) { + + /* "squish/energy.pyx":412 + * f = f.next(&f) + * if f.arr_index == e.arr_index: + * break # <<<<<<<<<<<<<< + * + * e = e.next(&e) + */ + goto __pyx_L19_break; + + /* "squish/energy.pyx":411 + * f = f.twin(&f) + * f = f.next(&f) + * if f.arr_index == e.arr_index: # <<<<<<<<<<<<<< + * break + * + */ + } + } + __pyx_L19_break:; + + /* "squish/energy.pyx":414 + * break + * + * e = e.next(&e) # <<<<<<<<<<<<<< + * j = j + 1 + * edge_set.free(&edge_set) + */ + __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); + + /* "squish/energy.pyx":415 + * + * e = e.next(&e) + * j = j + 1 # <<<<<<<<<<<<<< + * edge_set.free(&edge_set) + * self.hess = -2*self.r*np.asarray(HE, dtype=FLOAT) + */ + __pyx_v_j = (__pyx_v_j + 1); + } + + /* "squish/energy.pyx":416 + * e = e.next(&e) + * j = j + 1 + * edge_set.free(&edge_set) # <<<<<<<<<<<<<< + * self.hess = -2*self.r*np.asarray(HE, dtype=FLOAT) + * self.hess = ( + */ + __pyx_v_edge_set.free((&__pyx_v_edge_set)); + } + + /* "squish/energy.pyx":417 + * j = j + 1 + * edge_set.free(&edge_set) + * self.hess = -2*self.r*np.asarray(HE, dtype=FLOAT) # <<<<<<<<<<<<<< + * self.hess = ( + * ( np.asarray(self.hess, dtype=FLOAT) + */ + __pyx_t_1 = PyFloat_FromDouble((-2.0 * __pyx_v_self->__pyx_base.r)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_HE, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_16 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_16.memview)) __PYX_ERR(0, 417, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_XDEC_MEMVIEW(&__pyx_v_self->__pyx_base.hess, 0); + __pyx_v_self->__pyx_base.hess = __pyx_t_16; + __pyx_t_16.memview = NULL; + __pyx_t_16.data = NULL; + + /* "squish/energy.pyx":419 + * self.hess = -2*self.r*np.asarray(HE, dtype=FLOAT) + * self.hess = ( + * ( np.asarray(self.hess, dtype=FLOAT) # <<<<<<<<<<<<<< + * + np.asarray(self.hess, dtype=FLOAT).T ) + * / 2 + */ + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_v_self->__pyx_base.hess.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 419, __pyx_L1_error)} + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_self->__pyx_base.hess, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "squish/energy.pyx":420 + * self.hess = ( + * ( np.asarray(self.hess, dtype=FLOAT) + * + np.asarray(self.hess, dtype=FLOAT).T ) # <<<<<<<<<<<<<< + * / 2 + * ) + */ + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_v_self->__pyx_base.hess.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 420, __pyx_L1_error)} + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_self->__pyx_base.hess, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "squish/energy.pyx":421 + * ( np.asarray(self.hess, dtype=FLOAT) + * + np.asarray(self.hess, dtype=FLOAT).T ) + * / 2 # <<<<<<<<<<<<<< + * ) + */ + __pyx_t_3 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_5, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 421, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_16 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_6squish_4core_FLOAT_T(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_16.memview)) __PYX_ERR(0, 421, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "squish/energy.pyx":418 + * edge_set.free(&edge_set) + * self.hess = -2*self.r*np.asarray(HE, dtype=FLOAT) + * self.hess = ( # <<<<<<<<<<<<<< + * ( np.asarray(self.hess, dtype=FLOAT) + * + np.asarray(self.hess, dtype=FLOAT).T ) + */ + __PYX_XDEC_MEMVIEW(&__pyx_v_self->__pyx_base.hess, 0); + __pyx_v_self->__pyx_base.hess = __pyx_t_16; + __pyx_t_16.memview = NULL; + __pyx_t_16.data = NULL; + + /* "squish/energy.pyx":273 + * self.grad = dedx + * + * cdef void calc_hess(self) except *: # <<<<<<<<<<<<<< + * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + * self.vertices, self.site_cache, + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1); + __Pyx_AddTraceback("squish.energy.RadialTEnergy.calc_hess", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __PYX_XDEC_MEMVIEW(&__pyx_v_HE, 1); + __Pyx_RefNannyFinishContext(); +} + /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") @@ -6084,7 +8027,7 @@ static PyObject *__pyx_pf_6squish_6energy_13RadialTEnergy_2__reduce_cython__(CYT * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -6140,7 +8083,7 @@ static PyObject *__pyx_pf_6squish_6energy_13RadialTEnergy_4__setstate_cython__(C * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -6695,7 +8638,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { * * cdef inline int import_umath() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 945, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 945, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; @@ -6827,7 +8770,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { * * cdef inline int import_ufunc() except -1: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 951, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 951, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; @@ -6959,7 +8902,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { * * cdef extern from *: */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 957, __pyx_L5_except_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 957, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; @@ -7383,7 +9326,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if itemsize <= 0: */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 133, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -7415,7 +9358,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if not isinstance(format, bytes): */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 136, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -7542,7 +9485,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -7816,7 +9759,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __ * * if self.dtype_is_object: */ - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 176, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; @@ -8060,7 +10003,7 @@ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(stru * info.buf = self.data * info.len = self.len */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -8794,7 +10737,7 @@ static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __p * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -8850,7 +10793,7 @@ static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -10560,7 +12503,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setit * * have_slices, index = _unellipsify(index, self.view.ndim) */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 418, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -11608,7 +13551,7 @@ static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview * else: * if len(self.view.format) == 1: */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 495, __pyx_L5_except_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 495, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -11970,7 +13913,7 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbu * * if flags & PyBUF_ND: */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 520, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 520, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -12519,7 +14462,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 570, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -12636,7 +14579,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get_ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__20, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 577, __pyx_L1_error) + __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__21, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; @@ -13674,7 +15617,7 @@ static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struc * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -13730,7 +15673,7 @@ static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED st * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -14087,9 +16030,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_7); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__23); - __Pyx_GIVEREF(__pyx_slice__23); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__23); + __Pyx_INCREF(__pyx_slice_); + __Pyx_GIVEREF(__pyx_slice_); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice_); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 682, __pyx_L1_error) @@ -14122,7 +16065,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { * else: */ /*else*/ { - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__23); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 685, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice_); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 685, __pyx_L1_error) } __pyx_L7:; @@ -14262,9 +16205,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__23); - __Pyx_GIVEREF(__pyx_slice__23); - PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__23); + __Pyx_INCREF(__pyx_slice_); + __Pyx_GIVEREF(__pyx_slice_); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice_); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 696, __pyx_L1_error) @@ -20281,7 +22224,7 @@ static PyTypeObject __pyx_type_6squish_6energy_AreaEnergy = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - "\n\tClass for formulas relevant to the Area energy.\n\t:param n: [int] how many sites to generate.\n\t:param w: [float] width of the bounding domain.\n\t:param h: [float] height of the bounding domain.\n\t:param r: [float] radius of zero energy circle.\n\t:param sites: [np.ndarray] collection of sites.\n\t", /*tp_doc*/ + "\n Class for formulas relevant to the Area energy.\n :param n: [int] how many sites to generate.\n :param w: [float] width of the bounding domain.\n :param h: [float] height of the bounding domain.\n :param r: [float] radius of zero energy circle.\n :param sites: [np.ndarray] collection of sites.\n ", /*tp_doc*/ __pyx_tp_traverse_6squish_6energy_AreaEnergy, /*tp_traverse*/ __pyx_tp_clear_6squish_6energy_AreaEnergy, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -20402,7 +22345,7 @@ static PyTypeObject __pyx_type_6squish_6energy_RadialALEnergy = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - "\n\tClass for formulas relevant to the Area energy.\n\t:param n: [int] how many sites to generate.\n\t:param w: [float] width of the bounding domain.\n\t:param h: [float] height of the bounding domain.\n\t:param r: [float] radius of zero energy circle.\n\t:param sites: [np.ndarray] collection of sites.\n\t", /*tp_doc*/ + "\n Class for formulas relevant to the Area energy.\n :param n: [int] how many sites to generate.\n :param w: [float] width of the bounding domain.\n :param h: [float] height of the bounding domain.\n :param r: [float] radius of zero energy circle.\n :param sites: [np.ndarray] collection of sites.\n ", /*tp_doc*/ __pyx_tp_traverse_6squish_6energy_RadialALEnergy, /*tp_traverse*/ __pyx_tp_clear_6squish_6energy_RadialALEnergy, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -20523,7 +22466,7 @@ static PyTypeObject __pyx_type_6squish_6energy_RadialTEnergy = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - "\n\tClass for formulas relevant to the Area energy.\n\t:param n: [int] how many sites to generate.\n\t:param w: [float] width of the bounding domain.\n\t:param h: [float] height of the bounding domain.\n\t:param r: [float] radius of zero energy circle.\n\t:param sites: [np.ndarray] collection of sites.\n\t", /*tp_doc*/ + "\n Class for formulas relevant to the Area energy.\n :param n: [int] how many sites to generate.\n :param w: [float] width of the bounding domain.\n :param h: [float] height of the bounding domain.\n :param r: [float] radius of zero energy circle.\n :param sites: [np.ndarray] collection of sites.\n ", /*tp_doc*/ __pyx_tp_traverse_6squish_6energy_RadialTEnergy, /*tp_traverse*/ __pyx_tp_clear_6squish_6energy_RadialTEnergy, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -21350,12 +23293,14 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_RadialTEnergy, __pyx_k_RadialTEnergy, sizeof(__pyx_k_RadialTEnergy), 0, 0, 1, 1}, {&__pyx_kp_u_Radial_AL, __pyx_k_Radial_AL, sizeof(__pyx_k_Radial_AL), 0, 1, 0, 0}, {&__pyx_kp_u_Radial_T, __pyx_k_Radial_T, sizeof(__pyx_k_Radial_T), 0, 1, 0, 0}, + {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1}, {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, {&__pyx_n_u_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 1, 0, 1}, + {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1}, {&__pyx_n_s_attr_str, __pyx_k_attr_str, sizeof(__pyx_k_attr_str), 0, 0, 1, 1}, {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, @@ -21364,6 +23309,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1}, {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, @@ -21371,6 +23317,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, + {&__pyx_n_s_flatten, __pyx_k_flatten, sizeof(__pyx_k_flatten), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, @@ -21378,6 +23325,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_full, __pyx_k_full, sizeof(__pyx_k_full), 0, 0, 1, 1}, {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, + {&__pyx_n_s_gradient, __pyx_k_gradient, sizeof(__pyx_k_gradient), 0, 0, 1, 1}, {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, @@ -21445,12 +23393,12 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 38, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 120, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 945, __pyx_L1_error) __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 133, __pyx_L1_error) __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 148, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 151, __pyx_L1_error) - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 180, __pyx_L1_error) __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 404, __pyx_L1_error) __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(1, 613, __pyx_L1_error) __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 832, __pyx_L1_error) @@ -21463,43 +23411,54 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + /* "squish/energy.pyx":129 + * new_sites[i][j] = (new_sites[i][j] + d) % mod + * + * HE[:, 2*i+j] = ((Ep.gradient - Em.gradient)/(2*d)).flatten() # <<<<<<<<<<<<<< + * + * # Average out discrepencies, since it should be symmetric. + */ + __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice_); + __Pyx_GIVEREF(__pyx_slice_); + /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "(tree fragment)":4 - * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 4, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 2, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): + /* "(tree fragment)":4 * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + /* "(tree fragment)":4 * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); /* "(tree fragment)":2 * def __reduce_cython__(self): @@ -21507,18 +23466,18 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); /* "(tree fragment)":4 * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") * def __setstate_cython__(self, __pyx_state): * raise TypeError("self.edge_cache_map cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_self_edge_cache_map_cannot_be_co); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":945 * __pyx_import_array() @@ -21527,9 +23486,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * cdef inline int import_umath() except -1: */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 945, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 945, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); /* "../../../../../.venv2/lib/python3.8/site-packages/numpy/__init__.pxd":951 * _import_umath() @@ -21538,9 +23497,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * cdef inline int import_ufunc() except -1: */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 951, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 951, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); /* "View.MemoryView":133 * @@ -21549,9 +23508,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * if itemsize <= 0: */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); /* "View.MemoryView":136 * @@ -21560,9 +23519,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * if not isinstance(format, bytes): */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); /* "View.MemoryView":148 * @@ -21571,9 +23530,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 148, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); /* "View.MemoryView":176 * self.data = malloc(self.len) @@ -21582,9 +23541,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * if self.dtype_is_object: */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); /* "View.MemoryView":192 * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS @@ -21593,9 +23552,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * info.buf = self.data * info.len = self.len */ - __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); /* "(tree fragment)":2 * def __reduce_cython__(self): @@ -21603,18 +23562,18 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); /* "View.MemoryView":418 * def __setitem__(memoryview self, object index, object value): @@ -21623,9 +23582,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * have_slices, index = _unellipsify(index, self.view.ndim) */ - __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 418, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); - __Pyx_GIVEREF(__pyx_tuple__16); + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 418, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); /* "View.MemoryView":495 * result = struct.unpack(self.view.format, bytesitem) @@ -21634,9 +23593,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * else: * if len(self.view.format) == 1: */ - __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 495, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); + __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 495, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__18); + __Pyx_GIVEREF(__pyx_tuple__18); /* "View.MemoryView":520 * def __getbuffer__(self, Py_buffer *info, int flags): @@ -21645,9 +23604,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * if flags & PyBUF_ND: */ - __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 520, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__18); - __Pyx_GIVEREF(__pyx_tuple__18); + __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 520, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__19); + __Pyx_GIVEREF(__pyx_tuple__19); /* "View.MemoryView":570 * if self.view.strides == NULL: @@ -21656,9 +23615,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) */ - __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 570, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); + __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 570, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); /* "View.MemoryView":577 * def suboffsets(self): @@ -21667,12 +23626,12 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) */ - __pyx_tuple__20 = PyTuple_New(1); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 577, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); + __pyx_tuple__21 = PyTuple_New(1); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__21); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_tuple__20, 0, __pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_tuple__20); + PyTuple_SET_ITEM(__pyx_tuple__21, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_tuple__21); /* "(tree fragment)":2 * def __reduce_cython__(self): @@ -21680,29 +23639,18 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") */ - __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); + __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); /* "(tree fragment)":4 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") * def __setstate_cython__(self, __pyx_state): * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< */ - __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); - - /* "View.MemoryView":682 - * if item is Ellipsis: - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< - * seen_ellipsis = True - * else: - */ - __pyx_slice__23 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__23)) __PYX_ERR(1, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__23); - __Pyx_GIVEREF(__pyx_slice__23); + __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__23); + __Pyx_GIVEREF(__pyx_tuple__23); /* "View.MemoryView":703 * for suboffset in suboffsets[:ndim]: @@ -21878,6 +23826,7 @@ static int __Pyx_modinit_type_init_code(void) { __pyx_vtable_6squish_6energy_AreaEnergy.__pyx_base = *__pyx_vtabptr_6squish_7voronoi_VoronoiContainer; __pyx_vtable_6squish_6energy_AreaEnergy.__pyx_base.precompute = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_10AreaEnergy_precompute; __pyx_vtable_6squish_6energy_AreaEnergy.__pyx_base.calc_grad = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_10AreaEnergy_calc_grad; + __pyx_vtable_6squish_6energy_AreaEnergy.__pyx_base.calc_hess = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_10AreaEnergy_calc_hess; __pyx_type_6squish_6energy_AreaEnergy.tp_base = __pyx_ptype_6squish_7voronoi_VoronoiContainer; if (PyType_Ready(&__pyx_type_6squish_6energy_AreaEnergy) < 0) __PYX_ERR(0, 20, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 @@ -21891,27 +23840,29 @@ static int __Pyx_modinit_type_init_code(void) { __pyx_vtable_6squish_6energy_RadialALEnergy.__pyx_base = *__pyx_vtabptr_6squish_7voronoi_VoronoiContainer; __pyx_vtable_6squish_6energy_RadialALEnergy.__pyx_base.precompute = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_14RadialALEnergy_precompute; __pyx_vtable_6squish_6energy_RadialALEnergy.__pyx_base.calc_grad = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_14RadialALEnergy_calc_grad; + __pyx_vtable_6squish_6energy_RadialALEnergy.__pyx_base.calc_hess = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_14RadialALEnergy_calc_hess; __pyx_type_6squish_6energy_RadialALEnergy.tp_base = __pyx_ptype_6squish_7voronoi_VoronoiContainer; - if (PyType_Ready(&__pyx_type_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 116, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 139, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_6squish_6energy_RadialALEnergy.tp_print = 0; #endif - if (__Pyx_SetVtable(__pyx_type_6squish_6energy_RadialALEnergy.tp_dict, __pyx_vtabptr_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 116, __pyx_L1_error) - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_RadialALEnergy, (PyObject *)&__pyx_type_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 116, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 116, __pyx_L1_error) + if (__Pyx_SetVtable(__pyx_type_6squish_6energy_RadialALEnergy.tp_dict, __pyx_vtabptr_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 139, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_RadialALEnergy, (PyObject *)&__pyx_type_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 139, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6squish_6energy_RadialALEnergy) < 0) __PYX_ERR(0, 139, __pyx_L1_error) __pyx_ptype_6squish_6energy_RadialALEnergy = &__pyx_type_6squish_6energy_RadialALEnergy; __pyx_vtabptr_6squish_6energy_RadialTEnergy = &__pyx_vtable_6squish_6energy_RadialTEnergy; __pyx_vtable_6squish_6energy_RadialTEnergy.__pyx_base = *__pyx_vtabptr_6squish_7voronoi_VoronoiContainer; __pyx_vtable_6squish_6energy_RadialTEnergy.__pyx_base.precompute = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_13RadialTEnergy_precompute; __pyx_vtable_6squish_6energy_RadialTEnergy.__pyx_base.calc_grad = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_13RadialTEnergy_calc_grad; + __pyx_vtable_6squish_6energy_RadialTEnergy.__pyx_base.calc_hess = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_6energy_13RadialTEnergy_calc_hess; __pyx_type_6squish_6energy_RadialTEnergy.tp_base = __pyx_ptype_6squish_7voronoi_VoronoiContainer; - if (PyType_Ready(&__pyx_type_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 152, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 178, __pyx_L1_error) #if PY_VERSION_HEX < 0x030800B1 __pyx_type_6squish_6energy_RadialTEnergy.tp_print = 0; #endif - if (__Pyx_SetVtable(__pyx_type_6squish_6energy_RadialTEnergy.tp_dict, __pyx_vtabptr_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 152, __pyx_L1_error) - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_RadialTEnergy, (PyObject *)&__pyx_type_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 152, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 152, __pyx_L1_error) + if (__Pyx_SetVtable(__pyx_type_6squish_6energy_RadialTEnergy.tp_dict, __pyx_vtabptr_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 178, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_RadialTEnergy, (PyObject *)&__pyx_type_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 178, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6squish_6energy_RadialTEnergy) < 0) __PYX_ERR(0, 178, __pyx_L1_error) __pyx_ptype_6squish_6energy_RadialTEnergy = &__pyx_type_6squish_6energy_RadialTEnergy; __pyx_vtabptr_array = &__pyx_vtable_array; __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview; @@ -22345,10 +24296,10 @@ if (!__Pyx_RefNanny) { __pyx_v_6squish_6energy_RADIALT_ECM = __pyx_f_6squish_7voronoi__EdgeCacheMap(0, 4, 6, 8, -1LL, 10, 11, 12, 13, 14); /* "squish/energy.pyx":30 - * """ + * """ * - * attr_str = "area" # <<<<<<<<<<<<<< - * title_str = "Area" + * attr_str = "area" # <<<<<<<<<<<<<< + * title_str = "Area" * */ if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_AreaEnergy->tp_dict, __pyx_n_s_attr_str, __pyx_n_u_area) < 0) __PYX_ERR(0, 30, __pyx_L1_error) @@ -22356,52 +24307,52 @@ if (!__Pyx_RefNanny) { /* "squish/energy.pyx":31 * - * attr_str = "area" - * title_str = "Area" # <<<<<<<<<<<<<< + * attr_str = "area" + * title_str = "Area" # <<<<<<<<<<<<<< * - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, */ if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_AreaEnergy->tp_dict, __pyx_n_s_title_str, __pyx_n_u_Area) < 0) __PYX_ERR(0, 31, __pyx_L1_error) PyType_Modified(__pyx_ptype_6squish_6energy_AreaEnergy); - /* "squish/energy.pyx":126 - * """ + /* "squish/energy.pyx":149 + * """ * - * attr_str = "radial-al" # <<<<<<<<<<<<<< - * title_str = "Radial[AL]" + * attr_str = "radial-al" # <<<<<<<<<<<<<< + * title_str = "Radial[AL]" * */ - if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialALEnergy->tp_dict, __pyx_n_s_attr_str, __pyx_kp_u_radial_al) < 0) __PYX_ERR(0, 126, __pyx_L1_error) + if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialALEnergy->tp_dict, __pyx_n_s_attr_str, __pyx_kp_u_radial_al) < 0) __PYX_ERR(0, 149, __pyx_L1_error) PyType_Modified(__pyx_ptype_6squish_6energy_RadialALEnergy); - /* "squish/energy.pyx":127 + /* "squish/energy.pyx":150 * - * attr_str = "radial-al" - * title_str = "Radial[AL]" # <<<<<<<<<<<<<< + * attr_str = "radial-al" + * title_str = "Radial[AL]" # <<<<<<<<<<<<<< * * */ - if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialALEnergy->tp_dict, __pyx_n_s_title_str, __pyx_kp_u_Radial_AL) < 0) __PYX_ERR(0, 127, __pyx_L1_error) + if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialALEnergy->tp_dict, __pyx_n_s_title_str, __pyx_kp_u_Radial_AL) < 0) __PYX_ERR(0, 150, __pyx_L1_error) PyType_Modified(__pyx_ptype_6squish_6energy_RadialALEnergy); - /* "squish/energy.pyx":162 - * """ + /* "squish/energy.pyx":188 + * """ * - * attr_str = "radial-t" # <<<<<<<<<<<<<< - * title_str = "Radial[T]" - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + * attr_str = "radial-t" # <<<<<<<<<<<<<< + * title_str = "Radial[T]" + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, */ - if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialTEnergy->tp_dict, __pyx_n_s_attr_str, __pyx_kp_u_radial_t) < 0) __PYX_ERR(0, 162, __pyx_L1_error) + if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialTEnergy->tp_dict, __pyx_n_s_attr_str, __pyx_kp_u_radial_t) < 0) __PYX_ERR(0, 188, __pyx_L1_error) PyType_Modified(__pyx_ptype_6squish_6energy_RadialTEnergy); - /* "squish/energy.pyx":163 + /* "squish/energy.pyx":189 * - * attr_str = "radial-t" - * title_str = "Radial[T]" # <<<<<<<<<<<<<< - * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, - * np.ndarray[FLOAT_T, ndim=2] site_arr): + * attr_str = "radial-t" + * title_str = "Radial[T]" # <<<<<<<<<<<<<< + * def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + * np.ndarray[FLOAT_T, ndim=2] site_arr): */ - if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialTEnergy->tp_dict, __pyx_n_s_title_str, __pyx_kp_u_Radial_T) < 0) __PYX_ERR(0, 163, __pyx_L1_error) + if (PyDict_SetItem((PyObject *)__pyx_ptype_6squish_6energy_RadialTEnergy->tp_dict, __pyx_n_s_title_str, __pyx_kp_u_Radial_T) < 0) __PYX_ERR(0, 189, __pyx_L1_error) PyType_Modified(__pyx_ptype_6squish_6energy_RadialTEnergy); /* "squish/energy.pyx":1 @@ -23843,6 +25794,311 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec } #endif +/* PyIntCompare */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) { + if (op1 == op2) { + Py_RETURN_TRUE; + } + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long a = PyInt_AS_LONG(op1); + if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + int unequal; + unsigned long uintval; + Py_ssize_t size = Py_SIZE(op1); + const digit* digits = ((PyLongObject*)op1)->ob_digit; + if (intval == 0) { + if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } else if (intval < 0) { + if (size >= 0) + Py_RETURN_FALSE; + intval = -intval; + size = -size; + } else { + if (size <= 0) + Py_RETURN_FALSE; + } + uintval = (unsigned long) intval; +#if PyLong_SHIFT * 4 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 4)) { + unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 3 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 3)) { + unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 2 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 2)) { + unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 1 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 1)) { + unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif + unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); + if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } + return ( + PyObject_RichCompare(op1, op2, Py_EQ)); +} + +/* GetItemInt */ + static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* ObjectGetItem */ + #if CYTHON_USE_TYPE_SLOTS +static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { + PyObject *runerr; + Py_ssize_t key_value; + PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; + if (unlikely(!(m && m->sq_item))) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); + return NULL; + } + key_value = __Pyx_PyIndex_AsSsize_t(index); + if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { + return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); + } + if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { + PyErr_Clear(); + PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); + } + return NULL; +} +static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { + PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; + if (likely(m && m->mp_subscript)) { + return m->mp_subscript(obj, key); + } + return __Pyx_PyObject_GetIndex(obj, key); +} +#endif + +/* PyObjectCallNoArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) +#else + if (likely(PyCFunction_Check(func))) +#endif + { + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* PyIntBinop */ + #if !CYTHON_COMPILING_IN_PYPY +#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS +#define __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(operand)\ + if (unlikely(zerodivision_check && ((operand) == 0))) {\ + PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\ + return NULL;\ + } +#endif +static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { + (void)inplace; + (void)zerodivision_check; + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long a = PyInt_AS_LONG(op1); + __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b) + if (8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53))) { + return PyFloat_FromDouble((double)a / (double)b); + } + return PyInt_Type.tp_as_number->nb_true_divide(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_true_divide(op1, op2); + } + } + __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b) + if ((8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53))) + || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) { + return PyFloat_FromDouble((double)a / (double)b); + } + return PyLong_Type.tp_as_number->nb_true_divide(op1, op2); + return PyLong_FromLong(x); + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + if (unlikely(zerodivision_check && b == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero"); + return NULL; + } + PyFPE_START_PROTECT("divide", return NULL) + result = ((double)a) / (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2); +} +#endif + /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, @@ -24319,122 +26575,6 @@ return_ne: return PyObject_GetAttr(o, n); } -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* ObjectGetItem */ - #if CYTHON_USE_TYPE_SLOTS -static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { - PyObject *runerr; - Py_ssize_t key_value; - PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; - if (unlikely(!(m && m->sq_item))) { - PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); - return NULL; - } - key_value = __Pyx_PyIndex_AsSsize_t(index); - if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { - return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); - } - if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { - PyErr_Clear(); - PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); - } - return NULL; -} -static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { - PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; - if (likely(m && m->mp_subscript)) { - return m->mp_subscript(obj, key); - } - return __Pyx_PyObject_GetIndex(obj, key); -} -#endif - /* decode_c_string */ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, @@ -25766,6 +27906,29 @@ __pyx_fail: return result; } +/* ObjectToMemviewSlice */ + static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_6squish_4core_FLOAT_T(PyObject *obj, int writable_flag) { + __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_BufFmt_StackElem stack[1]; + int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) }; + int retcode; + if (obj == Py_None) { + result.memview = (struct __pyx_memoryview_obj *) Py_None; + return result; + } + retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0, + PyBUF_RECORDS_RO | writable_flag, 2, + &__Pyx_TypeInfo_nn___pyx_t_6squish_4core_FLOAT_T, stack, + &result, obj); + if (unlikely(retcode == -1)) + goto __pyx_fail; + return result; +__pyx_fail: + result.memview = NULL; + result.data = NULL; + return result; +} + /* Declarations */ #if CYTHON_CCOMPLEX #ifdef __cplusplus @@ -26375,6 +28538,44 @@ raise_neg_overflow: } } +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC @@ -26805,44 +29006,6 @@ raise_neg_overflow: } } -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - /* CIntFromPy */ static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC diff --git a/squish/energy.pyx b/squish/energy.pyx index 9029caa..d395640 100644 --- a/squish/energy.pyx +++ b/squish/energy.pyx @@ -4,10 +4,10 @@ from cython.parallel import parallel, prange cimport numpy as np from libc.math cimport NAN, pi as PI, atanh from squish.core cimport INT_T, FLOAT_T, Vector2D, Matrix2x2, BitSet, \ - _Vector2D, _Matrix2x2, _BitSet + _Vector2D, _Matrix2x2, _BitSet from squish.voronoi cimport Site, HalfEdge, EdgeCacheMap, VoronoiInfo, \ - _Site, _HalfEdge, _EdgeCacheMap, _VoronoiInfo, VoronoiContainer, \ - R, NAN_MATRIX, NAN_VECTOR + _Site, _HalfEdge, _EdgeCacheMap, _VoronoiInfo, VoronoiContainer, \ + R, NAN_MATRIX, NAN_VECTOR #### Constants #### @@ -18,228 +18,405 @@ cdef EdgeCacheMap AREA_ECM = _EdgeCacheMap(0, 4, 6, 8, 10, 12, 13, -1, -1, 14) cdef EdgeCacheMap RADIALT_ECM = _EdgeCacheMap(0, 4, 6, 8, -1, 10, 11, 12, 13, 14) cdef class AreaEnergy(VoronoiContainer): - """ - Class for formulas relevant to the Area energy. - :param n: [int] how many sites to generate. - :param w: [float] width of the bounding domain. - :param h: [float] height of the bounding domain. - :param r: [float] radius of zero energy circle. - :param sites: [np.ndarray] collection of sites. - """ + """ + Class for formulas relevant to the Area energy. + :param n: [int] how many sites to generate. + :param w: [float] width of the bounding domain. + :param h: [float] height of the bounding domain. + :param r: [float] radius of zero energy circle. + :param sites: [np.ndarray] collection of sites. + """ - attr_str = "area" - title_str = "Area" + attr_str = "area" + title_str = "Area" - def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, - np.ndarray[FLOAT_T, ndim=2] site_arr): - self.edge_cache_map = &AREA_ECM - self.energy = 0.0 + def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + np.ndarray[FLOAT_T, ndim=2] site_arr): + self.edge_cache_map = &AREA_ECM + self.energy = 0.0 - super().__init__(n, w, h, r, site_arr) - self.minimum = (n)*(w*h/(n)-PI*r**2)**2 + super().__init__(n, w, h, r, site_arr) + self.minimum = (n)*(w*h/(n)-PI*r**2)**2 - cdef void precompute(self) except *: - cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + cdef void precompute(self) except *: + cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) - cdef Site xi - cdef HalfEdge em, e, ep - cdef Vector2D vdiff + cdef Site xi + cdef HalfEdge em, e, ep + cdef Vector2D vdiff - cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], PI*self.r**2) + cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], PI*self.r**2) - cdef INT_T i, j - for i in prange(self.sites.shape[0], nogil=True): - xi = _Site(i, &info) - e = xi.edge(&xi) + cdef INT_T i, j + for i in prange(self.sites.shape[0], nogil=True): + xi = _Site(i, &info) + e = xi.edge(&xi) - site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 - xi.cache.energy(&xi, site_energy[i]) + site_energy[i] = (xi.cache.area(&xi, NAN) - site_energy[i])**2 + xi.cache.energy(&xi, site_energy[i]) - j = 0 - while j < xi.edge_num(&xi): - em, ep = e.prev(&e), e.next(&e) - vdiff = em.origin(&em) - vdiff.self.vsub(&vdiff, ep.origin(&ep)) - e.cache.dVdv(&e, R.vecmul(&R, vdiff)) - e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + j = 0 + while j < xi.edge_num(&xi): + em, ep = e.prev(&e), e.next(&e) + vdiff = em.origin(&em) + vdiff.self.vsub(&vdiff, ep.origin(&ep)) + e.cache.dVdv(&e, R.vecmul(&R, vdiff)) + e.cache.H(&e, VoronoiContainer.calc_H(em, e)) - e = e.next(&e) - j = j + 1 + e = e.next(&e) + j = j + 1 - self.energy = np.sum(site_energy[:self.n]) + self.energy = np.sum(site_energy[:self.n]) - cdef void calc_grad(self) except *: - cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + cdef void calc_grad(self) except *: + cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) - cdef Site xi, xf - cdef HalfEdge e, f - cdef Vector2D dedxi_p - cdef BitSet edge_set + cdef Site xi, xf + cdef HalfEdge e, f + cdef Vector2D dedxi_p + cdef BitSet edge_set - cdef INT_T num_edges = self.edges.shape[0] - cdef FLOAT_T A = PI*self.r**2 + cdef INT_T num_edges = self.edges.shape[0] + cdef FLOAT_T A = PI*self.r**2 - cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) + cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) - cdef INT_T i, j - for i in prange(self.n, nogil=True): - xi = _Site(i, &info) - e = xi.edge(&xi) - edge_set = _BitSet(num_edges) - j = 0 - while j < xi.edge_num(&xi): # Looping through site edges. - f = e - while True: # Circling this vertex. - if not edge_set.add(&edge_set, f.arr_index): - xf = f.face(&f) - dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv - dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) - dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) - dedx[i][0] += dedxi_p.x - dedx[i][1] += dedxi_p.y + cdef INT_T i, j + for i in prange(self.n, nogil=True): + xi = _Site(i, &info) + e = xi.edge(&xi) + edge_set = _BitSet(num_edges) + j = 0 + while j < xi.edge_num(&xi): # Looping through site edges. + f = e + while True: # Circling this vertex. + if not edge_set.add(&edge_set, f.arr_index): + xf = f.face(&f) + dedxi_p = f.cache.dVdv(&f, NAN_VECTOR) #dVdv + dedxi_p.self.smul(&dedxi_p, xf.cache.area(&xf, NAN) - A) + dedxi_p.self.matmul(&dedxi_p, e.cache.H(&e, NAN_MATRIX)) + dedx[i][0] += dedxi_p.x + dedx[i][1] += dedxi_p.y - f = f.twin(&f) - f = f.next(&f) - if f.arr_index == e.arr_index: - break + f = f.twin(&f) + f = f.next(&f) + if f.arr_index == e.arr_index: + break - e = e.next(&e) - j = j + 1 - edge_set.free(&edge_set) - self.grad = dedx + e = e.next(&e) + j = j + 1 + edge_set.free(&edge_set) + self.grad = dedx + + + cdef void calc_hess(self) except *: + d = 10e-5 + HE = np.zeros((2*self.n, 2*self.n)) + new_sites = np.copy(self.site_arr) # Maintain one copy for speed. + for i in range(self.n): + for j in range(2): + mod = self.w if j == 0 else self.h + new_sites[i][j] = (new_sites[i][j] + d) % mod + Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) + new_sites[i][j] = (new_sites[i][j] - 2*d) % mod + Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) + new_sites[i][j] = (new_sites[i][j] + d) % mod + + HE[:, 2*i+j] = ((Ep.gradient - Em.gradient)/(2*d)).flatten() + + # Average out discrepencies, since it should be symmetric. + for i in range(2*self.n): + for j in range(i, 2*self.n): + HE[i][j] = (HE[i][j] + HE[j][i])/2 + HE[j][i] = HE[i][j] + self.hess = HE cdef class RadialALEnergy(VoronoiContainer): - """ - Class for formulas relevant to the Area energy. - :param n: [int] how many sites to generate. - :param w: [float] width of the bounding domain. - :param h: [float] height of the bounding domain. - :param r: [float] radius of zero energy circle. - :param sites: [np.ndarray] collection of sites. - """ + """ + Class for formulas relevant to the Area energy. + :param n: [int] how many sites to generate. + :param w: [float] width of the bounding domain. + :param h: [float] height of the bounding domain. + :param r: [float] radius of zero energy circle. + :param sites: [np.ndarray] collection of sites. + """ - attr_str = "radial-al" - title_str = "Radial[AL]" + attr_str = "radial-al" + title_str = "Radial[AL]" - def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, - np.ndarray[FLOAT_T, ndim=2] site_arr): - #self.edge_cache_map = &AREA_EDGE_CACHE_MAP - self.energy = 0.0 + def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + np.ndarray[FLOAT_T, ndim=2] site_arr): + #self.edge_cache_map = &AREA_EDGE_CACHE_MAP + self.energy = 0.0 - super().__init__(n, w, h, r, site_arr) + super().__init__(n, w, h, r, site_arr) - cdef void precompute(self) except *: - cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + cdef void precompute(self) except *: + cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) - pass + pass - cdef void calc_grad(self) except *: - cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + cdef void calc_grad(self) except *: + cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) - pass + pass + + cdef void calc_hess(self) except *: + pass cdef class RadialTEnergy(VoronoiContainer): - """ - Class for formulas relevant to the Area energy. - :param n: [int] how many sites to generate. - :param w: [float] width of the bounding domain. - :param h: [float] height of the bounding domain. - :param r: [float] radius of zero energy circle. - :param sites: [np.ndarray] collection of sites. - """ + """ + Class for formulas relevant to the Area energy. + :param n: [int] how many sites to generate. + :param w: [float] width of the bounding domain. + :param h: [float] height of the bounding domain. + :param r: [float] radius of zero energy circle. + :param sites: [np.ndarray] collection of sites. + """ - attr_str = "radial-t" - title_str = "Radial[T]" - def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, - np.ndarray[FLOAT_T, ndim=2] site_arr): - self.edge_cache_map = &RADIALT_ECM - self.energy = 0.0 + attr_str = "radial-t" + title_str = "Radial[T]" + def __init__(AreaEnergy self, INT_T n, FLOAT_T w, FLOAT_T h, FLOAT_T r, + np.ndarray[FLOAT_T, ndim=2] site_arr): + self.edge_cache_map = &RADIALT_ECM + self.energy = 0.0 - super().__init__(n, w, h, r, site_arr) + super().__init__(n, w, h, r, site_arr) - cdef void precompute(self) except *: - cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + cdef void precompute(self) except *: + cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) - cdef Site xi - cdef HalfEdge e, ep - cdef Vector2D la + cdef Site xi + cdef HalfEdge e, ep + cdef Vector2D la - # All energy has a 2pir_0 term. - cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], 2*PI*self.r**2) - cdef FLOAT_T [:] avg_radii = np.zeros(self.sites.shape[0]) - cdef FLOAT_T sm, sp + # All energy has a 2pir_0 term. + cdef FLOAT_T [:] site_energy = np.full(self.sites.shape[0], 2*PI*self.r**2) + cdef FLOAT_T [:] avg_radii = np.zeros(self.sites.shape[0]) + cdef FLOAT_T sm, sp - cdef INT_T i, j - for i in prange(self.sites.shape[0], nogil=True): - xi = _Site(i, &info) - e = xi.edge(&xi) - j = 0 - while j < xi.edge_num(&xi): - ep = e.next(&e) - #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + cdef INT_T i, j + for i in prange(self.sites.shape[0], nogil=True): + xi = _Site(i, &info) + e = xi.edge(&xi) + j = 0 + while j < xi.edge_num(&xi): + ep = e.next(&e) + #e.cache.H(&e, VoronoiContainer.calc_H(em, e)) - la = e.cache.la(&e, NAN_VECTOR) - sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la - sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la + la = e.cache.la(&e, NAN_VECTOR) + sp = la.dot(&la, ep.cache.da(&ep, NAN_VECTOR)) # dap . la + sm = la.dot(&la, e.cache.da(&e, NAN_VECTOR)) # da . la - sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) - sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) + sp = sp / (ep.cache.da_mag(&ep, NAN) * e.cache.la_mag(&e, NAN)) + sm = sm / (e.cache.da_mag(&e, NAN) * e.cache.la_mag(&e, NAN)) - e.cache.calI(&e, (atanh(sp) - atanh(sm))) + e.cache.calI(&e, (atanh(sp) - atanh(sm))) - avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 + avg_radii[i] += e.cache.ya_mag(&e, NAN) * e.cache.calI(&e, NAN) / 2 - e = e.next(&e) - j = j + 1 + e = e.next(&e) + j = j + 1 - site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) + site_energy[i] += 2*(xi.cache.area(&xi, NAN) - self.r*avg_radii[i]) - xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) - xi.cache.energy(&xi, site_energy[i]) + xi.cache.avg_radius(&xi, avg_radii[i]/(2*PI)) + xi.cache.energy(&xi, site_energy[i]) - self.energy = np.sum(site_energy[:self.n]) + self.energy = np.sum(site_energy[:self.n]) - cdef void calc_grad(self) except *: - cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) + cdef void calc_grad(self) except *: + cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) - cdef Site xi - cdef HalfEdge e - cdef Vector2D dedxi_p + cdef Site xi + cdef HalfEdge e + cdef Vector2D dedxi_p - cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) + cdef FLOAT_T [:, ::1] dedx = np.zeros((self.n, 2), dtype=FLOAT) - cdef INT_T i, j - for i in prange(self.n, nogil=True): - xi = _Site(i, &info) - e = xi.edge(&xi) + cdef INT_T i, j + for i in prange(self.n, nogil=True): + xi = _Site(i, &info) + e = xi.edge(&xi) - j = 0 - while j < xi.edge_num(&xi): # Looping through site edges. - dedxi_p = e.cache.ya(&e, NAN_VECTOR) - dedxi_p.self.smul( - &dedxi_p, - e.cache.calI(&e, NAN) / e.cache.ya_mag(&e, NAN) - ) + j = 0 + while j < xi.edge_num(&xi): # Looping through site edges. + dedxi_p = e.cache.ya(&e, NAN_VECTOR) + dedxi_p.self.smul( + &dedxi_p, + e.cache.calI(&e, NAN) / e.cache.ya_mag(&e, NAN) + ) - dedx[i][0] += 2*self.r*dedxi_p.x - dedx[i][1] += 2*self.r*dedxi_p.y + dedx[i][0] += 2*self.r*dedxi_p.x + dedx[i][1] += 2*self.r*dedxi_p.y - e = e.next(&e) - j = j + 1 + e = e.next(&e) + j = j + 1 - self.grad = dedx + self.grad = dedx + + cdef void calc_hess(self) except *: + cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, + self.vertices, self.site_cache, + self.edge_cache, self.edge_cache_map) + cdef Site xi, xk + cdef HalfEdge em, e, ep, f + cdef Vector2D temp1, temp2 + cdef Matrix2x2 dsite, q, tempm + cdef BitSet edge_set + + cdef INT_T num_edges = self.edges.shape[0] + + cdef FLOAT_T [:,:] HE = np.zeros((2*self.n, 2*self.n)) + + cdef INT_T i, j, k + for i in prange(self.sites.shape[0], nogil=True): + xi = _Site(i, &info) + e = xi.edge(&xi) + + j = 0 + while j < xi.edge_num(&xi): + em, ep = e.prev(&e), e.next(&e) + e.cache.H(&e, VoronoiContainer.calc_H(em, e)) + + e = e.next(&e) + j = j + 1 + + + for i in range(self.n): + xi = _Site(i, &info) + e = xi.edge(&xi) + edge_set = _BitSet(num_edges) + + j = 0 + while j < xi.edge_num(&xi): + em, ep = e.prev(&e), e.next(&e) + + # Calculating of p + temp1 = em.cache.la(&em, NAN_VECTOR) + temp1.self.rot(&temp1) + temp1.self.sdiv( + &temp1, + em.cache.la_mag(&em, NAN) * em.cache.ya_mag(&em, NAN) / 2 + ) + temp2 = e.cache.la(&e, NAN_VECTOR) + temp2.self.rot(&temp2) + temp2.self.sdiv( + &temp2, + e.cache.la_mag(&e, NAN) * e.cache.ya_mag(&e, NAN) / 2 + ) + + temp1.self.vsub(&temp1, temp2) # (lm/Am - l/A) + + temp2 = e.cache.da(&e, NAN_VECTOR) # rot(d) / |d| + temp2.self.sdiv(&temp2, e.cache.da_mag(&e, NAN)) + temp2.self.rot(&temp2) + + dsite = temp1.vecmul(&temp1, temp2) + + HE[2*i, 2*i] -= dsite.a + HE[2*i, 2*i+1] -= dsite.b + HE[2*i+1, 2*i] -= dsite.c + HE[2*i+1, 2*i+1] -= dsite.d + + # Calculating of q + temp2 = e.cache.la(&e, NAN_VECTOR) + temp1 = temp2.copy.rot(&temp2) + q = temp1.vecmul(&temp1, temp2) + q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) + + q.self.msub(&q, R) + q.self.smul( + &q, + e.cache.calI(&e, NAN) / e.cache.la_mag(&e, NAN) + ) + + temp1 = e.cache.la(&e, NAN_VECTOR) + temp1.self.rot(&temp1) + tempm = temp1.vecmul(&temp1, temp1) + tempm.self.smul( + &tempm, + ep.cache.da_mag(&ep, NAN) - e.cache.da_mag(&e, NAN) + ) + tempm.self.sdiv( + &tempm, + e.cache.la_mag(&e, NAN)**3 * e.cache.ya_mag(&e, NAN) / 2 + ) + + q.self.madd(&q, tempm) + + # Minus portion + temp2 = em.cache.la(&em, NAN_VECTOR) + temp1 = temp2.copy.rot(&temp2) + tempm = temp1.vecmul(&temp1, temp2) + tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) + + tempm = R.copy.msub(&R, tempm) + tempm.self.smul( + &tempm, + em.cache.calI(&em, NAN) / em.cache.la_mag(&em, NAN) + ) + + q.self.madd(&q, tempm) + + temp1 = em.cache.la(&em, NAN_VECTOR) + temp1.self.rot(&temp1) + tempm = temp1.vecmul(&temp1, temp1) + tempm.self.smul( + &tempm, + e.cache.da_mag(&e, NAN) - em.cache.da_mag(&em, NAN) + ) + tempm.self.sdiv( + &tempm, + em.cache.la_mag(&em, NAN)**3 * em.cache.ya_mag(&em, NAN) / 2 + ) + + q.self.msub(&q, tempm) + + # Add p to q, so p = p, q = p+q + q.self.madd(&q, dsite) + + f = e + while True: + xk = f.face(&f) + k = xk.index(&xk) % self.n + if k < 0: + k = k + self.n + + if not edge_set.add(&edge_set, f.arr_index): + tempm = q.copy.matmul(&q, f.cache.H(&f, NAN_MATRIX)) + + HE[2*i, 2*k] += tempm.a + HE[2*i, 2*k+1] += tempm.b + HE[2*i+1, 2*k] += tempm.c + HE[2*i+1, 2*k+1] += tempm.d + + f = f.twin(&f) + f = f.next(&f) + if f.arr_index == e.arr_index: + break + + e = e.next(&e) + j = j + 1 + edge_set.free(&edge_set) + self.hess = -2*self.r*np.asarray(HE, dtype=FLOAT) + self.hess = ( + ( np.asarray(self.hess, dtype=FLOAT) + + np.asarray(self.hess, dtype=FLOAT).T ) + / 2 + ) diff --git a/squish/ordered.py b/squish/ordered.py index d8a8aa6..0fa581f 100644 --- a/squish/ordered.py +++ b/squish/ordered.py @@ -2,11 +2,21 @@ from __future__ import annotations from typing import List, Tuple import numpy as np from numpy.linalg import norm as mag -from math import gcd, sqrt, log, tan, atan, pi +from math import gcd, sqrt, log, tan, atan, atanh, pi +import cmath +from fractions import Fraction Config = Tuple[int, int] +def e_hex(domain: DomainParams) -> float: + return ( + 2 + - 2 * domain.r * (6 * 3 ** (-0.25) * sqrt(2) * atanh(0.5)) + + 2 * pi * domain.r ** 2 + ) + + def configurations(domain: DomainParams) -> List[Config]: n = domain.n coprimes, valid = [], [] @@ -25,6 +35,9 @@ def configurations(domain: DomainParams) -> List[Config]: except KeyError: pass + for i in range(len(valid)): + valid.append((valid[i][1], valid[i][0])) + return valid @@ -106,3 +119,71 @@ def rot(v: numpy.ndarray) -> numpy.ndarray: w = np.copy(v) w[0], w[1] = -w[1], w[0] return w + + +def divisors(n: int) -> List[int]: + divs = [[i, n // i] for i in range(1, int(sqrt(n)) + 1) if n % i == 0] + return sorted(set(list(sum(divs, [])))) + + +def factorize(n: int) -> Dict[int, int]: + primes = [i for i in range(1, n + 1) if len(divisors(i)) == 2] + prime_fac = {} + for prime in primes: + i = 0 + while n % prime ** (i + 1) == 0: + i += 1 + if i > 0: + prime_fac[prime] = i + + return prime_fac + + +def hexagon_alpha(n: int, fraction: bool = False) -> List[int]: + if n % 2 == 1: + return [] + + fac = factorize(n) + q = 1 + for prime in fac: + if prime % 3 != 2: + q *= prime ** fac[prime] + + divq = divisors(q) + ratios, thres = [], 1 / sqrt(3) + for g in divq: + us = n // (2 * g) + divu = divisors(us) + for u in divu: + d = 2 * g * u * u + f = Fraction(n, d) + if f <= thres: + ratios.append(f) + else: + ratios.append(Fraction(d, 3 * n)) + + ratios = sorted(set(ratios)) + if fraction: + return ratios + else: + return [float(x) * sqrt(3) for x in ratios] + + +def hexagon_alpha_brute(n: int): + w = cmath.rect(1, 2 * pi / 3) + divs = divisors(n / 2) + ratios, thres = [], 1 / sqrt(3) + for a in range(n): + for b in range(1, a + 1): + if a == 0 and b == 0: + continue + z2, g = a * a - a * b + b * b, gcd(a - 2 * b, 2 * a - b) + if z2 // g in divs: + f = Fraction(n, 2 * z2) + if f <= thres: + ratios.append(f) + else: + ratios.append(Fraction(2 * z2, 3 * n)) + + ratios = sorted(set([float(x) * sqrt(3) for x in ratios])) + return ratios diff --git a/squish/simulation.py b/squish/simulation.py index dde2ef1..c6271aa 100644 --- a/squish/simulation.py +++ b/squish/simulation.py @@ -159,6 +159,7 @@ class Simulation: sim, frames = Simulation.load(path) for frame in frames: sim.frames.append(sim.energy.mode(*frame["domain"], frame["arr"])) + sim.frames[-1].stats = frame["stats"] return sim @@ -238,8 +239,8 @@ class Flow(Simulation): if self.adaptive: error = change - grad * self.step_size - tol = 10 ** min(-3, -2 + log10(grad_norm)) - + tol = 10 ** min(-4, -3 + log10(grad_norm)) + # tol = 10 ** -7 self.step_size *= (tol / np.linalg.norm(error)) ** 0.5 if not save: @@ -315,7 +316,7 @@ class Search(Simulation): new_sites: Optional[numpy.ndarray] = None, ) -> None: if log: - print(f"Travel - {self.domain}", flush=True) + print(f"Search - {self.domain} - {len(self)}", flush=True) if save and len(self) == 0: self.save(self.initial_data, True) @@ -328,16 +329,15 @@ class Search(Simulation): sim.run(False, log, log_steps) self.frames.append(sim[-1]) + # Get Hessian,and check nullity. If > 2, perturb. + hess = self.frames[i].hessian + eigs = np.sort(np.linalg.eig(hess)[0]) + self.frames[i].stats["eigs"] = eigs + if save: self.save(self.frame_data(i)) if log: print(f"Equilibrium: {i:04}\n", flush=True) - - # Get Hessian,and check nullity. If > 2, perturb. - hess = self.frames[i].hessian(10e-5) - eigs = np.sort(np.linalg.eig(hess)[0]) - self.frames[i].stats["eigs"] = eigs - zero_eigs = np.count_nonzero( np.isclose(eigs, np.zeros((len(eigs),)), atol=1e-4) ) diff --git a/squish/voronoi.c b/squish/voronoi.c index 248edc7..e93cf71 100644 --- a/squish/voronoi.c +++ b/squish/voronoi.c @@ -1430,10 +1430,11 @@ typedef __pyx_t_6squish_4core_Matrix2x2 (*__pyx_t_6squish_4core_MatrixCopySclOp) * * ctypedef struct VectorSelfOps: # <<<<<<<<<<<<<< * Vector2D* (*neg)(Vector2D*) nogil - * + * Vector2D* (*rot)(Vector2D*) nogil */ struct __pyx_t_6squish_4core_VectorSelfOps { __pyx_t_6squish_4core_Vector2D *(*neg)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Vector2D *(*rot)(__pyx_t_6squish_4core_Vector2D *); __pyx_t_6squish_4core_VectorSelfVecOp vadd; __pyx_t_6squish_4core_VectorSelfVecOp vsub; __pyx_t_6squish_4core_VectorSelfVecOp vmul; @@ -1445,15 +1446,16 @@ struct __pyx_t_6squish_4core_VectorSelfOps { __pyx_t_6squish_4core_VectorSelfSclOp sdiv; }; -/* "squish/core.pxd":67 +/* "squish/core.pxd":68 * * * ctypedef struct VectorCopyOps: # <<<<<<<<<<<<<< * Vector2D (*neg)(Vector2D*) nogil - * + * Vector2D (*rot)(Vector2D*) nogil */ struct __pyx_t_6squish_4core_VectorCopyOps { __pyx_t_6squish_4core_Vector2D (*neg)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Vector2D (*rot)(__pyx_t_6squish_4core_Vector2D *); __pyx_t_6squish_4core_VectorCopyVecOp vadd; __pyx_t_6squish_4core_VectorCopyVecOp vsub; __pyx_t_6squish_4core_VectorCopyVecOp vmul; @@ -1465,15 +1467,16 @@ struct __pyx_t_6squish_4core_VectorCopyOps { __pyx_t_6squish_4core_VectorCopySclOp sdiv; }; -/* "squish/core.pxd":82 +/* "squish/core.pxd":84 * * * ctypedef struct MatrixSelfOps: # <<<<<<<<<<<<<< * Matrix2x2* (*neg)(Matrix2x2*) nogil - * + * Matrix2x2* (*T)(Matrix2x2*) nogil */ struct __pyx_t_6squish_4core_MatrixSelfOps { __pyx_t_6squish_4core_Matrix2x2 *(*neg)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 *(*T)(__pyx_t_6squish_4core_Matrix2x2 *); __pyx_t_6squish_4core_MatrixSelfMatOp madd; __pyx_t_6squish_4core_MatrixSelfMatOp msub; __pyx_t_6squish_4core_MatrixSelfMatOp mmul; @@ -1485,15 +1488,16 @@ struct __pyx_t_6squish_4core_MatrixSelfOps { __pyx_t_6squish_4core_MatrixSelfSclOp sdiv; }; -/* "squish/core.pxd":97 +/* "squish/core.pxd":100 * * * ctypedef struct MatrixCopyOps: # <<<<<<<<<<<<<< * Matrix2x2 (*neg)(Matrix2x2*) nogil - * + * Matrix2x2 (*T)(Matrix2x2*) nogil */ struct __pyx_t_6squish_4core_MatrixCopyOps { __pyx_t_6squish_4core_Matrix2x2 (*neg)(__pyx_t_6squish_4core_Matrix2x2 *); + __pyx_t_6squish_4core_Matrix2x2 (*T)(__pyx_t_6squish_4core_Matrix2x2 *); __pyx_t_6squish_4core_MatrixCopyMatOp madd; __pyx_t_6squish_4core_MatrixCopyMatOp msub; __pyx_t_6squish_4core_MatrixCopyMatOp mmul; @@ -1505,7 +1509,7 @@ struct __pyx_t_6squish_4core_MatrixCopyOps { __pyx_t_6squish_4core_MatrixCopySclOp sdiv; }; -/* "squish/core.pxd":112 +/* "squish/core.pxd":116 * * # Psuedo-class for a 2-dimensional vector. No orientation. * ctypedef struct Vector2D: # <<<<<<<<<<<<<< @@ -1518,12 +1522,12 @@ struct __pyx_t_6squish_4core_Vector2D { __pyx_t_6squish_4core_VectorSelfOps self; __pyx_t_6squish_4core_VectorCopyOps copy; int (*equals)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); - __pyx_t_6squish_4core_Vector2D (*rot)(__pyx_t_6squish_4core_Vector2D *); + __pyx_t_6squish_4core_Matrix2x2 (*vecmul)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*dot)(__pyx_t_6squish_4core_Vector2D *, __pyx_t_6squish_4core_Vector2D); __pyx_t_6squish_4core_FLOAT_T (*mag)(__pyx_t_6squish_4core_Vector2D *); }; -/* "squish/core.pxd":123 +/* "squish/core.pxd":127 * * # Psuedo-class for a 2x2 matrix. * ctypedef struct Matrix2x2: # <<<<<<<<<<<<<< @@ -1680,6 +1684,7 @@ struct __pyx_obj_6squish_7voronoi_VoronoiContainer { __Pyx_memviewslice site_cache; __Pyx_memviewslice edge_cache; __Pyx_memviewslice grad; + __Pyx_memviewslice hess; __Pyx_memviewslice sites; __Pyx_memviewslice edges; __pyx_t_6squish_7voronoi_EdgeCacheMap *edge_cache_map; @@ -1779,6 +1784,7 @@ struct __pyx_vtabstruct_6squish_7voronoi_VoronoiContainer { void (*common_cache)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); void (*precompute)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); void (*calc_grad)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); + void (*calc_hess)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); void (*get_statistics)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *); __pyx_t_6squish_4core_Matrix2x2 (*calc_H)(__pyx_t_6squish_7voronoi_HalfEdge, __pyx_t_6squish_7voronoi_HalfEdge); int (*sign)(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice); @@ -2218,21 +2224,6 @@ static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long in (inplace ? PyNumber_InPlaceRemainder(op1, op2) : PyNumber_Remainder(op1, op2)) #endif -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyInt_TrueDivideObjC(op1, op2, intval, inplace, zerodivision_check)\ - (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2)) -#endif - /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { @@ -2813,6 +2804,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_7voronoi_16 static CYTHON_INLINE int __pyx_f_6squish_7voronoi_16VoronoiContainer_sign(__Pyx_memviewslice __pyx_v_ref, __Pyx_memviewslice __pyx_v_p, __Pyx_memviewslice __pyx_v_q); /* proto*/ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_precompute(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto*/ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_calc_grad(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto*/ +static void __pyx_f_6squish_7voronoi_16VoronoiContainer_calc_hess(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto*/ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_get_statistics(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto*/ static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/ static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/ @@ -2930,6 +2922,7 @@ static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; /* Module declarations from 'squish.core' */ static struct __pyx_t_6squish_4core_IArray (*__pyx_f_6squish_4core__IArray)(__pyx_t_6squish_4core_INT_T *, __pyx_t_6squish_4core_Pair); /*proto*/ static __pyx_t_6squish_4core_FArray (*__pyx_f_6squish_4core__FArray)(__pyx_t_6squish_4core_FLOAT_T *, __pyx_t_6squish_4core_Pair); /*proto*/ +static __pyx_t_6squish_4core_BitSet (*__pyx_f_6squish_4core__BitSet)(__pyx_t_6squish_4core_INT_T); /*proto*/ static __pyx_t_6squish_4core_Vector2D (*__pyx_f_6squish_4core__Vector2D)(__pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ static __pyx_t_6squish_4core_Matrix2x2 (*__pyx_f_6squish_4core__Matrix2x2)(__pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T); /*proto*/ @@ -3057,11 +3050,11 @@ static const char __pyx_k_get[] = "get"; static const char __pyx_k_new[] = "__new__"; static const char __pyx_k_obj[] = "obj"; static const char __pyx_k_base[] = "base"; -static const char __pyx_k_copy[] = "copy"; static const char __pyx_k_dict[] = "__dict__"; static const char __pyx_k_flip[] = "flip"; static const char __pyx_k_isin[] = "isin"; static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_math[] = "math"; static const char __pyx_k_mode[] = "mode"; static const char __pyx_k_name[] = "name"; static const char __pyx_k_ndim[] = "ndim"; @@ -3104,7 +3097,6 @@ static const char __pyx_k_unpack[] = "unpack"; static const char __pyx_k_update[] = "update"; static const char __pyx_k_Voronoi[] = "Voronoi"; static const char __pyx_k_asarray[] = "asarray"; -static const char __pyx_k_flatten[] = "flatten"; static const char __pyx_k_float64[] = "float64"; static const char __pyx_k_fortran[] = "fortran"; static const char __pyx_k_memview[] = "memview"; @@ -3232,7 +3224,6 @@ static PyObject *__pyx_n_s_class; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_kp_s_contiguous_and_direct; static PyObject *__pyx_kp_s_contiguous_and_indirect; -static PyObject *__pyx_n_s_copy; static PyObject *__pyx_n_s_dict; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_dtype_is_object; @@ -3243,7 +3234,6 @@ static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_error; static PyObject *__pyx_n_s_extend; static PyObject *__pyx_n_s_flags; -static PyObject *__pyx_n_s_flatten; static PyObject *__pyx_n_s_flip; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_format; @@ -3262,6 +3252,7 @@ static PyObject *__pyx_n_u_isoparam_avg; static PyObject *__pyx_n_s_itemsize; static PyObject *__pyx_kp_s_itemsize_0_for_cython_array; static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_math; static PyObject *__pyx_n_s_memview; static PyObject *__pyx_n_s_mode; static PyObject *__pyx_n_s_n; @@ -3336,18 +3327,17 @@ static int __pyx_pf_6squish_7voronoi_16VoronoiContainer___init__(struct __pyx_ob static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8site_arr___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8vor_data___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8gradient___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_7hessian___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_2add_sites(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, PyObject *__pyx_v_add); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, __pyx_t_6squish_4core_FLOAT_T __pyx_v_step); /* proto */ -static PyArrayObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_6approx_hessian(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, double __pyx_v_d); /* proto */ -static PyArrayObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8radialt_hessian(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_6site_vert_arr(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_1n___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_1w___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_1h___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_1r___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_6energy___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags); /* proto */ static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ @@ -9020,7 +9010,7 @@ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_common_cache(struct __py * # vp - vm, vm - xi * la, da = q.copy.vsub(&q, p), p.copy.vsub(&p, xi.vec(&xi)) # <<<<<<<<<<<<<< * la_mag = la.mag(&la) - * area_p = la.dot(&la, da.rot(&da)) + * area_p = la.dot(&la, da.copy.rot(&da)) */ __pyx_t_11 = __pyx_v_q.copy.vsub((&__pyx_v_q), __pyx_v_p); __pyx_t_10 = __pyx_v_p.copy.vsub((&__pyx_v_p), __pyx_v_xi.vec((&__pyx_v_xi))); @@ -9031,32 +9021,32 @@ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_common_cache(struct __py * # vp - vm, vm - xi * la, da = q.copy.vsub(&q, p), p.copy.vsub(&p, xi.vec(&xi)) * la_mag = la.mag(&la) # <<<<<<<<<<<<<< - * area_p = la.dot(&la, da.rot(&da)) - * Rla = la.rot(&la) + * area_p = la.dot(&la, da.copy.rot(&da)) + * Rla = la.copy.rot(&la) */ __pyx_v_la_mag = __pyx_v_la.mag((&__pyx_v_la)); /* "squish/voronoi.pyx":557 * la, da = q.copy.vsub(&q, p), p.copy.vsub(&p, xi.vec(&xi)) * la_mag = la.mag(&la) - * area_p = la.dot(&la, da.rot(&da)) # <<<<<<<<<<<<<< - * Rla = la.rot(&la) + * area_p = la.dot(&la, da.copy.rot(&da)) # <<<<<<<<<<<<<< + * Rla = la.copy.rot(&la) * ya = Rla.copy.smul(&Rla, -2*area_p/la.dot(&la, la)) */ - __pyx_v_area_p = __pyx_v_la.dot((&__pyx_v_la), __pyx_v_da.rot((&__pyx_v_da))); + __pyx_v_area_p = __pyx_v_la.dot((&__pyx_v_la), __pyx_v_da.copy.rot((&__pyx_v_da))); /* "squish/voronoi.pyx":558 * la_mag = la.mag(&la) - * area_p = la.dot(&la, da.rot(&da)) - * Rla = la.rot(&la) # <<<<<<<<<<<<<< + * area_p = la.dot(&la, da.copy.rot(&da)) + * Rla = la.copy.rot(&la) # <<<<<<<<<<<<<< * ya = Rla.copy.smul(&Rla, -2*area_p/la.dot(&la, la)) * */ - __pyx_v_Rla = __pyx_v_la.rot((&__pyx_v_la)); + __pyx_v_Rla = __pyx_v_la.copy.rot((&__pyx_v_la)); /* "squish/voronoi.pyx":559 - * area_p = la.dot(&la, da.rot(&da)) - * Rla = la.rot(&la) + * area_p = la.dot(&la, da.copy.rot(&da)) + * Rla = la.copy.rot(&la) * ya = Rla.copy.smul(&Rla, -2*area_p/la.dot(&la, la)) # <<<<<<<<<<<<<< * * # Calculating centroid. @@ -9320,7 +9310,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_7voronoi_16 * xj, xk = em.cache.ya(&em, NAN_VECTOR), ep.cache.ya(&ep, NAN_VECTOR) * Rxjk = xk.copy.vsub(&xk, xj) # <<<<<<<<<<<<<< * Rxjk.self.smul(&Rxjk, 2) - * Rxjk = Rxjk.rot(&Rxjk) + * Rxjk.self.rot(&Rxjk) */ __pyx_v_Rxjk = __pyx_v_xk.copy.vsub((&__pyx_v_xk), __pyx_v_xj); @@ -9328,7 +9318,7 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_7voronoi_16 * xj, xk = em.cache.ya(&em, NAN_VECTOR), ep.cache.ya(&ep, NAN_VECTOR) * Rxjk = xk.copy.vsub(&xk, xj) * Rxjk.self.smul(&Rxjk, 2) # <<<<<<<<<<<<<< - * Rxjk = Rxjk.rot(&Rxjk) + * Rxjk.self.rot(&Rxjk) * */ (void)(__pyx_v_Rxjk.self.smul((&__pyx_v_Rxjk), 2.0)); @@ -9336,14 +9326,14 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_7voronoi_16 /* "squish/voronoi.pyx":594 * Rxjk = xk.copy.vsub(&xk, xj) * Rxjk.self.smul(&Rxjk, 2) - * Rxjk = Rxjk.rot(&Rxjk) # <<<<<<<<<<<<<< + * Rxjk.self.rot(&Rxjk) # <<<<<<<<<<<<<< * * v = ep.cache.da(&ep, NAN_VECTOR) */ - __pyx_v_Rxjk = __pyx_v_Rxjk.rot((&__pyx_v_Rxjk)); + (void)(__pyx_v_Rxjk.self.rot((&__pyx_v_Rxjk))); /* "squish/voronoi.pyx":596 - * Rxjk = Rxjk.rot(&Rxjk) + * Rxjk.self.rot(&Rxjk) * * v = ep.cache.da(&ep, NAN_VECTOR) # <<<<<<<<<<<<<< * top = R.copy.smul(&R, xj.dot(&xj, xj) - xk.dot(&xk, xk)) @@ -9374,18 +9364,18 @@ static CYTHON_INLINE __pyx_t_6squish_4core_Matrix2x2 __pyx_f_6squish_7voronoi_16 * top.self.msub(&top, _Matrix2x2(v.x*Rxjk.x, v.x*Rxjk.y, v.y*Rxjk.x, v.y*Rxjk.y)) * top.self.sdiv(&top, -Rxjk.dot(&Rxjk, xj)) # <<<<<<<<<<<<<< * - * return _Matrix2x2(top.a, top.c, top.b, top.d) + * return top */ (void)(__pyx_v_top.self.sdiv((&__pyx_v_top), (-__pyx_v_Rxjk.dot((&__pyx_v_Rxjk), __pyx_v_xj)))); /* "squish/voronoi.pyx":601 * top.self.sdiv(&top, -Rxjk.dot(&Rxjk, xj)) * - * return _Matrix2x2(top.a, top.c, top.b, top.d) # <<<<<<<<<<<<<< + * return top # <<<<<<<<<<<<<< * * @staticmethod */ - __pyx_r = __pyx_f_6squish_4core__Matrix2x2(__pyx_v_top.a, __pyx_v_top.c, __pyx_v_top.b, __pyx_v_top.d); + __pyx_r = __pyx_v_top; goto __pyx_L0; /* "squish/voronoi.pyx":587 @@ -9503,6 +9493,22 @@ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_calc_grad(CYTHON_UNUSED } /* "squish/voronoi.pyx":624 + * pass + * + * cdef void calc_hess(self) except *: # <<<<<<<<<<<<<< + * pass + * + */ + +static void __pyx_f_6squish_7voronoi_16VoronoiContainer_calc_hess(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("calc_hess", 0); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "squish/voronoi.pyx":627 * pass * * cdef void get_statistics(self) except *: # <<<<<<<<<<<<<< @@ -9531,26 +9537,26 @@ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_get_statistics(struct __ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_statistics", 0); - /* "squish/voronoi.pyx":625 + /* "squish/voronoi.pyx":628 * * cdef void get_statistics(self) except *: * self.stats = {} # <<<<<<<<<<<<<< * cache = self.site_cache[:self.n, :] * */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats, __pyx_t_1) < 0) __PYX_ERR(0, 625, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats, __pyx_t_1) < 0) __PYX_ERR(0, 628, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "squish/voronoi.pyx":626 + /* "squish/voronoi.pyx":629 * cdef void get_statistics(self) except *: * self.stats = {} * cache = self.site_cache[:self.n, :] # <<<<<<<<<<<<<< * * self.stats["site_areas"] = np.asarray(cache[:, SITE_CACHE_MAP.iarea]) */ - if (unlikely(!__pyx_v_self->site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 626, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 629, __pyx_L1_error)} __pyx_t_2.data = __pyx_v_self->site_cache.data; __pyx_t_2.memview = __pyx_v_self->site_cache.memview; __PYX_INC_MEMVIEW(&__pyx_t_2, 0); @@ -9569,14 +9575,14 @@ static void __pyx_f_6squish_7voronoi_16VoronoiContainer_get_statistics(struct __ 0, 1) < 0)) { - __PYX_ERR(0, 626, __pyx_L1_error) + __PYX_ERR(0, 629, __pyx_L1_error) } __pyx_t_2.shape[1] = __pyx_v_self->site_cache.shape[1]; __pyx_t_2.strides[1] = __pyx_v_self->site_cache.strides[1]; __pyx_t_2.suboffsets[1] = -1; -__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_2, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error) +__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_2, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 629, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1); __pyx_t_2.memview = NULL; @@ -9584,133 +9590,19 @@ __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_2, 2, (PyObject *(*)(char *)) __p __pyx_v_cache = __pyx_t_1; __pyx_t_1 = 0; - /* "squish/voronoi.pyx":628 + /* "squish/voronoi.pyx":631 * cache = self.site_cache[:self.n, :] * * self.stats["site_areas"] = np.asarray(cache[:, SITE_CACHE_MAP.iarea]) # <<<<<<<<<<<<<< * self.stats["site_edge_count"] = np.asarray(self.sites[:self.n, 2]) * - */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.iarea); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_INCREF(__pyx_slice__2); - __Pyx_GIVEREF(__pyx_slice__2); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__2); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_n_u_site_areas, __pyx_t_1) < 0)) __PYX_ERR(0, 628, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":629 - * - * self.stats["site_areas"] = np.asarray(cache[:, SITE_CACHE_MAP.iarea]) - * self.stats["site_edge_count"] = np.asarray(self.sites[:self.n, 2]) # <<<<<<<<<<<<<< - * - * self.stats["site_isos"] = np.asarray(cache[:, SITE_CACHE_MAP.iisoparam]) - */ - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 629, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 629, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_v_self->sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 629, __pyx_L1_error)} - __pyx_t_7.data = __pyx_v_self->sites.data; - __pyx_t_7.memview = __pyx_v_self->sites.memview; - __PYX_INC_MEMVIEW(&__pyx_t_7, 0); - __pyx_t_3 = -1; - if (unlikely(__pyx_memoryview_slice_memviewslice( - &__pyx_t_7, - __pyx_v_self->sites.shape[0], __pyx_v_self->sites.strides[0], __pyx_v_self->sites.suboffsets[0], - 0, - 0, - &__pyx_t_3, - 0, - __pyx_v_self->n, - 0, - 0, - 1, - 0, - 1) < 0)) -{ - __PYX_ERR(0, 629, __pyx_L1_error) -} - -{ - Py_ssize_t __pyx_tmp_idx = 2; - Py_ssize_t __pyx_tmp_stride = __pyx_v_self->sites.strides[1]; - __pyx_t_7.data += __pyx_tmp_idx * __pyx_tmp_stride; -} - -__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_INT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_INT_T, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 629, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); - __pyx_t_7.memview = NULL; - __pyx_t_7.data = NULL; - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 629, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 629, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_site_edge_count, __pyx_t_1) < 0)) __PYX_ERR(0, 629, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":631 - * self.stats["site_edge_count"] = np.asarray(self.sites[:self.n, 2]) - * - * self.stats["site_isos"] = np.asarray(cache[:, SITE_CACHE_MAP.iisoparam]) # <<<<<<<<<<<<<< - * self.stats["site_energies"] = np.asarray(cache[:, SITE_CACHE_MAP.ienergy]) - * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.iisoparam); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.iarea); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); @@ -9741,35 +9633,55 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_n_u_site_isos, __pyx_t_1) < 0)) __PYX_ERR(0, 631, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_n_u_site_areas, __pyx_t_1) < 0)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "squish/voronoi.pyx":632 * + * self.stats["site_areas"] = np.asarray(cache[:, SITE_CACHE_MAP.iarea]) + * self.stats["site_edge_count"] = np.asarray(self.sites[:self.n, 2]) # <<<<<<<<<<<<<< + * * self.stats["site_isos"] = np.asarray(cache[:, SITE_CACHE_MAP.iisoparam]) - * self.stats["site_energies"] = np.asarray(cache[:, SITE_CACHE_MAP.ienergy]) # <<<<<<<<<<<<<< - * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) - * self.stats["centroids"] = np.asarray( */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.ienergy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error) + if (unlikely(!__pyx_v_self->sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 632, __pyx_L1_error)} + __pyx_t_7.data = __pyx_v_self->sites.data; + __pyx_t_7.memview = __pyx_v_self->sites.memview; + __PYX_INC_MEMVIEW(&__pyx_t_7, 0); + __pyx_t_3 = -1; + if (unlikely(__pyx_memoryview_slice_memviewslice( + &__pyx_t_7, + __pyx_v_self->sites.shape[0], __pyx_v_self->sites.strides[0], __pyx_v_self->sites.suboffsets[0], + 0, + 0, + &__pyx_t_3, + 0, + __pyx_v_self->n, + 0, + 0, + 1, + 0, + 1) < 0)) +{ + __PYX_ERR(0, 632, __pyx_L1_error) +} + +{ + Py_ssize_t __pyx_tmp_idx = 2; + Py_ssize_t __pyx_tmp_stride = __pyx_v_self->sites.strides[1]; + __pyx_t_7.data += __pyx_tmp_idx * __pyx_tmp_stride; +} + +__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_INT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_INT_T, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 632, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_INCREF(__pyx_slice__2); - __Pyx_GIVEREF(__pyx_slice__2); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__2); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); + __pyx_t_7.memview = NULL; + __pyx_t_7.data = NULL; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); @@ -9788,25 +9700,25 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_site_energies, __pyx_t_1) < 0)) __PYX_ERR(0, 632, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_site_edge_count, __pyx_t_1) < 0)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "squish/voronoi.pyx":633 - * self.stats["site_isos"] = np.asarray(cache[:, SITE_CACHE_MAP.iisoparam]) + /* "squish/voronoi.pyx":634 + * self.stats["site_edge_count"] = np.asarray(self.sites[:self.n, 2]) + * + * self.stats["site_isos"] = np.asarray(cache[:, SITE_CACHE_MAP.iisoparam]) # <<<<<<<<<<<<<< * self.stats["site_energies"] = np.asarray(cache[:, SITE_CACHE_MAP.ienergy]) - * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) # <<<<<<<<<<<<<< - * self.stats["centroids"] = np.asarray( - * cache[:, SITE_CACHE_MAP.icentroid:SITE_CACHE_MAP.icentroid+2] + * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 633, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 633, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.iavg_radius); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 633, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.iisoparam); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 633, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2); @@ -9814,7 +9726,7 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 633, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; @@ -9830,44 +9742,138 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 633, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_n_u_avg_radius, __pyx_t_1) < 0)) __PYX_ERR(0, 633, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_n_u_site_isos, __pyx_t_1) < 0)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "squish/voronoi.pyx":634 + /* "squish/voronoi.pyx":635 + * + * self.stats["site_isos"] = np.asarray(cache[:, SITE_CACHE_MAP.iisoparam]) + * self.stats["site_energies"] = np.asarray(cache[:, SITE_CACHE_MAP.ienergy]) # <<<<<<<<<<<<<< + * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) + * self.stats["centroids"] = np.asarray( + */ + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.ienergy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_slice__2); + __Pyx_GIVEREF(__pyx_slice__2); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__2); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_site_energies, __pyx_t_1) < 0)) __PYX_ERR(0, 635, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "squish/voronoi.pyx":636 + * self.stats["site_isos"] = np.asarray(cache[:, SITE_CACHE_MAP.iisoparam]) + * self.stats["site_energies"] = np.asarray(cache[:, SITE_CACHE_MAP.ienergy]) + * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) # <<<<<<<<<<<<<< + * self.stats["centroids"] = np.asarray( + * cache[:, SITE_CACHE_MAP.icentroid:SITE_CACHE_MAP.icentroid+2] + */ + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.iavg_radius); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_slice__2); + __Pyx_GIVEREF(__pyx_slice__2); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__2); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_n_u_avg_radius, __pyx_t_1) < 0)) __PYX_ERR(0, 636, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "squish/voronoi.pyx":637 * self.stats["site_energies"] = np.asarray(cache[:, SITE_CACHE_MAP.ienergy]) * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) * self.stats["centroids"] = np.asarray( # <<<<<<<<<<<<<< * cache[:, SITE_CACHE_MAP.icentroid:SITE_CACHE_MAP.icentroid+2] * ) */ - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "squish/voronoi.pyx":635 + /* "squish/voronoi.pyx":638 * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) * self.stats["centroids"] = np.asarray( * cache[:, SITE_CACHE_MAP.icentroid:SITE_CACHE_MAP.icentroid+2] # <<<<<<<<<<<<<< * ) * */ - __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.icentroid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 635, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.icentroid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_From_npy_int64((__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.icentroid + 2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 635, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_npy_int64((__pyx_v_6squish_7voronoi_SITE_CACHE_MAP.icentroid + 2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = PySlice_New(__pyx_t_5, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 635, __pyx_L1_error) + __pyx_t_8 = PySlice_New(__pyx_t_5, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 635, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2); @@ -9875,7 +9881,7 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 635, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_cache, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; @@ -9891,89 +9897,89 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 634, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "squish/voronoi.pyx":634 + /* "squish/voronoi.pyx":637 * self.stats["site_energies"] = np.asarray(cache[:, SITE_CACHE_MAP.ienergy]) * self.stats["avg_radius"] = np.asarray(cache[:, SITE_CACHE_MAP.iavg_radius]) * self.stats["centroids"] = np.asarray( # <<<<<<<<<<<<<< * cache[:, SITE_CACHE_MAP.icentroid:SITE_CACHE_MAP.icentroid+2] * ) */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_centroids, __pyx_t_1) < 0)) __PYX_ERR(0, 634, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_n_u_centroids, __pyx_t_1) < 0)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "squish/voronoi.pyx":638 + /* "squish/voronoi.pyx":641 * ) * * self.stats["isoparam_avg"] = self.stats["site_areas"] / \ # <<<<<<<<<<<<<< * (PI*self.stats["avg_radius"]**2) * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 638, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_site_areas); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 638, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_site_areas); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "squish/voronoi.pyx":639 + /* "squish/voronoi.pyx":642 * * self.stats["isoparam_avg"] = self.stats["site_areas"] / \ * (PI*self.stats["avg_radius"]**2) # <<<<<<<<<<<<<< * * edges = np.asarray(self.edges) */ - __pyx_t_1 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 639, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_8, __pyx_n_u_avg_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 639, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_8, __pyx_n_u_avg_radius); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyNumber_Power(__pyx_t_6, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 639, __pyx_L1_error) + __pyx_t_8 = PyNumber_Power(__pyx_t_6, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 639, __pyx_L1_error) + __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - /* "squish/voronoi.pyx":638 + /* "squish/voronoi.pyx":641 * ) * * self.stats["isoparam_avg"] = self.stats["site_areas"] / \ # <<<<<<<<<<<<<< * (PI*self.stats["avg_radius"]**2) * */ - __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 638, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_n_u_isoparam_avg, __pyx_t_8) < 0)) __PYX_ERR(0, 638, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_n_u_isoparam_avg, __pyx_t_8) < 0)) __PYX_ERR(0, 641, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - /* "squish/voronoi.pyx":641 + /* "squish/voronoi.pyx":644 * (PI*self.stats["avg_radius"]**2) * * edges = np.asarray(self.edges) # <<<<<<<<<<<<<< * * mask = np.nonzero(edges[:, 0] != -1)[0] */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 641, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 641, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_v_self->edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 641, __pyx_L1_error)} - __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_self->edges, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_INT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_INT_T, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 641, __pyx_L1_error) + if (unlikely(!__pyx_v_self->edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 644, __pyx_L1_error)} + __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_self->edges, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_INT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_INT_T, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { @@ -9988,27 +9994,27 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __pyx_t_8 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 641, __pyx_L1_error) + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_edges = __pyx_t_8; __pyx_t_8 = 0; - /* "squish/voronoi.pyx":643 + /* "squish/voronoi.pyx":646 * edges = np.asarray(self.edges) * * mask = np.nonzero(edges[:, 0] != -1)[0] # <<<<<<<<<<<<<< * all_edges = mask[(mask % 2 == 0)] * caches = edges[all_edges, 4] */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 643, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 643, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_edges, __pyx_tuple__3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 643, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_edges, __pyx_tuple__3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyInt_NeObjC(__pyx_t_4, __pyx_int_neg_1, -1L, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_NeObjC(__pyx_t_4, __pyx_int_neg_1, -1L, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; @@ -10024,41 +10030,41 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __pyx_t_8 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 643, __pyx_L1_error) + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 643, __pyx_L1_error) + __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_mask = __pyx_t_6; __pyx_t_6 = 0; - /* "squish/voronoi.pyx":644 + /* "squish/voronoi.pyx":647 * * mask = np.nonzero(edges[:, 0] != -1)[0] * all_edges = mask[(mask % 2 == 0)] # <<<<<<<<<<<<<< * caches = edges[all_edges, 4] * */ - __pyx_t_6 = __Pyx_PyInt_RemainderObjC(__pyx_v_mask, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 644, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_RemainderObjC(__pyx_v_mask, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_6, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 644, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyInt_EqObjC(__pyx_t_6, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_mask, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 644, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_mask, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_all_edges = __pyx_t_6; __pyx_t_6 = 0; - /* "squish/voronoi.pyx":645 + /* "squish/voronoi.pyx":648 * mask = np.nonzero(edges[:, 0] != -1)[0] * all_edges = mask[(mask % 2 == 0)] * caches = edges[all_edges, 4] # <<<<<<<<<<<<<< * * edge_cache = np.asarray(self.edge_cache) */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 645, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_all_edges); __Pyx_GIVEREF(__pyx_v_all_edges); @@ -10066,26 +10072,26 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); - __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_edges, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 645, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_edges, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_caches = __pyx_t_8; __pyx_t_8 = 0; - /* "squish/voronoi.pyx":647 + /* "squish/voronoi.pyx":650 * caches = edges[all_edges, 4] * * edge_cache = np.asarray(self.edge_cache) # <<<<<<<<<<<<<< * * self.stats["edge_lengths"] = edge_cache[caches, self.edge_cache_map.ila_mag] */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 647, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_v_self->edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 647, __pyx_L1_error)} - __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_self->edge_cache, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 647, __pyx_L1_error) + if (unlikely(!__pyx_v_self->edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 650, __pyx_L1_error)} + __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_self->edge_cache, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { @@ -10100,22 +10106,22 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __pyx_t_8 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 647, __pyx_L1_error) + if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_edge_cache = __pyx_t_8; __pyx_t_8 = 0; - /* "squish/voronoi.pyx":649 + /* "squish/voronoi.pyx":652 * edge_cache = np.asarray(self.edge_cache) * * self.stats["edge_lengths"] = edge_cache[caches, self.edge_cache_map.ila_mag] # <<<<<<<<<<<<<< * * @property */ - __pyx_t_8 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->edge_cache_map->ila_mag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 649, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->edge_cache_map->ila_mag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_caches); __Pyx_GIVEREF(__pyx_v_caches); @@ -10123,16 +10129,16 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_edge_cache, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 649, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_edge_cache, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stats); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_n_u_edge_lengths, __pyx_t_8) < 0)) __PYX_ERR(0, 649, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_n_u_edge_lengths, __pyx_t_8) < 0)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - /* "squish/voronoi.pyx":624 + /* "squish/voronoi.pyx":627 * pass * * cdef void get_statistics(self) except *: # <<<<<<<<<<<<<< @@ -10161,7 +10167,7 @@ __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __p __Pyx_RefNannyFinishContext(); } -/* "squish/voronoi.pyx":652 +/* "squish/voronoi.pyx":655 * * @property * def site_arr(self): # <<<<<<<<<<<<<< @@ -10196,7 +10202,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8site_arr___get__( int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "squish/voronoi.pyx":653 + /* "squish/voronoi.pyx":656 * @property * def site_arr(self): * return np.asarray(self.points[:self.n], dtype=FLOAT) # <<<<<<<<<<<<<< @@ -10204,12 +10210,12 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8site_arr___get__( * @property */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_v_self->points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 653, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 656, __pyx_L1_error)} __pyx_t_3.data = __pyx_v_self->points.data; __pyx_t_3.memview = __pyx_v_self->points.memview; __PYX_INC_MEMVIEW(&__pyx_t_3, 0); @@ -10228,30 +10234,30 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8site_arr___get__( 0, 1) < 0)) { - __PYX_ERR(0, 653, __pyx_L1_error) + __PYX_ERR(0, 656, __pyx_L1_error) } __pyx_t_3.shape[1] = __pyx_v_self->points.shape[1]; __pyx_t_3.strides[1] = __pyx_v_self->points.strides[1]; __pyx_t_3.suboffsets[1] = -1; -__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_3, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error) +__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_3, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1); __pyx_t_3.memview = NULL; __pyx_t_3.data = NULL; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 653, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 653, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 653, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 653, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -10260,7 +10266,7 @@ __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_3, 2, (PyObject *(*)(char *)) __p __pyx_t_6 = 0; goto __pyx_L0; - /* "squish/voronoi.pyx":652 + /* "squish/voronoi.pyx":655 * * @property * def site_arr(self): # <<<<<<<<<<<<<< @@ -10283,7 +10289,7 @@ __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_t_3, 2, (PyObject *(*)(char *)) __p return __pyx_r; } -/* "squish/voronoi.pyx":656 +/* "squish/voronoi.pyx":659 * * @property * def vor_data(self): # <<<<<<<<<<<<<< @@ -10313,7 +10319,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8vor_data___get__( int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "squish/voronoi.pyx":657 + /* "squish/voronoi.pyx":660 * @property * def vor_data(self): * return self.scipy_vor # <<<<<<<<<<<<<< @@ -10321,13 +10327,13 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8vor_data___get__( * @property */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_scipy_vor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_scipy_vor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "squish/voronoi.pyx":656 + /* "squish/voronoi.pyx":659 * * @property * def vor_data(self): # <<<<<<<<<<<<<< @@ -10346,7 +10352,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8vor_data___get__( return __pyx_r; } -/* "squish/voronoi.pyx":660 +/* "squish/voronoi.pyx":663 * * @property * def gradient(self): # <<<<<<<<<<<<<< @@ -10379,34 +10385,34 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8gradient___get__( int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "squish/voronoi.pyx":661 + /* "squish/voronoi.pyx":664 * @property * def gradient(self): * return np.asarray(self.grad, dtype=FLOAT) # <<<<<<<<<<<<<< * - * def add_sites(self, add): + * @property */ __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_v_self->grad.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 661, __pyx_L1_error)} - __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_self->grad, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error) + if (unlikely(!__pyx_v_self->grad.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 664, __pyx_L1_error)} + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_self->grad, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 661, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 661, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 661, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 661, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10415,7 +10421,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8gradient___get__( __pyx_t_4 = 0; goto __pyx_L0; - /* "squish/voronoi.pyx":660 + /* "squish/voronoi.pyx":663 * * @property * def gradient(self): # <<<<<<<<<<<<<< @@ -10437,8 +10443,108 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8gradient___get__( return __pyx_r; } -/* "squish/voronoi.pyx":663 - * return np.asarray(self.grad, dtype=FLOAT) +/* "squish/voronoi.pyx":667 + * + * @property + * def hessian(self): # <<<<<<<<<<<<<< + * self.calc_hess() + * return np.asarray(self.hess, dtype=FLOAT) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_7hessian_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_7hessian_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_7hessian___get__(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_7hessian___get__(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "squish/voronoi.pyx":668 + * @property + * def hessian(self): + * self.calc_hess() # <<<<<<<<<<<<<< + * return np.asarray(self.hess, dtype=FLOAT) + * + */ + ((struct __pyx_vtabstruct_6squish_7voronoi_VoronoiContainer *)__pyx_v_self->__pyx_vtab)->calc_hess(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 668, __pyx_L1_error) + + /* "squish/voronoi.pyx":669 + * def hessian(self): + * self.calc_hess() + * return np.asarray(self.hess, dtype=FLOAT) # <<<<<<<<<<<<<< + * + * def add_sites(self, add): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (unlikely(!__pyx_v_self->hess.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 669, __pyx_L1_error)} + __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_self->hess, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_6squish_4core_FLOAT_T, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_6squish_4core_FLOAT_T, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 669, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + + /* "squish/voronoi.pyx":667 + * + * @property + * def hessian(self): # <<<<<<<<<<<<<< + * self.calc_hess() + * return np.asarray(self.hess, dtype=FLOAT) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("squish.voronoi.VoronoiContainer.hessian.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "squish/voronoi.pyx":671 + * return np.asarray(self.hess, dtype=FLOAT) * * def add_sites(self, add): # <<<<<<<<<<<<<< * return (self.site_arr + add) % np.asarray(self.dim, dtype=FLOAT) @@ -10471,7 +10577,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_2add_sites(struct int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_sites", 0); - /* "squish/voronoi.pyx":664 + /* "squish/voronoi.pyx":672 * * def add_sites(self, add): * return (self.site_arr + add) % np.asarray(self.dim, dtype=FLOAT) # <<<<<<<<<<<<<< @@ -10479,35 +10585,35 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_2add_sites(struct * def iterate(self, FLOAT_T step): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_site_arr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_site_arr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_add); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_add); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_carray_to_py___pyx_t_6squish_4core_FLOAT_T(__pyx_v_self->dim, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_1 = __Pyx_carray_to_py___pyx_t_6squish_4core_FLOAT_T(__pyx_v_self->dim, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 664, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 664, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) + __pyx_t_1 = PyNumber_Remainder(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -10515,8 +10621,8 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_2add_sites(struct __pyx_t_1 = 0; goto __pyx_L0; - /* "squish/voronoi.pyx":663 - * return np.asarray(self.grad, dtype=FLOAT) + /* "squish/voronoi.pyx":671 + * return np.asarray(self.hess, dtype=FLOAT) * * def add_sites(self, add): # <<<<<<<<<<<<<< * return (self.site_arr + add) % np.asarray(self.dim, dtype=FLOAT) @@ -10538,7 +10644,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_2add_sites(struct return __pyx_r; } -/* "squish/voronoi.pyx":666 +/* "squish/voronoi.pyx":674 * return (self.site_arr + add) % np.asarray(self.dim, dtype=FLOAT) * * def iterate(self, FLOAT_T step): # <<<<<<<<<<<<<< @@ -10557,7 +10663,7 @@ static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_5iterate(PyObject __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("iterate (wrapper)", 0); assert(__pyx_arg_step); { - __pyx_v_step = __pyx_PyFloat_AsDouble(__pyx_arg_step); if (unlikely((__pyx_v_step == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) + __pyx_v_step = __pyx_PyFloat_AsDouble(__pyx_arg_step); if (unlikely((__pyx_v_step == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 674, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -10593,48 +10699,48 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("iterate", 0); - /* "squish/voronoi.pyx":667 + /* "squish/voronoi.pyx":675 * * def iterate(self, FLOAT_T step): * k1 = self.gradient # <<<<<<<<<<<<<< * k2 = self.__class__(self.n, self.w, self.h, self.r, * self.add_sites(step*k1) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_gradient); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_gradient); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_k1 = __pyx_t_1; __pyx_t_1 = 0; - /* "squish/voronoi.pyx":668 + /* "squish/voronoi.pyx":676 * def iterate(self, FLOAT_T step): * k1 = self.gradient * k2 = self.__class__(self.n, self.w, self.h, self.r, # <<<<<<<<<<<<<< * self.add_sites(step*k1) * ).gradient */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->w); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - /* "squish/voronoi.pyx":669 + /* "squish/voronoi.pyx":677 * k1 = self.gradient * k2 = self.__class__(self.n, self.w, self.h, self.r, * self.add_sites(step*k1) # <<<<<<<<<<<<<< * ).gradient * */ - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_sites); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_sites); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = PyFloat_FromDouble(__pyx_v_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_9 = PyFloat_FromDouble(__pyx_v_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyNumber_Multiply(__pyx_t_9, __pyx_v_k1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_10 = PyNumber_Multiply(__pyx_t_9, __pyx_v_k1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; @@ -10650,7 +10756,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 669, __pyx_L1_error) + if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; @@ -10668,7 +10774,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_8, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10681,7 +10787,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[6] = {__pyx_t_8, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10692,7 +10798,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ } else #endif { - __pyx_t_10 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_10 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; @@ -10712,44 +10818,44 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "squish/voronoi.pyx":670 + /* "squish/voronoi.pyx":678 * k2 = self.__class__(self.n, self.w, self.h, self.r, * self.add_sites(step*k1) * ).gradient # <<<<<<<<<<<<<< * * return -(step/2)*(k1+k2), -k1 */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_gradient); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_gradient); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_k2 = __pyx_t_2; __pyx_t_2 = 0; - /* "squish/voronoi.pyx":672 + /* "squish/voronoi.pyx":680 * ).gradient * * return -(step/2)*(k1+k2), -k1 # <<<<<<<<<<<<<< * - * + * def site_vert_arr(self): # -> List[np.ndarray] */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyFloat_FromDouble((-(__pyx_v_step / 2.0))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-(__pyx_v_step / 2.0))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyNumber_Add(__pyx_v_k1, __pyx_v_k2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_1 = PyNumber_Add(__pyx_v_k1, __pyx_v_k2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_10 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Negative(__pyx_v_k1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_1 = PyNumber_Negative(__pyx_v_k1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10); @@ -10761,7 +10867,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ __pyx_t_2 = 0; goto __pyx_L0; - /* "squish/voronoi.pyx":666 + /* "squish/voronoi.pyx":674 * return (self.site_arr + add) % np.asarray(self.dim, dtype=FLOAT) * * def iterate(self, FLOAT_T step): # <<<<<<<<<<<<<< @@ -10791,1815 +10897,8 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_4iterate(struct __ return __pyx_r; } -/* "squish/voronoi.pyx":675 - * - * - * def approx_hessian(self, d: float) -> np.ndarray: # <<<<<<<<<<<<<< - * """ - * Obtains the approximate Hessian. - */ - -/* Python wrapper */ -static PyArrayObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_7approx_hessian(PyObject *__pyx_v_self, PyObject *__pyx_arg_d); /*proto*/ -static char __pyx_doc_6squish_7voronoi_16VoronoiContainer_6approx_hessian[] = "\n Obtains the approximate Hessian.\n :param d: [float] small d for approximation.\n :return: 2Nx2N array that represents Hessian.\n "; -static PyArrayObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_7approx_hessian(PyObject *__pyx_v_self, PyObject *__pyx_arg_d) { - double __pyx_v_d; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyArrayObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("approx_hessian (wrapper)", 0); - assert(__pyx_arg_d); { - __pyx_v_d = __pyx_PyFloat_AsDouble(__pyx_arg_d); if (unlikely((__pyx_v_d == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 675, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L3_error:; - __Pyx_AddTraceback("squish.voronoi.VoronoiContainer.approx_hessian", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_6approx_hessian(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self), ((double)__pyx_v_d)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyArrayObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_6approx_hessian(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, double __pyx_v_d) { - PyObject *__pyx_v_HE = NULL; - PyObject *__pyx_v_new_sites = NULL; - PyObject *__pyx_v_i = NULL; - PyObject *__pyx_v_j = NULL; - PyObject *__pyx_v_mod = NULL; - PyObject *__pyx_v_Ep = NULL; - PyObject *__pyx_v_Em = NULL; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - Py_ssize_t __pyx_t_6; - PyObject *(*__pyx_t_7)(PyObject *); - long __pyx_t_8; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - int __pyx_t_13; - PyObject *__pyx_t_14 = NULL; - Py_ssize_t __pyx_t_15; - PyObject *(*__pyx_t_16)(PyObject *); - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("approx_hessian", 0); - - /* "squish/voronoi.pyx":681 - * :return: 2Nx2N array that represents Hessian. - * """ - * HE = np.zeros((2*self.n, 2*self.n)) # <<<<<<<<<<<<<< - * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. - * for i in range(self.n): - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->n)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); - __pyx_t_2 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_HE = __pyx_t_1; - __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":682 - * """ - * HE = np.zeros((2*self.n, 2*self.n)) - * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. # <<<<<<<<<<<<<< - * for i in range(self.n): - * for j in range(2): - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_site_arr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_new_sites = __pyx_t_1; - __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":683 - * HE = np.zeros((2*self.n, 2*self.n)) - * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. - * for i in range(self.n): # <<<<<<<<<<<<<< - * for j in range(2): - * mod = self.w if j == 0 else self.h - */ - __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 683, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { - __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; - __pyx_t_7 = NULL; - } else { - __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 683, __pyx_L1_error) - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - for (;;) { - if (likely(!__pyx_t_7)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 683, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 683, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 683, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 683, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_7(__pyx_t_1); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 683, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_5); - } - __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5); - __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":684 - * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. - * for i in range(self.n): - * for j in range(2): # <<<<<<<<<<<<<< - * mod = self.w if j == 0 else self.h - * new_sites[i][j] = (new_sites[i][j] + d) % mod - */ - for (__pyx_t_8 = 0; __pyx_t_8 < 2; __pyx_t_8+=1) { - __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 684, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_5); - __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":685 - * for i in range(self.n): - * for j in range(2): - * mod = self.w if j == 0 else self.h # <<<<<<<<<<<<<< - * new_sites[i][j] = (new_sites[i][j] + d) % mod - * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) - */ - __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_v_j, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 685, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 685, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_9) { - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 685, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __pyx_t_3; - __pyx_t_3 = 0; - } else { - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->h); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 685, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __pyx_t_3; - __pyx_t_3 = 0; - } - __Pyx_XDECREF_SET(__pyx_v_mod, __pyx_t_5); - __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":686 - * for j in range(2): - * mod = self.w if j == 0 else self.h - * new_sites[i][j] = (new_sites[i][j] + d) % mod # <<<<<<<<<<<<<< - * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) - * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod - */ - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 686, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 686, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 686, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 686, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(__pyx_t_4, __pyx_v_mod); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 686, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 686, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_v_j, __pyx_t_5) < 0)) __PYX_ERR(0, 686, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":687 - * mod = self.w if j == 0 else self.h - * new_sites[i][j] = (new_sites[i][j] + d) % mod - * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) # <<<<<<<<<<<<<< - * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod - * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) - */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = PyFloat_FromDouble(__pyx_v_self->h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->r); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_12 = NULL; - __pyx_t_13 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_12)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_12); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_13 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_12, __pyx_t_3, __pyx_t_2, __pyx_t_10, __pyx_t_11, __pyx_v_new_sites}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[6] = {__pyx_t_12, __pyx_t_3, __pyx_t_2, __pyx_t_10, __pyx_t_11, __pyx_v_new_sites}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - { - __pyx_t_14 = PyTuple_New(5+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - if (__pyx_t_12) { - __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL; - } - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_13, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_13, __pyx_t_11); - __Pyx_INCREF(__pyx_v_new_sites); - __Pyx_GIVEREF(__pyx_v_new_sites); - PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_13, __pyx_v_new_sites); - __pyx_t_3 = 0; - __pyx_t_2 = 0; - __pyx_t_10 = 0; - __pyx_t_11 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 687, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_Ep, __pyx_t_5); - __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":688 - * new_sites[i][j] = (new_sites[i][j] + d) % mod - * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) - * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod # <<<<<<<<<<<<<< - * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) - * new_sites[i][j] = (new_sites[i][j] + d) % mod - */ - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 688, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 688, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyFloat_FromDouble((2.0 * __pyx_v_d)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 688, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_14 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 688, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(__pyx_t_14, __pyx_v_mod); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 688, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 688, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - if (unlikely(PyObject_SetItem(__pyx_t_14, __pyx_v_j, __pyx_t_5) < 0)) __PYX_ERR(0, 688, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":689 - * Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) - * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod - * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) # <<<<<<<<<<<<<< - * new_sites[i][j] = (new_sites[i][j] + d) % mod - * - */ - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->w); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_10 = PyFloat_FromDouble(__pyx_v_self->h); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->r); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - __pyx_t_13 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_14); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_14, function); - __pyx_t_13 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_14)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_t_4, __pyx_t_11, __pyx_t_10, __pyx_t_2, __pyx_v_new_sites}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_t_4, __pyx_t_11, __pyx_t_10, __pyx_t_2, __pyx_v_new_sites}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-__pyx_t_13, 5+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_12 = PyTuple_New(5+__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_13, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_13, __pyx_t_11); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_13, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_13, __pyx_t_2); - __Pyx_INCREF(__pyx_v_new_sites); - __Pyx_GIVEREF(__pyx_v_new_sites); - PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_13, __pyx_v_new_sites); - __pyx_t_4 = 0; - __pyx_t_11 = 0; - __pyx_t_10 = 0; - __pyx_t_2 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_XDECREF_SET(__pyx_v_Em, __pyx_t_5); - __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":690 - * new_sites[i][j] = (new_sites[i][j] - 2*d) % mod - * Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) - * new_sites[i][j] = (new_sites[i][j] + d) % mod # <<<<<<<<<<<<<< - * - * HE[:, 2*i+j] = ((Ep.gradient - Em.gradient)/(2*d)).flatten() - */ - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 690, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_14 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 690, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 690, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_12 = PyNumber_Add(__pyx_t_14, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 690, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(__pyx_t_12, __pyx_v_mod); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 690, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_new_sites, __pyx_v_i); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 690, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - if (unlikely(PyObject_SetItem(__pyx_t_12, __pyx_v_j, __pyx_t_5) < 0)) __PYX_ERR(0, 690, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":692 - * new_sites[i][j] = (new_sites[i][j] + d) % mod - * - * HE[:, 2*i+j] = ((Ep.gradient - Em.gradient)/(2*d)).flatten() # <<<<<<<<<<<<<< - * - * # Average out discrepencies, since it should be symmetric. - */ - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_Ep, __pyx_n_s_gradient); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_Em, __pyx_n_s_gradient); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_2 = PyNumber_Subtract(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyFloat_FromDouble((2.0 * __pyx_v_d)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_12 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_flatten); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) { - __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_14); - if (likely(__pyx_t_12)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); - __Pyx_INCREF(__pyx_t_12); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_14, function); - } - } - __pyx_t_5 = (__pyx_t_12) ? __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_12) : __Pyx_PyObject_CallNoArg(__pyx_t_14); - __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyNumber_Multiply(__pyx_int_2, __pyx_v_i); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_12 = PyNumber_Add(__pyx_t_14, __pyx_v_j); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_INCREF(__pyx_slice__2); - __Pyx_GIVEREF(__pyx_slice__2); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_slice__2); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_12); - __pyx_t_12 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_HE, __pyx_t_14, __pyx_t_5) < 0)) __PYX_ERR(0, 692, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - - /* "squish/voronoi.pyx":683 - * HE = np.zeros((2*self.n, 2*self.n)) - * new_sites = np.copy(self.site_arr) # Maintain one copy for speed. - * for i in range(self.n): # <<<<<<<<<<<<<< - * for j in range(2): - * mod = self.w if j == 0 else self.h - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":695 - * - * # Average out discrepencies, since it should be symmetric. - * for i in range(2*self.n): # <<<<<<<<<<<<<< - * for j in range(i, 2*self.n): - * HE[i][j] = (HE[i][j] + HE[j][i])/2 - */ - __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->n)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 695, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { - __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; - __pyx_t_7 = NULL; - } else { - __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 695, __pyx_L1_error) - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - for (;;) { - if (likely(!__pyx_t_7)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 695, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 695, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 695, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 695, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_7(__pyx_t_1); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 695, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_5); - } - __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5); - __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":696 - * # Average out discrepencies, since it should be symmetric. - * for i in range(2*self.n): - * for j in range(i, 2*self.n): # <<<<<<<<<<<<<< - * HE[i][j] = (HE[i][j] + HE[j][i])/2 - * HE[j][i] = HE[i][j] - */ - __pyx_t_5 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->n)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 696, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_INCREF(__pyx_v_i); - __Pyx_GIVEREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_i); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { - __pyx_t_14 = __pyx_t_5; __Pyx_INCREF(__pyx_t_14); __pyx_t_15 = 0; - __pyx_t_16 = NULL; - } else { - __pyx_t_15 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 696, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_16 = Py_TYPE(__pyx_t_14)->tp_iternext; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 696, __pyx_L1_error) - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - for (;;) { - if (likely(!__pyx_t_16)) { - if (likely(PyList_CheckExact(__pyx_t_14))) { - if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_14)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 696, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_14, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_14)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 696, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_14, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_16(__pyx_t_14); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 696, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_5); - } - __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_5); - __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":697 - * for i in range(2*self.n): - * for j in range(i, 2*self.n): - * HE[i][j] = (HE[i][j] + HE[j][i])/2 # <<<<<<<<<<<<<< - * HE[j][i] = HE[i][j] - * - */ - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_j); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Add(__pyx_t_12, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_TrueDivideObjC(__pyx_t_5, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_v_j, __pyx_t_2) < 0)) __PYX_ERR(0, 697, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "squish/voronoi.pyx":698 - * for j in range(i, 2*self.n): - * HE[i][j] = (HE[i][j] + HE[j][i])/2 - * HE[j][i] = HE[i][j] # <<<<<<<<<<<<<< - * - * return HE - */ - __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_j); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 698, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_v_i, __pyx_t_5) < 0)) __PYX_ERR(0, 698, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "squish/voronoi.pyx":696 - * # Average out discrepencies, since it should be symmetric. - * for i in range(2*self.n): - * for j in range(i, 2*self.n): # <<<<<<<<<<<<<< - * HE[i][j] = (HE[i][j] + HE[j][i])/2 - * HE[j][i] = HE[i][j] - */ - } - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - - /* "squish/voronoi.pyx":695 - * - * # Average out discrepencies, since it should be symmetric. - * for i in range(2*self.n): # <<<<<<<<<<<<<< - * for j in range(i, 2*self.n): - * HE[i][j] = (HE[i][j] + HE[j][i])/2 - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":700 - * HE[j][i] = HE[i][j] - * - * return HE # <<<<<<<<<<<<<< - * - * def radialt_hessian(self) -> np.ndarray: - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - if (!(likely(((__pyx_v_HE) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_HE, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 700, __pyx_L1_error) - __Pyx_INCREF(__pyx_v_HE); - __pyx_r = ((PyArrayObject *)__pyx_v_HE); - goto __pyx_L0; - - /* "squish/voronoi.pyx":675 - * - * - * def approx_hessian(self, d: float) -> np.ndarray: # <<<<<<<<<<<<<< - * """ - * Obtains the approximate Hessian. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_14); - __Pyx_AddTraceback("squish.voronoi.VoronoiContainer.approx_hessian", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_HE); - __Pyx_XDECREF(__pyx_v_new_sites); - __Pyx_XDECREF(__pyx_v_i); - __Pyx_XDECREF(__pyx_v_j); - __Pyx_XDECREF(__pyx_v_mod); - __Pyx_XDECREF(__pyx_v_Ep); - __Pyx_XDECREF(__pyx_v_Em); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "squish/voronoi.pyx":702 - * return HE - * - * def radialt_hessian(self) -> np.ndarray: # <<<<<<<<<<<<<< - * HE = np.zeros((2*self.n, 2*self.n)) - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - */ - -/* Python wrapper */ -static PyArrayObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_9radialt_hessian(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyArrayObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_9radialt_hessian(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyArrayObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("radialt_hessian (wrapper)", 0); - __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_8radialt_hessian(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyArrayObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8radialt_hessian(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self) { - PyObject *__pyx_v_HE = NULL; - __pyx_t_6squish_7voronoi_VoronoiInfo __pyx_v_info; - __pyx_t_6squish_7voronoi_Site __pyx_v_xi; - __pyx_t_6squish_7voronoi_Site __pyx_v_xk; - __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_e; - __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_em; - __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_ep; - __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_fj; - __pyx_t_6squish_7voronoi_HalfEdge __pyx_v_fk; - __pyx_t_6squish_4core_Vector2D __pyx_v_temp1; - __pyx_t_6squish_4core_Vector2D __pyx_v_temp2; - __pyx_t_6squish_4core_Vector2D __pyx_v_dau; - __pyx_t_6squish_4core_Vector2D __pyx_v_dapu; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_sigI; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_sigJ; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_sigK; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_p; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_q; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_tempm; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_toI; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_toJ; - __pyx_t_6squish_4core_Matrix2x2 __pyx_v_toK; - __pyx_t_6squish_4core_INT_T __pyx_v_i; - __pyx_t_6squish_4core_INT_T __pyx_v_j; - __pyx_t_6squish_4core_INT_T __pyx_v_k; - __pyx_t_6squish_4core_INT_T __pyx_v_z; - __pyx_t_6squish_7voronoi_Site __pyx_v_xj; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - __pyx_t_6squish_4core_INT_T __pyx_t_6; - __pyx_t_6squish_4core_INT_T __pyx_t_7; - __pyx_t_6squish_4core_INT_T __pyx_t_8; - int __pyx_t_9; - __pyx_t_6squish_7voronoi_HalfEdge __pyx_t_10; - __pyx_t_6squish_7voronoi_HalfEdge __pyx_t_11; - __pyx_t_6squish_7voronoi_Site __pyx_t_12; - __pyx_t_6squish_7voronoi_Site __pyx_t_13; - __pyx_t_6squish_4core_INT_T __pyx_t_14; - __pyx_t_6squish_4core_INT_T __pyx_t_15; - PyObject *__pyx_t_16 = NULL; - PyObject *__pyx_t_17 = NULL; - PyObject *__pyx_t_18 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("radialt_hessian", 0); - - /* "squish/voronoi.pyx":703 - * - * def radialt_hessian(self) -> np.ndarray: - * HE = np.zeros((2*self.n, 2*self.n)) # <<<<<<<<<<<<<< - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_self->n)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); - __pyx_t_2 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_HE = __pyx_t_1; - __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":704 - * def radialt_hessian(self) -> np.ndarray: - * HE = np.zeros((2*self.n, 2*self.n)) - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, - * self.edge_cache, self.edge_cache_map) - */ - if (unlikely(!__pyx_v_self->sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 704, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 704, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 704, __pyx_L1_error)} - - /* "squish/voronoi.pyx":705 - * HE = np.zeros((2*self.n, 2*self.n)) - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, # <<<<<<<<<<<<<< - * self.edge_cache, self.edge_cache_map) - * cdef Site xi, xk - */ - if (unlikely(!__pyx_v_self->vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 705, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 705, __pyx_L1_error)} - - /* "squish/voronoi.pyx":706 - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - * self.vertices, self.site_cache, - * self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< - * cdef Site xi, xk - * cdef HalfEdge e, em, ep, fj, fk - */ - if (unlikely(!__pyx_v_self->edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 706, __pyx_L1_error)} - - /* "squish/voronoi.pyx":704 - * def radialt_hessian(self) -> np.ndarray: - * HE = np.zeros((2*self.n, 2*self.n)) - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< - * self.vertices, self.site_cache, - * self.edge_cache, self.edge_cache_map) - */ - __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->sites, __pyx_v_self->edges, __pyx_v_self->points, __pyx_v_self->vertices, __pyx_v_self->site_cache, __pyx_v_self->edge_cache, __pyx_v_self->edge_cache_map); - - /* "squish/voronoi.pyx":713 - * - * cdef INT_T i, j, k, z - * for i in range(self.n): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * ep = xi.edge(&xi) - */ - __pyx_t_6 = __pyx_v_self->n; - __pyx_t_7 = __pyx_t_6; - for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { - __pyx_v_i = __pyx_t_8; - - /* "squish/voronoi.pyx":714 - * cdef INT_T i, j, k, z - * for i in range(self.n): - * xi = _Site(i, &info) # <<<<<<<<<<<<<< - * ep = xi.edge(&xi) - * e = ep.prev(&ep) - */ - __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); - - /* "squish/voronoi.pyx":715 - * for i in range(self.n): - * xi = _Site(i, &info) - * ep = xi.edge(&xi) # <<<<<<<<<<<<<< - * e = ep.prev(&ep) - * j = 0 - */ - __pyx_v_ep = __pyx_v_xi.edge((&__pyx_v_xi)); - - /* "squish/voronoi.pyx":716 - * xi = _Site(i, &info) - * ep = xi.edge(&xi) - * e = ep.prev(&ep) # <<<<<<<<<<<<<< - * j = 0 - * while j < xi.edge_num(&xi): - */ - __pyx_v_e = __pyx_v_ep.prev((&__pyx_v_ep)); - - /* "squish/voronoi.pyx":717 - * ep = xi.edge(&xi) - * e = ep.prev(&ep) - * j = 0 # <<<<<<<<<<<<<< - * while j < xi.edge_num(&xi): - * e.cache.H(&e, VoronoiContainer.calc_H(e, ep)) - */ - __pyx_v_j = 0; - - /* "squish/voronoi.pyx":718 - * e = ep.prev(&ep) - * j = 0 - * while j < xi.edge_num(&xi): # <<<<<<<<<<<<<< - * e.cache.H(&e, VoronoiContainer.calc_H(e, ep)) - * e = e.next(&e) - */ - while (1) { - __pyx_t_9 = ((__pyx_v_j < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); - if (!__pyx_t_9) break; - - /* "squish/voronoi.pyx":719 - * j = 0 - * while j < xi.edge_num(&xi): - * e.cache.H(&e, VoronoiContainer.calc_H(e, ep)) # <<<<<<<<<<<<<< - * e = e.next(&e) - * j = j + 1 - */ - (void)(__pyx_v_e.cache->H((&__pyx_v_e), __pyx_f_6squish_7voronoi_16VoronoiContainer_calc_H(__pyx_v_e, __pyx_v_ep))); - - /* "squish/voronoi.pyx":720 - * while j < xi.edge_num(&xi): - * e.cache.H(&e, VoronoiContainer.calc_H(e, ep)) - * e = e.next(&e) # <<<<<<<<<<<<<< - * j = j + 1 - * - */ - __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); - - /* "squish/voronoi.pyx":721 - * e.cache.H(&e, VoronoiContainer.calc_H(e, ep)) - * e = e.next(&e) - * j = j + 1 # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_j = (__pyx_v_j + 1); - } - } - - /* "squish/voronoi.pyx":724 - * - * - * for i in range(self.n): # <<<<<<<<<<<<<< - * xi = _Site(i, &info) - * e = xi.edge(&xi) - */ - __pyx_t_6 = __pyx_v_self->n; - __pyx_t_7 = __pyx_t_6; - for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { - __pyx_v_i = __pyx_t_8; - - /* "squish/voronoi.pyx":725 - * - * for i in range(self.n): - * xi = _Site(i, &info) # <<<<<<<<<<<<<< - * e = xi.edge(&xi) - * - */ - __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); - - /* "squish/voronoi.pyx":726 - * for i in range(self.n): - * xi = _Site(i, &info) - * e = xi.edge(&xi) # <<<<<<<<<<<<<< - * - * z = 0 - */ - __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); - - /* "squish/voronoi.pyx":728 - * e = xi.edge(&xi) - * - * z = 0 # <<<<<<<<<<<<<< - * while z < xi.edge_num(&xi): - * em, ep = e.prev(&e), e.next(&e) - */ - __pyx_v_z = 0; - - /* "squish/voronoi.pyx":729 - * - * z = 0 - * while z < xi.edge_num(&xi): # <<<<<<<<<<<<<< - * em, ep = e.prev(&e), e.next(&e) - * fj, fk = em.twin(&em), e.twin(&e) - */ - while (1) { - __pyx_t_9 = ((__pyx_v_z < __pyx_v_xi.edge_num((&__pyx_v_xi))) != 0); - if (!__pyx_t_9) break; - - /* "squish/voronoi.pyx":730 - * z = 0 - * while z < xi.edge_num(&xi): - * em, ep = e.prev(&e), e.next(&e) # <<<<<<<<<<<<<< - * fj, fk = em.twin(&em), e.twin(&e) - * fj, fk = fj.next(&fj), fk.next(&fk) - */ - __pyx_t_10 = __pyx_v_e.prev((&__pyx_v_e)); - __pyx_t_11 = __pyx_v_e.next((&__pyx_v_e)); - __pyx_v_em = __pyx_t_10; - __pyx_v_ep = __pyx_t_11; - - /* "squish/voronoi.pyx":731 - * while z < xi.edge_num(&xi): - * em, ep = e.prev(&e), e.next(&e) - * fj, fk = em.twin(&em), e.twin(&e) # <<<<<<<<<<<<<< - * fj, fk = fj.next(&fj), fk.next(&fk) - * - */ - __pyx_t_11 = __pyx_v_em.twin((&__pyx_v_em)); - __pyx_t_10 = __pyx_v_e.twin((&__pyx_v_e)); - __pyx_v_fj = __pyx_t_11; - __pyx_v_fk = __pyx_t_10; - - /* "squish/voronoi.pyx":732 - * em, ep = e.prev(&e), e.next(&e) - * fj, fk = em.twin(&em), e.twin(&e) - * fj, fk = fj.next(&fj), fk.next(&fk) # <<<<<<<<<<<<<< - * - * xj, xk = fj.face(&fj), fk.face(&fk) - */ - __pyx_t_10 = __pyx_v_fj.next((&__pyx_v_fj)); - __pyx_t_11 = __pyx_v_fk.next((&__pyx_v_fk)); - __pyx_v_fj = __pyx_t_10; - __pyx_v_fk = __pyx_t_11; - - /* "squish/voronoi.pyx":734 - * fj, fk = fj.next(&fj), fk.next(&fk) - * - * xj, xk = fj.face(&fj), fk.face(&fk) # <<<<<<<<<<<<<< - * j, k = xj.index(&xj) % self.n, xk.index(&xk) % self.n - * if k < 0: - */ - __pyx_t_12 = __pyx_v_fj.face((&__pyx_v_fj)); - __pyx_t_13 = __pyx_v_fk.face((&__pyx_v_fk)); - __pyx_v_xj = __pyx_t_12; - __pyx_v_xk = __pyx_t_13; - - /* "squish/voronoi.pyx":735 - * - * xj, xk = fj.face(&fj), fk.face(&fk) - * j, k = xj.index(&xj) % self.n, xk.index(&xk) % self.n # <<<<<<<<<<<<<< - * if k < 0: - * k = k + self.n - */ - __pyx_t_14 = (__pyx_v_xj.index((&__pyx_v_xj)) % __pyx_v_self->n); - __pyx_t_15 = (__pyx_v_xk.index((&__pyx_v_xk)) % __pyx_v_self->n); - __pyx_v_j = __pyx_t_14; - __pyx_v_k = __pyx_t_15; - - /* "squish/voronoi.pyx":736 - * xj, xk = fj.face(&fj), fk.face(&fk) - * j, k = xj.index(&xj) % self.n, xk.index(&xk) % self.n - * if k < 0: # <<<<<<<<<<<<<< - * k = k + self.n - * if j < 0: - */ - __pyx_t_9 = ((__pyx_v_k < 0) != 0); - if (__pyx_t_9) { - - /* "squish/voronoi.pyx":737 - * j, k = xj.index(&xj) % self.n, xk.index(&xk) % self.n - * if k < 0: - * k = k + self.n # <<<<<<<<<<<<<< - * if j < 0: - * j = j + self.n - */ - __pyx_v_k = (__pyx_v_k + __pyx_v_self->n); - - /* "squish/voronoi.pyx":736 - * xj, xk = fj.face(&fj), fk.face(&fk) - * j, k = xj.index(&xj) % self.n, xk.index(&xk) % self.n - * if k < 0: # <<<<<<<<<<<<<< - * k = k + self.n - * if j < 0: - */ - } - - /* "squish/voronoi.pyx":738 - * if k < 0: - * k = k + self.n - * if j < 0: # <<<<<<<<<<<<<< - * j = j + self.n - * - */ - __pyx_t_9 = ((__pyx_v_j < 0) != 0); - if (__pyx_t_9) { - - /* "squish/voronoi.pyx":739 - * k = k + self.n - * if j < 0: - * j = j + self.n # <<<<<<<<<<<<<< - * - * sigI = e.cache.H(&e, NAN_MATRIX) - */ - __pyx_v_j = (__pyx_v_j + __pyx_v_self->n); - - /* "squish/voronoi.pyx":738 - * if k < 0: - * k = k + self.n - * if j < 0: # <<<<<<<<<<<<<< - * j = j + self.n - * - */ - } - - /* "squish/voronoi.pyx":741 - * j = j + self.n - * - * sigI = e.cache.H(&e, NAN_MATRIX) # <<<<<<<<<<<<<< - * sigJ = fj.cache.H(&fj, NAN_MATRIX) - * sigK = fk.cache.H(&fk, NAN_MATRIX) - */ - __pyx_v_sigI = __pyx_v_e.cache->H((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_MATRIX); - - /* "squish/voronoi.pyx":742 - * - * sigI = e.cache.H(&e, NAN_MATRIX) - * sigJ = fj.cache.H(&fj, NAN_MATRIX) # <<<<<<<<<<<<<< - * sigK = fk.cache.H(&fk, NAN_MATRIX) - * - */ - __pyx_v_sigJ = __pyx_v_fj.cache->H((&__pyx_v_fj), __pyx_v_6squish_7voronoi_NAN_MATRIX); - - /* "squish/voronoi.pyx":743 - * sigI = e.cache.H(&e, NAN_MATRIX) - * sigJ = fj.cache.H(&fj, NAN_MATRIX) - * sigK = fk.cache.H(&fk, NAN_MATRIX) # <<<<<<<<<<<<<< - * - * ### Calculating of p - */ - __pyx_v_sigK = __pyx_v_fk.cache->H((&__pyx_v_fk), __pyx_v_6squish_7voronoi_NAN_MATRIX); - - /* "squish/voronoi.pyx":746 - * - * ### Calculating of p - * temp1 = e.cache.la(&e, NAN_VECTOR) # <<<<<<<<<<<<<< - * temp1 = temp1.rot(&temp1) - * temp1.self.sdiv( - */ - __pyx_v_temp1 = __pyx_v_e.cache->la((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); - - /* "squish/voronoi.pyx":747 - * ### Calculating of p - * temp1 = e.cache.la(&e, NAN_VECTOR) - * temp1 = temp1.rot(&temp1) # <<<<<<<<<<<<<< - * temp1.self.sdiv( - * &temp1, - */ - __pyx_v_temp1 = __pyx_v_temp1.rot((&__pyx_v_temp1)); - - /* "squish/voronoi.pyx":748 - * temp1 = e.cache.la(&e, NAN_VECTOR) - * temp1 = temp1.rot(&temp1) - * temp1.self.sdiv( # <<<<<<<<<<<<<< - * &temp1, - * e.cache.la_mag(&e, NAN) * e.cache.ya_mag(&e, NAN) / 2 - */ - (void)(__pyx_v_temp1.self.sdiv((&__pyx_v_temp1), ((__pyx_v_e.cache->la_mag((&__pyx_v_e), NAN) * __pyx_v_e.cache->ya_mag((&__pyx_v_e), NAN)) / 2.0))); - - /* "squish/voronoi.pyx":753 - * ) - * - * dau = e.cache.da(&e, NAN_VECTOR) # <<<<<<<<<<<<<< - * dau.self.sdiv(&dau, e.cache.da_mag(&e, NAN)) - * dapu = ep.cache.da(&ep, NAN_VECTOR) - */ - __pyx_v_dau = __pyx_v_e.cache->da((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); - - /* "squish/voronoi.pyx":754 - * - * dau = e.cache.da(&e, NAN_VECTOR) - * dau.self.sdiv(&dau, e.cache.da_mag(&e, NAN)) # <<<<<<<<<<<<<< - * dapu = ep.cache.da(&ep, NAN_VECTOR) - * dapu.self.sdiv(&dapu, ep.cache.da_mag(&ep, NAN)) - */ - (void)(__pyx_v_dau.self.sdiv((&__pyx_v_dau), __pyx_v_e.cache->da_mag((&__pyx_v_e), NAN))); - - /* "squish/voronoi.pyx":755 - * dau = e.cache.da(&e, NAN_VECTOR) - * dau.self.sdiv(&dau, e.cache.da_mag(&e, NAN)) - * dapu = ep.cache.da(&ep, NAN_VECTOR) # <<<<<<<<<<<<<< - * dapu.self.sdiv(&dapu, ep.cache.da_mag(&ep, NAN)) - * - */ - __pyx_v_dapu = __pyx_v_ep.cache->da((&__pyx_v_ep), __pyx_v_6squish_7voronoi_NAN_VECTOR); - - /* "squish/voronoi.pyx":756 - * dau.self.sdiv(&dau, e.cache.da_mag(&e, NAN)) - * dapu = ep.cache.da(&ep, NAN_VECTOR) - * dapu.self.sdiv(&dapu, ep.cache.da_mag(&ep, NAN)) # <<<<<<<<<<<<<< - * - * temp2 = dapu.copy.vsub(&dapu, dau) - */ - (void)(__pyx_v_dapu.self.sdiv((&__pyx_v_dapu), __pyx_v_ep.cache->da_mag((&__pyx_v_ep), NAN))); - - /* "squish/voronoi.pyx":758 - * dapu.self.sdiv(&dapu, ep.cache.da_mag(&ep, NAN)) - * - * temp2 = dapu.copy.vsub(&dapu, dau) # <<<<<<<<<<<<<< - * temp2 = temp2.rot(&temp2) - * - */ - __pyx_v_temp2 = __pyx_v_dapu.copy.vsub((&__pyx_v_dapu), __pyx_v_dau); - - /* "squish/voronoi.pyx":759 - * - * temp2 = dapu.copy.vsub(&dapu, dau) - * temp2 = temp2.rot(&temp2) # <<<<<<<<<<<<<< - * - * p = _Matrix2x2( - */ - __pyx_v_temp2 = __pyx_v_temp2.rot((&__pyx_v_temp2)); - - /* "squish/voronoi.pyx":761 - * temp2 = temp2.rot(&temp2) - * - * p = _Matrix2x2( # <<<<<<<<<<<<<< - * temp1.x*temp2.x, temp1.x*temp2.y, - * temp1.y*temp2.x, temp1.y*temp2.y - */ - __pyx_v_p = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_temp1.x * __pyx_v_temp2.x), (__pyx_v_temp1.x * __pyx_v_temp2.y), (__pyx_v_temp1.y * __pyx_v_temp2.x), (__pyx_v_temp1.y * __pyx_v_temp2.y)); - - /* "squish/voronoi.pyx":767 - * - * ### Calculating of q - * temp2 = e.cache.la(&e, NAN_VECTOR) # <<<<<<<<<<<<<< - * temp1 = temp2.rot(&temp2) - * q = _Matrix2x2( - */ - __pyx_v_temp2 = __pyx_v_e.cache->la((&__pyx_v_e), __pyx_v_6squish_7voronoi_NAN_VECTOR); - - /* "squish/voronoi.pyx":768 - * ### Calculating of q - * temp2 = e.cache.la(&e, NAN_VECTOR) - * temp1 = temp2.rot(&temp2) # <<<<<<<<<<<<<< - * q = _Matrix2x2( - * temp1.x*temp2.x, temp1.x*temp2.y, - */ - __pyx_v_temp1 = __pyx_v_temp2.rot((&__pyx_v_temp2)); - - /* "squish/voronoi.pyx":769 - * temp2 = e.cache.la(&e, NAN_VECTOR) - * temp1 = temp2.rot(&temp2) - * q = _Matrix2x2( # <<<<<<<<<<<<<< - * temp1.x*temp2.x, temp1.x*temp2.y, - * temp1.y*temp2.x, temp1.y*temp2.y - */ - __pyx_v_q = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_temp1.x * __pyx_v_temp2.x), (__pyx_v_temp1.x * __pyx_v_temp2.y), (__pyx_v_temp1.y * __pyx_v_temp2.x), (__pyx_v_temp1.y * __pyx_v_temp2.y)); - - /* "squish/voronoi.pyx":773 - * temp1.y*temp2.x, temp1.y*temp2.y - * ) - * q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) # <<<<<<<<<<<<<< - * - * q.self.msub(&q, R) - */ - (void)(__pyx_v_q.self.sdiv((&__pyx_v_q), pow(__pyx_v_e.cache->la_mag((&__pyx_v_e), NAN), 2.0))); - - /* "squish/voronoi.pyx":775 - * q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) - * - * q.self.msub(&q, R) # <<<<<<<<<<<<<< - * q.self.smul( - * &q, - */ - (void)(__pyx_v_q.self.msub((&__pyx_v_q), __pyx_v_6squish_7voronoi_R)); - - /* "squish/voronoi.pyx":776 - * - * q.self.msub(&q, R) - * q.self.smul( # <<<<<<<<<<<<<< - * &q, - * e.cache.calI(&e, NAN) / e.cache.la_mag(&e, NAN) - */ - (void)(__pyx_v_q.self.smul((&__pyx_v_q), (__pyx_v_e.cache->calI((&__pyx_v_e), NAN) / __pyx_v_e.cache->la_mag((&__pyx_v_e), NAN)))); - - /* "squish/voronoi.pyx":781 - * ) - * - * temp2 = em.cache.la(&em, NAN_VECTOR) # <<<<<<<<<<<<<< - * temp1 = temp2.rot(&temp2) - * tempm = _Matrix2x2( - */ - __pyx_v_temp2 = __pyx_v_em.cache->la((&__pyx_v_em), __pyx_v_6squish_7voronoi_NAN_VECTOR); - - /* "squish/voronoi.pyx":782 - * - * temp2 = em.cache.la(&em, NAN_VECTOR) - * temp1 = temp2.rot(&temp2) # <<<<<<<<<<<<<< - * tempm = _Matrix2x2( - * temp1.x*temp2.x, temp1.x*temp2.y, - */ - __pyx_v_temp1 = __pyx_v_temp2.rot((&__pyx_v_temp2)); - - /* "squish/voronoi.pyx":783 - * temp2 = em.cache.la(&em, NAN_VECTOR) - * temp1 = temp2.rot(&temp2) - * tempm = _Matrix2x2( # <<<<<<<<<<<<<< - * temp1.x*temp2.x, temp1.x*temp2.y, - * temp1.y*temp2.x, temp1.y*temp2.y - */ - __pyx_v_tempm = __pyx_f_6squish_4core__Matrix2x2((__pyx_v_temp1.x * __pyx_v_temp2.x), (__pyx_v_temp1.x * __pyx_v_temp2.y), (__pyx_v_temp1.y * __pyx_v_temp2.x), (__pyx_v_temp1.y * __pyx_v_temp2.y)); - - /* "squish/voronoi.pyx":787 - * temp1.y*temp2.x, temp1.y*temp2.y - * ) - * tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) # <<<<<<<<<<<<<< - * - * tempm = R.copy.msub(&R, tempm) - */ - (void)(__pyx_v_tempm.self.sdiv((&__pyx_v_tempm), pow(__pyx_v_em.cache->la_mag((&__pyx_v_em), NAN), 2.0))); - - /* "squish/voronoi.pyx":789 - * tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) - * - * tempm = R.copy.msub(&R, tempm) # <<<<<<<<<<<<<< - * tempm.self.smul( - * &tempm, - */ - __pyx_v_tempm = __pyx_v_6squish_7voronoi_R.copy.msub((&__pyx_v_6squish_7voronoi_R), __pyx_v_tempm); - - /* "squish/voronoi.pyx":790 - * - * tempm = R.copy.msub(&R, tempm) - * tempm.self.smul( # <<<<<<<<<<<<<< - * &tempm, - * em.cache.calI(&em, NAN) / em.cache.la_mag(&em, NAN) - */ - (void)(__pyx_v_tempm.self.smul((&__pyx_v_tempm), (__pyx_v_em.cache->calI((&__pyx_v_em), NAN) / __pyx_v_em.cache->la_mag((&__pyx_v_em), NAN)))); - - /* "squish/voronoi.pyx":795 - * ) - * - * q.self.madd(&q, tempm) # <<<<<<<<<<<<<< - * - * # Calculating components that go to the respective sites - */ - (void)(__pyx_v_q.self.madd((&__pyx_v_q), __pyx_v_tempm)); - - /* "squish/voronoi.pyx":798 - * - * # Calculating components that go to the respective sites - * toI = sigI.copy.mmul(&sigI, p.copy.madd(&p, q)) # <<<<<<<<<<<<<< - * toI.self.msub(&toI, p) - * - */ - __pyx_v_toI = __pyx_v_sigI.copy.mmul((&__pyx_v_sigI), __pyx_v_p.copy.madd((&__pyx_v_p), __pyx_v_q)); - - /* "squish/voronoi.pyx":799 - * # Calculating components that go to the respective sites - * toI = sigI.copy.mmul(&sigI, p.copy.madd(&p, q)) - * toI.self.msub(&toI, p) # <<<<<<<<<<<<<< - * - * toJ = sigJ.copy.mmul(&sigJ, p.copy.madd(&p, q)) - */ - (void)(__pyx_v_toI.self.msub((&__pyx_v_toI), __pyx_v_p)); - - /* "squish/voronoi.pyx":801 - * toI.self.msub(&toI, p) - * - * toJ = sigJ.copy.mmul(&sigJ, p.copy.madd(&p, q)) # <<<<<<<<<<<<<< - * toK = sigK.copy.mmul(&sigK, p.copy.madd(&p, q)) - * - */ - __pyx_v_toJ = __pyx_v_sigJ.copy.mmul((&__pyx_v_sigJ), __pyx_v_p.copy.madd((&__pyx_v_p), __pyx_v_q)); - - /* "squish/voronoi.pyx":802 - * - * toJ = sigJ.copy.mmul(&sigJ, p.copy.madd(&p, q)) - * toK = sigK.copy.mmul(&sigK, p.copy.madd(&p, q)) # <<<<<<<<<<<<<< - * - * HE[2*i: 2*(i+1), 2*i: 2*(i+1)] += np.array([[toI.a, toI.b], [toI.c, toI.d]]) - */ - __pyx_v_toK = __pyx_v_sigK.copy.mmul((&__pyx_v_sigK), __pyx_v_p.copy.madd((&__pyx_v_p), __pyx_v_q)); - - /* "squish/voronoi.pyx":804 - * toK = sigK.copy.mmul(&sigK, p.copy.madd(&p, q)) - * - * HE[2*i: 2*(i+1), 2*i: 2*(i+1)] += np.array([[toI.a, toI.b], [toI.c, toI.d]]) # <<<<<<<<<<<<<< - * HE[2*i: 2*(i+1), 2*j: 2*(j+1)] += np.array([[toJ.a, toJ.b], [toJ.c, toJ.d]]) - * HE[2*i: 2*(i+1), 2*k: 2*(k+1)] += np.array([[toK.a, toK.b], [toK.c, toK.d]]) - */ - __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_i)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_From_npy_int64((2 * (__pyx_v_i + 1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PySlice_New(__pyx_t_1, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_i)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * (__pyx_v_i + 1))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PySlice_New(__pyx_t_3, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); - __pyx_t_5 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_toI.a); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_16 = PyFloat_FromDouble(__pyx_v_toI.b); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_16); - __pyx_t_17 = PyList_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_GIVEREF(__pyx_t_3); - PyList_SET_ITEM(__pyx_t_17, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_16); - PyList_SET_ITEM(__pyx_t_17, 1, __pyx_t_16); - __pyx_t_3 = 0; - __pyx_t_16 = 0; - __pyx_t_16 = PyFloat_FromDouble(__pyx_v_toI.c); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_16); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_toI.d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_18 = PyList_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_18); - __Pyx_GIVEREF(__pyx_t_16); - PyList_SET_ITEM(__pyx_t_18, 0, __pyx_t_16); - __Pyx_GIVEREF(__pyx_t_3); - PyList_SET_ITEM(__pyx_t_18, 1, __pyx_t_3); - __pyx_t_16 = 0; - __pyx_t_3 = 0; - __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_17); - PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_17); - __Pyx_GIVEREF(__pyx_t_18); - PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_18); - __pyx_t_17 = 0; - __pyx_t_18 = 0; - __pyx_t_18 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_18)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_18); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_5 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_18, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_HE, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(0, 804, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":805 - * - * HE[2*i: 2*(i+1), 2*i: 2*(i+1)] += np.array([[toI.a, toI.b], [toI.c, toI.d]]) - * HE[2*i: 2*(i+1), 2*j: 2*(j+1)] += np.array([[toJ.a, toJ.b], [toJ.c, toJ.d]]) # <<<<<<<<<<<<<< - * HE[2*i: 2*(i+1), 2*k: 2*(k+1)] += np.array([[toK.a, toK.b], [toK.c, toK.d]]) - * - */ - __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_i)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_From_npy_int64((2 * (__pyx_v_i + 1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PySlice_New(__pyx_t_1, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_j)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * (__pyx_v_j + 1))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PySlice_New(__pyx_t_2, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); - __pyx_t_5 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_toJ.a); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_18 = PyFloat_FromDouble(__pyx_v_toJ.b); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_18); - __pyx_t_17 = PyList_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_GIVEREF(__pyx_t_2); - PyList_SET_ITEM(__pyx_t_17, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_18); - PyList_SET_ITEM(__pyx_t_17, 1, __pyx_t_18); - __pyx_t_2 = 0; - __pyx_t_18 = 0; - __pyx_t_18 = PyFloat_FromDouble(__pyx_v_toJ.c); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_18); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_toJ.d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_16 = PyList_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_16); - __Pyx_GIVEREF(__pyx_t_18); - PyList_SET_ITEM(__pyx_t_16, 0, __pyx_t_18); - __Pyx_GIVEREF(__pyx_t_2); - PyList_SET_ITEM(__pyx_t_16, 1, __pyx_t_2); - __pyx_t_18 = 0; - __pyx_t_2 = 0; - __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_17); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_17); - __Pyx_GIVEREF(__pyx_t_16); - PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_16); - __pyx_t_17 = 0; - __pyx_t_16 = 0; - __pyx_t_16 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_16)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_16); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_5 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_16, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); - __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_HE, __pyx_t_1, __pyx_t_3) < 0)) __PYX_ERR(0, 805, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":806 - * HE[2*i: 2*(i+1), 2*i: 2*(i+1)] += np.array([[toI.a, toI.b], [toI.c, toI.d]]) - * HE[2*i: 2*(i+1), 2*j: 2*(j+1)] += np.array([[toJ.a, toJ.b], [toJ.c, toJ.d]]) - * HE[2*i: 2*(i+1), 2*k: 2*(k+1)] += np.array([[toK.a, toK.b], [toK.c, toK.d]]) # <<<<<<<<<<<<<< - * - * e = e.next(&e) - */ - __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_i)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_From_npy_int64((2 * (__pyx_v_i + 1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PySlice_New(__pyx_t_1, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_npy_int64((2 * __pyx_v_k)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyInt_From_npy_int64((2 * (__pyx_v_k + 1))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PySlice_New(__pyx_t_3, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); - __pyx_t_5 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_HE, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_toK.a); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_16 = PyFloat_FromDouble(__pyx_v_toK.b); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_16); - __pyx_t_17 = PyList_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_GIVEREF(__pyx_t_3); - PyList_SET_ITEM(__pyx_t_17, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_16); - PyList_SET_ITEM(__pyx_t_17, 1, __pyx_t_16); - __pyx_t_3 = 0; - __pyx_t_16 = 0; - __pyx_t_16 = PyFloat_FromDouble(__pyx_v_toK.c); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_16); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_toK.d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_18 = PyList_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_18); - __Pyx_GIVEREF(__pyx_t_16); - PyList_SET_ITEM(__pyx_t_18, 0, __pyx_t_16); - __Pyx_GIVEREF(__pyx_t_3); - PyList_SET_ITEM(__pyx_t_18, 1, __pyx_t_3); - __pyx_t_16 = 0; - __pyx_t_3 = 0; - __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_17); - PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_17); - __Pyx_GIVEREF(__pyx_t_18); - PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_18); - __pyx_t_17 = 0; - __pyx_t_18 = 0; - __pyx_t_18 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_18)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_18); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_5 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_18, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_HE, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(0, 806, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "squish/voronoi.pyx":808 - * HE[2*i: 2*(i+1), 2*k: 2*(k+1)] += np.array([[toK.a, toK.b], [toK.c, toK.d]]) - * - * e = e.next(&e) # <<<<<<<<<<<<<< - * z = z + 1 - * - */ - __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); - - /* "squish/voronoi.pyx":809 - * - * e = e.next(&e) - * z = z + 1 # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_z = (__pyx_v_z + 1); - } - } - - /* "squish/voronoi.pyx":812 - * - * - * return -2*self.r*HE # <<<<<<<<<<<<<< - * - * def site_vert_arr(self): # -> List[np.ndarray] - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_1 = PyFloat_FromDouble((-2.0 * __pyx_v_self->r)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 812, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_v_HE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 812, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 812, __pyx_L1_error) - __pyx_r = ((PyArrayObject *)__pyx_t_2); - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "squish/voronoi.pyx":702 - * return HE - * - * def radialt_hessian(self) -> np.ndarray: # <<<<<<<<<<<<<< - * HE = np.zeros((2*self.n, 2*self.n)) - * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_16); - __Pyx_XDECREF(__pyx_t_17); - __Pyx_XDECREF(__pyx_t_18); - __Pyx_AddTraceback("squish.voronoi.VoronoiContainer.radialt_hessian", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_HE); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "squish/voronoi.pyx":814 - * return -2*self.r*HE +/* "squish/voronoi.pyx":682 + * return -(step/2)*(k1+k2), -k1 * * def site_vert_arr(self): # -> List[np.ndarray] # <<<<<<<<<<<<<< * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, @@ -12607,19 +10906,19 @@ static PyArrayObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8radialt_hess */ /* Python wrapper */ -static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_11site_vert_arr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_11site_vert_arr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_7site_vert_arr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_7site_vert_arr(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("site_vert_arr (wrapper)", 0); - __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self)); + __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_6site_vert_arr(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self) { +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_6site_vert_arr(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self) { __pyx_t_6squish_7voronoi_VoronoiInfo __pyx_v_info; __pyx_t_6squish_4core_INT_T __pyx_v_i; __pyx_t_6squish_4core_INT_T __pyx_v_j; @@ -12648,29 +10947,29 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st int __pyx_clineno = 0; __Pyx_RefNannySetupContext("site_vert_arr", 0); - /* "squish/voronoi.pyx":815 + /* "squish/voronoi.pyx":683 * * def site_vert_arr(self): # -> List[np.ndarray] * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) * */ - if (unlikely(!__pyx_v_self->sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 815, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 815, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 815, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->sites.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 683, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->edges.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 683, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->points.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 683, __pyx_L1_error)} - /* "squish/voronoi.pyx":816 + /* "squish/voronoi.pyx":684 * def site_vert_arr(self): # -> List[np.ndarray] * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, * self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map) # <<<<<<<<<<<<<< * * cdef INT_T i, j */ - if (unlikely(!__pyx_v_self->vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 816, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 816, __pyx_L1_error)} - if (unlikely(!__pyx_v_self->edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 816, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->vertices.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 684, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->site_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 684, __pyx_L1_error)} + if (unlikely(!__pyx_v_self->edge_cache.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");__PYX_ERR(0, 684, __pyx_L1_error)} - /* "squish/voronoi.pyx":815 + /* "squish/voronoi.pyx":683 * * def site_vert_arr(self): # -> List[np.ndarray] * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, # <<<<<<<<<<<<<< @@ -12679,23 +10978,23 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st */ __pyx_v_info = __pyx_f_6squish_7voronoi__VoronoiInfo(__pyx_v_self->sites, __pyx_v_self->edges, __pyx_v_self->points, __pyx_v_self->vertices, __pyx_v_self->site_cache, __pyx_v_self->edge_cache, __pyx_v_self->edge_cache_map); - /* "squish/voronoi.pyx":823 + /* "squish/voronoi.pyx":691 * cdef Vector2D v * * sites, site_verts = [], [] # <<<<<<<<<<<<<< * * for i in range(self.n): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 823, __pyx_L1_error) + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_sites = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; __pyx_v_site_verts = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "squish/voronoi.pyx":825 + /* "squish/voronoi.pyx":693 * sites, site_verts = [], [] * * for i in range(self.n): # <<<<<<<<<<<<<< @@ -12707,7 +11006,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "squish/voronoi.pyx":826 + /* "squish/voronoi.pyx":694 * * for i in range(self.n): * xi = _Site(i, &info) # <<<<<<<<<<<<<< @@ -12716,7 +11015,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st */ __pyx_v_xi = __pyx_f_6squish_7voronoi__Site(__pyx_v_i, (&__pyx_v_info)); - /* "squish/voronoi.pyx":827 + /* "squish/voronoi.pyx":695 * for i in range(self.n): * xi = _Site(i, &info) * v = xi.vec(&xi) # <<<<<<<<<<<<<< @@ -12725,23 +11024,23 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st */ __pyx_v_v = __pyx_v_xi.vec((&__pyx_v_xi)); - /* "squish/voronoi.pyx":828 + /* "squish/voronoi.pyx":696 * xi = _Site(i, &info) * v = xi.vec(&xi) * sites.append(np.array([v.x, v.y])) # <<<<<<<<<<<<<< * verts = np.empty((xi.edge_num(&xi), 2)) * e = xi.edge(&xi) */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 828, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_v.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_v.x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_v.y); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_v.y); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); @@ -12762,27 +11061,27 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 828, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_sites, __pyx_t_2); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_sites, __pyx_t_2); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "squish/voronoi.pyx":829 + /* "squish/voronoi.pyx":697 * v = xi.vec(&xi) * sites.append(np.array([v.x, v.y])) * verts = np.empty((xi.edge_num(&xi), 2)) # <<<<<<<<<<<<<< * e = xi.edge(&xi) * for j in range(xi.edge_num(&xi)): */ - __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 829, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 829, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyInt_From_npy_int64(__pyx_v_xi.edge_num((&__pyx_v_xi))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 829, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_npy_int64(__pyx_v_xi.edge_num((&__pyx_v_xi))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 829, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); @@ -12803,13 +11102,13 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 829, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_verts, __pyx_t_2); __pyx_t_2 = 0; - /* "squish/voronoi.pyx":830 + /* "squish/voronoi.pyx":698 * sites.append(np.array([v.x, v.y])) * verts = np.empty((xi.edge_num(&xi), 2)) * e = xi.edge(&xi) # <<<<<<<<<<<<<< @@ -12818,7 +11117,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st */ __pyx_v_e = __pyx_v_xi.edge((&__pyx_v_xi)); - /* "squish/voronoi.pyx":831 + /* "squish/voronoi.pyx":699 * verts = np.empty((xi.edge_num(&xi), 2)) * e = xi.edge(&xi) * for j in range(xi.edge_num(&xi)): # <<<<<<<<<<<<<< @@ -12830,7 +11129,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_j = __pyx_t_12; - /* "squish/voronoi.pyx":832 + /* "squish/voronoi.pyx":700 * e = xi.edge(&xi) * for j in range(xi.edge_num(&xi)): * v = e.origin(&e) # <<<<<<<<<<<<<< @@ -12839,20 +11138,20 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st */ __pyx_v_v = __pyx_v_e.origin((&__pyx_v_e)); - /* "squish/voronoi.pyx":833 + /* "squish/voronoi.pyx":701 * for j in range(xi.edge_num(&xi)): * v = e.origin(&e) * verts[j, 0], verts[j, 1] = v.x, v.y # <<<<<<<<<<<<<< * e = e.next(&e) * */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_v.x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_v.x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_v.y); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 833, __pyx_L1_error) + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_v.y); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = __Pyx_PyInt_From_npy_int64(__pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 833, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_npy_int64(__pyx_v_j); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 833, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); @@ -12860,12 +11159,12 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0); __pyx_t_7 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_verts, __pyx_t_6, __pyx_t_2) < 0)) __PYX_ERR(0, 833, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_v_verts, __pyx_t_6, __pyx_t_2) < 0)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 833, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); @@ -12873,11 +11172,11 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st __Pyx_GIVEREF(__pyx_int_1); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_verts, __pyx_t_6, __pyx_t_8) < 0)) __PYX_ERR(0, 833, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_v_verts, __pyx_t_6, __pyx_t_8) < 0)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - /* "squish/voronoi.pyx":834 + /* "squish/voronoi.pyx":702 * v = e.origin(&e) * verts[j, 0], verts[j, 1] = v.x, v.y * e = e.next(&e) # <<<<<<<<<<<<<< @@ -12887,23 +11186,23 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st __pyx_v_e = __pyx_v_e.next((&__pyx_v_e)); } - /* "squish/voronoi.pyx":836 + /* "squish/voronoi.pyx":704 * e = e.next(&e) * * site_verts.append(verts) # <<<<<<<<<<<<<< * * return sites, site_verts */ - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_site_verts, __pyx_v_verts); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 836, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_site_verts, __pyx_v_verts); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 704, __pyx_L1_error) } - /* "squish/voronoi.pyx":838 + /* "squish/voronoi.pyx":706 * site_verts.append(verts) * * return sites, site_verts # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 838, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_sites); __Pyx_GIVEREF(__pyx_v_sites); @@ -12915,8 +11214,8 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10site_vert_arr(st __pyx_t_8 = 0; goto __pyx_L0; - /* "squish/voronoi.pyx":814 - * return -2*self.r*HE + /* "squish/voronoi.pyx":682 + * return -(step/2)*(k1+k2), -k1 * * def site_vert_arr(self): # -> List[np.ndarray] # <<<<<<<<<<<<<< * cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, @@ -12993,7 +11292,7 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_1n___get__(struct * cdef readonly INT_T n * cdef readonly FLOAT_T w, h, r, energy # <<<<<<<<<<<<<< * cdef FLOAT_T [2] dim - * cdef FLOAT_T [:, ::1] points, vertices, site_cache, edge_cache, grad + * cdef FLOAT_T [:, ::1] points, vertices, site_cache, edge_cache, grad, hess */ /* Python wrapper */ @@ -13159,19 +11458,19 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_6energy___get__(st */ /* Python wrapper */ -static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_12__reduce_cython__(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self)); + __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_8__reduce_cython__(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self) { +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -13216,19 +11515,19 @@ static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_12__reduce_cython_ */ /* Python wrapper */ -static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_6squish_7voronoi_16VoronoiContainer_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_14__setstate_cython__(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + __pyx_r = __pyx_pf_6squish_7voronoi_16VoronoiContainer_10__setstate_cython__(((struct __pyx_obj_6squish_7voronoi_VoronoiContainer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_6squish_7voronoi_16VoronoiContainer_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_6squish_7voronoi_VoronoiContainer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -28193,6 +26492,8 @@ static PyObject *__pyx_tp_new_6squish_7voronoi_VoronoiContainer(PyTypeObject *t, p->edge_cache.memview = NULL; p->grad.data = NULL; p->grad.memview = NULL; + p->hess.data = NULL; + p->hess.memview = NULL; p->sites.data = NULL; p->sites.memview = NULL; p->edges.data = NULL; @@ -28218,6 +26519,7 @@ static void __pyx_tp_dealloc_6squish_7voronoi_VoronoiContainer(PyObject *o) { __PYX_XDEC_MEMVIEW(&p->site_cache, 1); __PYX_XDEC_MEMVIEW(&p->edge_cache, 1); __PYX_XDEC_MEMVIEW(&p->grad, 1); + __PYX_XDEC_MEMVIEW(&p->hess, 1); __PYX_XDEC_MEMVIEW(&p->sites, 1); __PYX_XDEC_MEMVIEW(&p->edges, 1); (*Py_TYPE(o)->tp_free)(o); @@ -28262,6 +26564,10 @@ static PyObject *__pyx_getprop_6squish_7voronoi_16VoronoiContainer_gradient(PyOb return __pyx_pw_6squish_7voronoi_16VoronoiContainer_8gradient_1__get__(o); } +static PyObject *__pyx_getprop_6squish_7voronoi_16VoronoiContainer_hessian(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_6squish_7voronoi_16VoronoiContainer_7hessian_1__get__(o); +} + static PyObject *__pyx_getprop_6squish_7voronoi_16VoronoiContainer_n(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_6squish_7voronoi_16VoronoiContainer_1n_1__get__(o); } @@ -28285,11 +26591,9 @@ static PyObject *__pyx_getprop_6squish_7voronoi_16VoronoiContainer_energy(PyObje static PyMethodDef __pyx_methods_6squish_7voronoi_VoronoiContainer[] = { {"add_sites", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_3add_sites, METH_O, 0}, {"iterate", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_5iterate, METH_O, 0}, - {"approx_hessian", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_7approx_hessian, METH_O, __pyx_doc_6squish_7voronoi_16VoronoiContainer_6approx_hessian}, - {"radialt_hessian", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_9radialt_hessian, METH_NOARGS, 0}, - {"site_vert_arr", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_11site_vert_arr, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_13__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_15__setstate_cython__, METH_O, 0}, + {"site_vert_arr", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_7site_vert_arr, METH_NOARGS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_9__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_6squish_7voronoi_16VoronoiContainer_11__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; @@ -28298,6 +26602,7 @@ static struct PyGetSetDef __pyx_getsets_6squish_7voronoi_VoronoiContainer[] = { {(char *)"site_arr", __pyx_getprop_6squish_7voronoi_16VoronoiContainer_site_arr, 0, (char *)0, 0}, {(char *)"vor_data", __pyx_getprop_6squish_7voronoi_16VoronoiContainer_vor_data, 0, (char *)0, 0}, {(char *)"gradient", __pyx_getprop_6squish_7voronoi_16VoronoiContainer_gradient, 0, (char *)0, 0}, + {(char *)"hessian", __pyx_getprop_6squish_7voronoi_16VoronoiContainer_hessian, 0, (char *)0, 0}, {(char *)"n", __pyx_getprop_6squish_7voronoi_16VoronoiContainer_n, 0, (char *)0, 0}, {(char *)"w", __pyx_getprop_6squish_7voronoi_16VoronoiContainer_w, 0, (char *)0, 0}, {(char *)"h", __pyx_getprop_6squish_7voronoi_16VoronoiContainer_h, 0, (char *)0, 0}, @@ -29182,7 +27487,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, - {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1}, {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, @@ -29193,7 +27497,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1}, {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, - {&__pyx_n_s_flatten, __pyx_k_flatten, sizeof(__pyx_k_flatten), 0, 0, 1, 1}, {&__pyx_n_s_flip, __pyx_k_flip, sizeof(__pyx_k_flip), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, @@ -29212,6 +27515,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1}, {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1}, {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1}, @@ -29314,25 +27618,25 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "squish/voronoi.pyx":628 + /* "squish/voronoi.pyx":631 * cache = self.site_cache[:self.n, :] * * self.stats["site_areas"] = np.asarray(cache[:, SITE_CACHE_MAP.iarea]) # <<<<<<<<<<<<<< * self.stats["site_edge_count"] = np.asarray(self.sites[:self.n, 2]) * */ - __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 628, __pyx_L1_error) + __pyx_slice__2 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__2)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__2); __Pyx_GIVEREF(__pyx_slice__2); - /* "squish/voronoi.pyx":643 + /* "squish/voronoi.pyx":646 * edges = np.asarray(self.edges) * * mask = np.nonzero(edges[:, 0] != -1)[0] # <<<<<<<<<<<<<< * all_edges = mask[(mask % 2 == 0)] * caches = edges[all_edges, 4] */ - __pyx_tuple__3 = PyTuple_Pack(2, __pyx_slice__2, __pyx_int_0); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 643, __pyx_L1_error) + __pyx_tuple__3 = PyTuple_Pack(2, __pyx_slice__2, __pyx_int_0); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); @@ -29724,6 +28028,7 @@ static int __Pyx_modinit_type_init_code(void) { __pyx_vtable_6squish_7voronoi_VoronoiContainer.common_cache = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_7voronoi_16VoronoiContainer_common_cache; __pyx_vtable_6squish_7voronoi_VoronoiContainer.precompute = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_7voronoi_16VoronoiContainer_precompute; __pyx_vtable_6squish_7voronoi_VoronoiContainer.calc_grad = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_7voronoi_16VoronoiContainer_calc_grad; + __pyx_vtable_6squish_7voronoi_VoronoiContainer.calc_hess = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_7voronoi_16VoronoiContainer_calc_hess; __pyx_vtable_6squish_7voronoi_VoronoiContainer.get_statistics = (void (*)(struct __pyx_obj_6squish_7voronoi_VoronoiContainer *))__pyx_f_6squish_7voronoi_16VoronoiContainer_get_statistics; __pyx_vtable_6squish_7voronoi_VoronoiContainer.calc_H = (__pyx_t_6squish_4core_Matrix2x2 (*)(__pyx_t_6squish_7voronoi_HalfEdge, __pyx_t_6squish_7voronoi_HalfEdge))__pyx_f_6squish_7voronoi_16VoronoiContainer_calc_H; __pyx_vtable_6squish_7voronoi_VoronoiContainer.sign = (int (*)(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice))__pyx_f_6squish_7voronoi_16VoronoiContainer_sign; @@ -29888,6 +28193,7 @@ static int __Pyx_modinit_function_import_code(void) { __Pyx_GOTREF(__pyx_t_1); if (__Pyx_ImportFunction(__pyx_t_1, "_IArray", (void (**)(void))&__pyx_f_6squish_4core__IArray, "struct __pyx_t_6squish_4core_IArray (__pyx_t_6squish_4core_INT_T *, __pyx_t_6squish_4core_Pair)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportFunction(__pyx_t_1, "_FArray", (void (**)(void))&__pyx_f_6squish_4core__FArray, "__pyx_t_6squish_4core_FArray (__pyx_t_6squish_4core_FLOAT_T *, __pyx_t_6squish_4core_Pair)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) + if (__Pyx_ImportFunction(__pyx_t_1, "_BitSet", (void (**)(void))&__pyx_f_6squish_4core__BitSet, "__pyx_t_6squish_4core_BitSet (__pyx_t_6squish_4core_INT_T)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportFunction(__pyx_t_1, "_Vector2D", (void (**)(void))&__pyx_f_6squish_4core__Vector2D, "__pyx_t_6squish_4core_Vector2D (__pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportFunction(__pyx_t_1, "_Matrix2x2", (void (**)(void))&__pyx_f_6squish_4core__Matrix2x2, "__pyx_t_6squish_4core_Matrix2x2 (__pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T, __pyx_t_6squish_4core_FLOAT_T)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -30103,7 +28409,7 @@ if (!__Pyx_RefNanny) { #endif /* "squish/voronoi.pyx":1 - * import array, scipy.spatial, numpy as np # <<<<<<<<<<<<<< + * import array, scipy.spatial, numpy as np, math # <<<<<<<<<<<<<< * from cython.parallel import parallel, prange * */ @@ -30119,6 +28425,10 @@ if (!__Pyx_RefNanny) { __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_Import(__pyx_n_s_math, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_math, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "squish/voronoi.pyx":16 * #### Constants #### @@ -30214,7 +28524,7 @@ if (!__Pyx_RefNanny) { __pyx_v_6squish_7voronoi_SITE_CACHE_MAP = __pyx_f_6squish_7voronoi__SiteCacheMap(0, 1, 2, 3, 4, 5, -1LL); /* "squish/voronoi.pyx":1 - * import array, scipy.spatial, numpy as np # <<<<<<<<<<<<<< + * import array, scipy.spatial, numpy as np, math # <<<<<<<<<<<<<< * from cython.parallel import parallel, prange * */ @@ -32380,128 +30690,6 @@ static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_ } #endif -/* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) -#else - if (likely(PyCFunction_Check(func))) -#endif - { - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* PyIntBinop */ - #if !CYTHON_COMPILING_IN_PYPY -#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS -#define __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(operand)\ - if (unlikely(zerodivision_check && ((operand) == 0))) {\ - PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\ - return NULL;\ - } -#endif -static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { - (void)inplace; - (void)zerodivision_check; - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long a = PyInt_AS_LONG(op1); - __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b) - if (8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53))) { - return PyFloat_FromDouble((double)a / (double)b); - } - return PyInt_Type.tp_as_number->nb_true_divide(op1, op2); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a, x; - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - CYTHON_FALLTHROUGH; - default: return PyLong_Type.tp_as_number->nb_true_divide(op1, op2); - } - } - __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b) - if ((8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53))) - || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) { - return PyFloat_FromDouble((double)a / (double)b); - } - return PyLong_Type.tp_as_number->nb_true_divide(op1, op2); - return PyLong_FromLong(x); - - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - double result; - if (unlikely(zerodivision_check && b == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero"); - return NULL; - } - PyFPE_START_PROTECT("divide", return NULL) - result = ((double)a) / (double)b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); - } - return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2); -} -#endif - /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, diff --git a/squish/voronoi.pxd b/squish/voronoi.pxd index d1b995b..3865fa4 100644 --- a/squish/voronoi.pxd +++ b/squish/voronoi.pxd @@ -66,7 +66,7 @@ cdef class VoronoiContainer: cdef readonly INT_T n cdef readonly FLOAT_T w, h, r, energy cdef FLOAT_T [2] dim - cdef FLOAT_T [:, ::1] points, vertices, site_cache, edge_cache, grad + cdef FLOAT_T [:, ::1] points, vertices, site_cache, edge_cache, grad, hess cdef INT_T [:, ::1] sites, edges cdef EdgeCacheMap* edge_cache_map cdef dict __dict__ @@ -77,6 +77,7 @@ cdef class VoronoiContainer: cdef void common_cache(VoronoiContainer self) except * cdef void precompute(self) except * cdef void calc_grad(self) except * + cdef void calc_hess(self) except * cdef void get_statistics(VoronoiContainer self) except * @staticmethod diff --git a/squish/voronoi.pyx b/squish/voronoi.pyx index 4bbb35b..40e4686 100644 --- a/squish/voronoi.pyx +++ b/squish/voronoi.pyx @@ -1,4 +1,4 @@ -import array, scipy.spatial, numpy as np +import array, scipy.spatial, numpy as np, math from cython.parallel import parallel, prange cimport numpy as np @@ -6,8 +6,8 @@ from cpython cimport array from libc.math cimport isnan, NAN, pi as PI from squish.core cimport INT_T, FLOAT_T, \ - IArray, FArray, Vector2D, Matrix2x2, \ - _IArray, _FArray, _Vector2D, _Matrix2x2 + IArray, FArray, Vector2D, Matrix2x2, BitSet, \ + _IArray, _FArray, _Vector2D, _Matrix2x2, _BitSet from squish.voronoi cimport SiteCacheMap, EdgeCacheMap, VoronoiInfo, Site, HalfEdge @@ -554,8 +554,8 @@ cdef class VoronoiContainer: # vp - vm, vm - xi la, da = q.copy.vsub(&q, p), p.copy.vsub(&p, xi.vec(&xi)) la_mag = la.mag(&la) - area_p = la.dot(&la, da.rot(&da)) - Rla = la.rot(&la) + area_p = la.dot(&la, da.copy.rot(&da)) + Rla = la.copy.rot(&la) ya = Rla.copy.smul(&Rla, -2*area_p/la.dot(&la, la)) # Calculating centroid. @@ -591,14 +591,14 @@ cdef class VoronoiContainer: xj, xk = em.cache.ya(&em, NAN_VECTOR), ep.cache.ya(&ep, NAN_VECTOR) Rxjk = xk.copy.vsub(&xk, xj) Rxjk.self.smul(&Rxjk, 2) - Rxjk = Rxjk.rot(&Rxjk) + Rxjk.self.rot(&Rxjk) v = ep.cache.da(&ep, NAN_VECTOR) top = R.copy.smul(&R, xj.dot(&xj, xj) - xk.dot(&xk, xk)) top.self.msub(&top, _Matrix2x2(v.x*Rxjk.x, v.x*Rxjk.y, v.y*Rxjk.x, v.y*Rxjk.y)) top.self.sdiv(&top, -Rxjk.dot(&Rxjk, xj)) - return _Matrix2x2(top.a, top.c, top.b, top.d) + return top @staticmethod cdef inline bint sign(FLOAT_T [::1] ref, FLOAT_T [::1] p, FLOAT_T [::1] q): @@ -621,6 +621,9 @@ cdef class VoronoiContainer: cdef void calc_grad(self) except *: pass + cdef void calc_hess(self) except *: + pass + cdef void get_statistics(self) except *: self.stats = {} cache = self.site_cache[:self.n, :] @@ -660,6 +663,11 @@ cdef class VoronoiContainer: def gradient(self): return np.asarray(self.grad, dtype=FLOAT) + @property + def hessian(self): + self.calc_hess() + return np.asarray(self.hess, dtype=FLOAT) + def add_sites(self, add): return (self.site_arr + add) % np.asarray(self.dim, dtype=FLOAT) @@ -671,146 +679,6 @@ cdef class VoronoiContainer: return -(step/2)*(k1+k2), -k1 - - def approx_hessian(self, d: float) -> np.ndarray: - """ - Obtains the approximate Hessian. - :param d: [float] small d for approximation. - :return: 2Nx2N array that represents Hessian. - """ - HE = np.zeros((2*self.n, 2*self.n)) - new_sites = np.copy(self.site_arr) # Maintain one copy for speed. - for i in range(self.n): - for j in range(2): - mod = self.w if j == 0 else self.h - new_sites[i][j] = (new_sites[i][j] + d) % mod - Ep = self.__class__(self.n, self.w, self.h, self.r, new_sites) - new_sites[i][j] = (new_sites[i][j] - 2*d) % mod - Em = self.__class__(self.n, self.w, self.h, self.r, new_sites) - new_sites[i][j] = (new_sites[i][j] + d) % mod - - HE[:, 2*i+j] = ((Ep.gradient - Em.gradient)/(2*d)).flatten() - - # Average out discrepencies, since it should be symmetric. - for i in range(2*self.n): - for j in range(i, 2*self.n): - HE[i][j] = (HE[i][j] + HE[j][i])/2 - HE[j][i] = HE[i][j] - - return HE - - def radialt_hessian(self) -> np.ndarray: - HE = np.zeros((2*self.n, 2*self.n)) - cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, - self.vertices, self.site_cache, - self.edge_cache, self.edge_cache_map) - cdef Site xi, xk - cdef HalfEdge e, em, ep, fj, fk - cdef Vector2D temp1, temp2, dau, dapu - cdef Matrix2x2 sigI, sigJ, sigK, p, q, tempm, toI, toJ, toK - - cdef INT_T i, j, k, z - for i in range(self.n): - xi = _Site(i, &info) - ep = xi.edge(&xi) - e = ep.prev(&ep) - j = 0 - while j < xi.edge_num(&xi): - e.cache.H(&e, VoronoiContainer.calc_H(e, ep)) - e = e.next(&e) - j = j + 1 - - - for i in range(self.n): - xi = _Site(i, &info) - e = xi.edge(&xi) - - z = 0 - while z < xi.edge_num(&xi): - em, ep = e.prev(&e), e.next(&e) - fj, fk = em.twin(&em), e.twin(&e) - fj, fk = fj.next(&fj), fk.next(&fk) - - xj, xk = fj.face(&fj), fk.face(&fk) - j, k = xj.index(&xj) % self.n, xk.index(&xk) % self.n - if k < 0: - k = k + self.n - if j < 0: - j = j + self.n - - sigI = e.cache.H(&e, NAN_MATRIX) - sigJ = fj.cache.H(&fj, NAN_MATRIX) - sigK = fk.cache.H(&fk, NAN_MATRIX) - - ### Calculating of p - temp1 = e.cache.la(&e, NAN_VECTOR) - temp1 = temp1.rot(&temp1) - temp1.self.sdiv( - &temp1, - e.cache.la_mag(&e, NAN) * e.cache.ya_mag(&e, NAN) / 2 - ) - - dau = e.cache.da(&e, NAN_VECTOR) - dau.self.sdiv(&dau, e.cache.da_mag(&e, NAN)) - dapu = ep.cache.da(&ep, NAN_VECTOR) - dapu.self.sdiv(&dapu, ep.cache.da_mag(&ep, NAN)) - - temp2 = dapu.copy.vsub(&dapu, dau) - temp2 = temp2.rot(&temp2) - - p = _Matrix2x2( - temp1.x*temp2.x, temp1.x*temp2.y, - temp1.y*temp2.x, temp1.y*temp2.y - ) - - ### Calculating of q - temp2 = e.cache.la(&e, NAN_VECTOR) - temp1 = temp2.rot(&temp2) - q = _Matrix2x2( - temp1.x*temp2.x, temp1.x*temp2.y, - temp1.y*temp2.x, temp1.y*temp2.y - ) - q.self.sdiv(&q, e.cache.la_mag(&e, NAN)**2) - - q.self.msub(&q, R) - q.self.smul( - &q, - e.cache.calI(&e, NAN) / e.cache.la_mag(&e, NAN) - ) - - temp2 = em.cache.la(&em, NAN_VECTOR) - temp1 = temp2.rot(&temp2) - tempm = _Matrix2x2( - temp1.x*temp2.x, temp1.x*temp2.y, - temp1.y*temp2.x, temp1.y*temp2.y - ) - tempm.self.sdiv(&tempm, em.cache.la_mag(&em, NAN)**2) - - tempm = R.copy.msub(&R, tempm) - tempm.self.smul( - &tempm, - em.cache.calI(&em, NAN) / em.cache.la_mag(&em, NAN) - ) - - q.self.madd(&q, tempm) - - # Calculating components that go to the respective sites - toI = sigI.copy.mmul(&sigI, p.copy.madd(&p, q)) - toI.self.msub(&toI, p) - - toJ = sigJ.copy.mmul(&sigJ, p.copy.madd(&p, q)) - toK = sigK.copy.mmul(&sigK, p.copy.madd(&p, q)) - - HE[2*i: 2*(i+1), 2*i: 2*(i+1)] += np.array([[toI.a, toI.b], [toI.c, toI.d]]) - HE[2*i: 2*(i+1), 2*j: 2*(j+1)] += np.array([[toJ.a, toJ.b], [toJ.c, toJ.d]]) - HE[2*i: 2*(i+1), 2*k: 2*(k+1)] += np.array([[toK.a, toK.b], [toK.c, toK.d]]) - - e = e.next(&e) - z = z + 1 - - - return -2*self.r*HE - def site_vert_arr(self): # -> List[np.ndarray] cdef VoronoiInfo info = _VoronoiInfo(self.sites, self.edges, self.points, self.vertices, self.site_cache, self.edge_cache, self.edge_cache_map)