text:
# Automatically generated with generator.jl
Base.pointer(a::BIG_1024_58) = reinterpret(Ptr{BIG_1024_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_1024_58}}, a::BIG_1024_58) = pointer(a)
Base.:(==)(a::BIG_1024_58, b::BIG_1024_58) = iszero(BIG_1024_58_comp(a, b))
Base.isless(a::BIG_1024_58, b::BIG_1024_58) = isone(-BIG_1024_58_comp(a, b))
BIG_1024_58() = (a = BIG_1024_58(undef); BIG_1024_58_zero(a); a)
Base.pointer(a::BIG_256_56) = reinterpret(Ptr{BIG_256_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_256_56}}, a::BIG_256_56) = pointer(a)
Base.:(==)(a::BIG_256_56, b::BIG_256_56) = iszero(BIG_256_56_comp(a, b))
Base.isless(a::BIG_256_56, b::BIG_256_56) = isone(-BIG_256_56_comp(a, b))
BIG_256_56() = (a = BIG_256_56(undef); BIG_256_56_zero(a); a)
Base.pointer(a::BIG_336_60) = reinterpret(Ptr{BIG_336_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_336_60}}, a::BIG_336_60) = pointer(a)
Base.:(==)(a::BIG_336_60, b::BIG_336_60) = iszero(BIG_336_60_comp(a, b))
Base.isless(a::BIG_336_60, b::BIG_336_60) = isone(-BIG_336_60_comp(a, b))
BIG_336_60() = (a = BIG_336_60(undef); BIG_336_60_zero(a); a)
Base.pointer(a::BIG_384_56) = reinterpret(Ptr{BIG_384_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_384_56}}, a::BIG_384_56) = pointer(a)
Base.:(==)(a::BIG_384_56, b::BIG_384_56) = iszero(BIG_384_56_comp(a, b))
Base.isless(a::BIG_384_56, b::BIG_384_56) = isone(-BIG_384_56_comp(a, b))
BIG_384_56() = (a = BIG_384_56(undef); BIG_384_56_zero(a); a)
Base.pointer(a::BIG_384_58) = reinterpret(Ptr{BIG_384_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_384_58}}, a::BIG_384_58) = pointer(a)
Base.:(==)(a::BIG_384_58, b::BIG_384_58) = iszero(BIG_384_58_comp(a, b))
Base.isless(a::BIG_384_58, b::BIG_384_58) = isone(-BIG_384_58_comp(a, b))
BIG_384_58() = (a = BIG_384_58(undef); BIG_384_58_zero(a); a)
Base.pointer(a::BIG_416_60) = reinterpret(Ptr{BIG_416_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_416_60}}, a::BIG_416_60) = pointer(a)
Base.:(==)(a::BIG_416_60, b::BIG_416_60) = iszero(BIG_416_60_comp(a, b))
Base.isless(a::BIG_416_60, b::BIG_416_60) = isone(-BIG_416_60_comp(a, b))
BIG_416_60() = (a = BIG_416_60(undef); BIG_416_60_zero(a); a)
Base.pointer(a::BIG_448_58) = reinterpret(Ptr{BIG_448_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_448_58}}, a::BIG_448_58) = pointer(a)
Base.:(==)(a::BIG_448_58, b::BIG_448_58) = iszero(BIG_448_58_comp(a, b))
Base.isless(a::BIG_448_58, b::BIG_448_58) = isone(-BIG_448_58_comp(a, b))
BIG_448_58() = (a = BIG_448_58(undef); BIG_448_58_zero(a); a)
Base.pointer(a::BIG_464_60) = reinterpret(Ptr{BIG_464_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_464_60}}, a::BIG_464_60) = pointer(a)
Base.:(==)(a::BIG_464_60, b::BIG_464_60) = iszero(BIG_464_60_comp(a, b))
Base.isless(a::BIG_464_60, b::BIG_464_60) = isone(-BIG_464_60_comp(a, b))
BIG_464_60() = (a = BIG_464_60(undef); BIG_464_60_zero(a); a)
Base.pointer(a::BIG_480_56) = reinterpret(Ptr{BIG_480_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_480_56}}, a::BIG_480_56) = pointer(a)
Base.:(==)(a::BIG_480_56, b::BIG_480_56) = iszero(BIG_480_56_comp(a, b))
Base.isless(a::BIG_480_56, b::BIG_480_56) = isone(-BIG_480_56_comp(a, b))
BIG_480_56() = (a = BIG_480_56(undef); BIG_480_56_zero(a); a)
Base.pointer(a::BIG_512_56) = reinterpret(Ptr{BIG_512_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_512_56}}, a::BIG_512_56) = pointer(a)
Base.:(==)(a::BIG_512_56, b::BIG_512_56) = iszero(BIG_512_56_comp(a, b))
Base.isless(a::BIG_512_56, b::BIG_512_56) = isone(-BIG_512_56_comp(a, b))
BIG_512_56() = (a = BIG_512_56(undef); BIG_512_56_zero(a); a)
Base.pointer(a::BIG_512_60) = reinterpret(Ptr{BIG_512_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_512_60}}, a::BIG_512_60) = pointer(a)
Base.:(==)(a::BIG_512_60, b::BIG_512_60) = iszero(BIG_512_60_comp(a, b))
Base.isless(a::BIG_512_60, b::BIG_512_60) = isone(-BIG_512_60_comp(a, b))
BIG_512_60() = (a = BIG_512_60(undef); BIG_512_60_zero(a); a)
Base.pointer(a::BIG_528_60) = reinterpret(Ptr{BIG_528_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_528_60}}, a::BIG_528_60) = pointer(a)
Base.:(==)(a::BIG_528_60, b::BIG_528_60) = iszero(BIG_528_60_comp(a, b))
Base.isless(a::BIG_528_60, b::BIG_528_60) = isone(-BIG_528_60_comp(a, b))
BIG_528_60() = (a = BIG_528_60(undef); BIG_528_60_zero(a); a)
Base.pointer(a::BIG_560_58) = reinterpret(Ptr{BIG_560_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{BIG_560_58}}, a::BIG_560_58) = pointer(a)
Base.:(==)(a::BIG_560_58, b::BIG_560_58) = iszero(BIG_560_58_comp(a, b))
Base.isless(a::BIG_560_58, b::BIG_560_58) = isone(-BIG_560_58_comp(a, b))
BIG_560_58() = (a = BIG_560_58(undef); BIG_560_58_zero(a); a)
Base.pointer(a::DBIG_1024_58) = reinterpret(Ptr{DBIG_1024_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_1024_58}}, a::DBIG_1024_58) = pointer(a)
Base.:(==)(a::DBIG_1024_58, b::DBIG_1024_58) = iszero(BIG_1024_58_dcomp(a, b))
Base.isless(a::DBIG_1024_58, b::DBIG_1024_58) = isone(-BIG_1024_58_dcomp(a, b))
DBIG_1024_58() = (a = DBIG_1024_58(undef); BIG_1024_58_dzero(a); a)
Base.pointer(a::DBIG_256_56) = reinterpret(Ptr{DBIG_256_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_256_56}}, a::DBIG_256_56) = pointer(a)
Base.:(==)(a::DBIG_256_56, b::DBIG_256_56) = iszero(BIG_256_56_dcomp(a, b))
Base.isless(a::DBIG_256_56, b::DBIG_256_56) = isone(-BIG_256_56_dcomp(a, b))
DBIG_256_56() = (a = DBIG_256_56(undef); BIG_256_56_dzero(a); a)
Base.pointer(a::DBIG_336_60) = reinterpret(Ptr{DBIG_336_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_336_60}}, a::DBIG_336_60) = pointer(a)
Base.:(==)(a::DBIG_336_60, b::DBIG_336_60) = iszero(BIG_336_60_dcomp(a, b))
Base.isless(a::DBIG_336_60, b::DBIG_336_60) = isone(-BIG_336_60_dcomp(a, b))
DBIG_336_60() = (a = DBIG_336_60(undef); BIG_336_60_dzero(a); a)
Base.pointer(a::DBIG_384_56) = reinterpret(Ptr{DBIG_384_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_384_56}}, a::DBIG_384_56) = pointer(a)
Base.:(==)(a::DBIG_384_56, b::DBIG_384_56) = iszero(BIG_384_56_dcomp(a, b))
Base.isless(a::DBIG_384_56, b::DBIG_384_56) = isone(-BIG_384_56_dcomp(a, b))
DBIG_384_56() = (a = DBIG_384_56(undef); BIG_384_56_dzero(a); a)
Base.pointer(a::DBIG_384_58) = reinterpret(Ptr{DBIG_384_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_384_58}}, a::DBIG_384_58) = pointer(a)
Base.:(==)(a::DBIG_384_58, b::DBIG_384_58) = iszero(BIG_384_58_dcomp(a, b))
Base.isless(a::DBIG_384_58, b::DBIG_384_58) = isone(-BIG_384_58_dcomp(a, b))
DBIG_384_58() = (a = DBIG_384_58(undef); BIG_384_58_dzero(a); a)
Base.pointer(a::DBIG_416_60) = reinterpret(Ptr{DBIG_416_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_416_60}}, a::DBIG_416_60) = pointer(a)
Base.:(==)(a::DBIG_416_60, b::DBIG_416_60) = iszero(BIG_416_60_dcomp(a, b))
Base.isless(a::DBIG_416_60, b::DBIG_416_60) = isone(-BIG_416_60_dcomp(a, b))
DBIG_416_60() = (a = DBIG_416_60(undef); BIG_416_60_dzero(a); a)
Base.pointer(a::DBIG_448_58) = reinterpret(Ptr{DBIG_448_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_448_58}}, a::DBIG_448_58) = pointer(a)
Base.:(==)(a::DBIG_448_58, b::DBIG_448_58) = iszero(BIG_448_58_dcomp(a, b))
Base.isless(a::DBIG_448_58, b::DBIG_448_58) = isone(-BIG_448_58_dcomp(a, b))
DBIG_448_58() = (a = DBIG_448_58(undef); BIG_448_58_dzero(a); a)
Base.pointer(a::DBIG_464_60) = reinterpret(Ptr{DBIG_464_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_464_60}}, a::DBIG_464_60) = pointer(a)
Base.:(==)(a::DBIG_464_60, b::DBIG_464_60) = iszero(BIG_464_60_dcomp(a, b))
Base.isless(a::DBIG_464_60, b::DBIG_464_60) = isone(-BIG_464_60_dcomp(a, b))
DBIG_464_60() = (a = DBIG_464_60(undef); BIG_464_60_dzero(a); a)
Base.pointer(a::DBIG_480_56) = reinterpret(Ptr{DBIG_480_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_480_56}}, a::DBIG_480_56) = pointer(a)
Base.:(==)(a::DBIG_480_56, b::DBIG_480_56) = iszero(BIG_480_56_dcomp(a, b))
Base.isless(a::DBIG_480_56, b::DBIG_480_56) = isone(-BIG_480_56_dcomp(a, b))
DBIG_480_56() = (a = DBIG_480_56(undef); BIG_480_56_dzero(a); a)
Base.pointer(a::DBIG_512_56) = reinterpret(Ptr{DBIG_512_56}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_512_56}}, a::DBIG_512_56) = pointer(a)
Base.:(==)(a::DBIG_512_56, b::DBIG_512_56) = iszero(BIG_512_56_dcomp(a, b))
Base.isless(a::DBIG_512_56, b::DBIG_512_56) = isone(-BIG_512_56_dcomp(a, b))
DBIG_512_56() = (a = DBIG_512_56(undef); BIG_512_56_dzero(a); a)
Base.pointer(a::DBIG_512_60) = reinterpret(Ptr{DBIG_512_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_512_60}}, a::DBIG_512_60) = pointer(a)
Base.:(==)(a::DBIG_512_60, b::DBIG_512_60) = iszero(BIG_512_60_dcomp(a, b))
Base.isless(a::DBIG_512_60, b::DBIG_512_60) = isone(-BIG_512_60_dcomp(a, b))
DBIG_512_60() = (a = DBIG_512_60(undef); BIG_512_60_dzero(a); a)
Base.pointer(a::DBIG_528_60) = reinterpret(Ptr{DBIG_528_60}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_528_60}}, a::DBIG_528_60) = pointer(a)
Base.:(==)(a::DBIG_528_60, b::DBIG_528_60) = iszero(BIG_528_60_dcomp(a, b))
Base.isless(a::DBIG_528_60, b::DBIG_528_60) = isone(-BIG_528_60_dcomp(a, b))
DBIG_528_60() = (a = DBIG_528_60(undef); BIG_528_60_dzero(a); a)
Base.pointer(a::DBIG_560_58) = reinterpret(Ptr{DBIG_560_58}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{DBIG_560_58}}, a::DBIG_560_58) = pointer(a)
Base.:(==)(a::DBIG_560_58, b::DBIG_560_58) = iszero(BIG_560_58_dcomp(a, b))
Base.isless(a::DBIG_560_58, b::DBIG_560_58) = isone(-BIG_560_58_dcomp(a, b))
DBIG_560_58() = (a = DBIG_560_58(undef); BIG_560_58_dzero(a); a)
Base.pointer(a::ECP2_BLS381) = reinterpret(Ptr{ECP2_BLS381}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP2_BLS381}}, a::ECP2_BLS381) = pointer(a)
Base.:(==)(a::ECP2_BLS381, b::ECP2_BLS381) = isone(ECP2_BLS381_equals(a, b))
ECP2_BLS381() = (a = ECP2_BLS381(undef); ECP2_BLS381_inf(a); a)
Base.pointer(a::ECP2_BLS383) = reinterpret(Ptr{ECP2_BLS383}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP2_BLS383}}, a::ECP2_BLS383) = pointer(a)
Base.:(==)(a::ECP2_BLS383, b::ECP2_BLS383) = isone(ECP2_BLS383_equals(a, b))
ECP2_BLS383() = (a = ECP2_BLS383(undef); ECP2_BLS383_inf(a); a)
Base.pointer(a::ECP2_BLS461) = reinterpret(Ptr{ECP2_BLS461}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP2_BLS461}}, a::ECP2_BLS461) = pointer(a)
Base.:(==)(a::ECP2_BLS461, b::ECP2_BLS461) = isone(ECP2_BLS461_equals(a, b))
ECP2_BLS461() = (a = ECP2_BLS461(undef); ECP2_BLS461_inf(a); a)
Base.pointer(a::ECP2_BN254) = reinterpret(Ptr{ECP2_BN254}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP2_BN254}}, a::ECP2_BN254) = pointer(a)
Base.:(==)(a::ECP2_BN254, b::ECP2_BN254) = isone(ECP2_BN254_equals(a, b))
ECP2_BN254() = (a = ECP2_BN254(undef); ECP2_BN254_inf(a); a)
Base.pointer(a::ECP2_BN254CX) = reinterpret(Ptr{ECP2_BN254CX}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP2_BN254CX}}, a::ECP2_BN254CX) = pointer(a)
Base.:(==)(a::ECP2_BN254CX, b::ECP2_BN254CX) = isone(ECP2_BN254CX_equals(a, b))
ECP2_BN254CX() = (a = ECP2_BN254CX(undef); ECP2_BN254CX_inf(a); a)
Base.pointer(a::ECP2_FP256BN) = reinterpret(Ptr{ECP2_FP256BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP2_FP256BN}}, a::ECP2_FP256BN) = pointer(a)
Base.:(==)(a::ECP2_FP256BN, b::ECP2_FP256BN) = isone(ECP2_FP256BN_equals(a, b))
ECP2_FP256BN() = (a = ECP2_FP256BN(undef); ECP2_FP256BN_inf(a); a)
Base.pointer(a::ECP2_FP512BN) = reinterpret(Ptr{ECP2_FP512BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP2_FP512BN}}, a::ECP2_FP512BN) = pointer(a)
Base.:(==)(a::ECP2_FP512BN, b::ECP2_FP512BN) = isone(ECP2_FP512BN_equals(a, b))
ECP2_FP512BN() = (a = ECP2_FP512BN(undef); ECP2_FP512BN_inf(a); a)
Base.pointer(a::ECP4_BLS24) = reinterpret(Ptr{ECP4_BLS24}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP4_BLS24}}, a::ECP4_BLS24) = pointer(a)
Base.:(==)(a::ECP4_BLS24, b::ECP4_BLS24) = isone(ECP4_BLS24_equals(a, b))
ECP4_BLS24() = (a = ECP4_BLS24(undef); ECP4_BLS24_inf(a); a)
Base.pointer(a::ECP8_BLS48) = reinterpret(Ptr{ECP8_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP8_BLS48}}, a::ECP8_BLS48) = pointer(a)
Base.:(==)(a::ECP8_BLS48, b::ECP8_BLS48) = isone(ECP8_BLS48_equals(a, b))
ECP8_BLS48() = (a = ECP8_BLS48(undef); ECP8_BLS48_inf(a); a)
Base.pointer(a::ECP_ANSSI) = reinterpret(Ptr{ECP_ANSSI}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_ANSSI}}, a::ECP_ANSSI) = pointer(a)
Base.:(==)(a::ECP_ANSSI, b::ECP_ANSSI) = isone(ECP_ANSSI_equals(a, b))
ECP_ANSSI() = (a = ECP_ANSSI(undef); ECP_ANSSI_inf(a); a)
Base.pointer(a::ECP_BLS24) = reinterpret(Ptr{ECP_BLS24}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BLS24}}, a::ECP_BLS24) = pointer(a)
Base.:(==)(a::ECP_BLS24, b::ECP_BLS24) = isone(ECP_BLS24_equals(a, b))
ECP_BLS24() = (a = ECP_BLS24(undef); ECP_BLS24_inf(a); a)
Base.pointer(a::ECP_BLS381) = reinterpret(Ptr{ECP_BLS381}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BLS381}}, a::ECP_BLS381) = pointer(a)
Base.:(==)(a::ECP_BLS381, b::ECP_BLS381) = isone(ECP_BLS381_equals(a, b))
ECP_BLS381() = (a = ECP_BLS381(undef); ECP_BLS381_inf(a); a)
Base.pointer(a::ECP_BLS383) = reinterpret(Ptr{ECP_BLS383}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BLS383}}, a::ECP_BLS383) = pointer(a)
Base.:(==)(a::ECP_BLS383, b::ECP_BLS383) = isone(ECP_BLS383_equals(a, b))
ECP_BLS383() = (a = ECP_BLS383(undef); ECP_BLS383_inf(a); a)
Base.pointer(a::ECP_BLS461) = reinterpret(Ptr{ECP_BLS461}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BLS461}}, a::ECP_BLS461) = pointer(a)
Base.:(==)(a::ECP_BLS461, b::ECP_BLS461) = isone(ECP_BLS461_equals(a, b))
ECP_BLS461() = (a = ECP_BLS461(undef); ECP_BLS461_inf(a); a)
Base.pointer(a::ECP_BLS48) = reinterpret(Ptr{ECP_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BLS48}}, a::ECP_BLS48) = pointer(a)
Base.:(==)(a::ECP_BLS48, b::ECP_BLS48) = isone(ECP_BLS48_equals(a, b))
ECP_BLS48() = (a = ECP_BLS48(undef); ECP_BLS48_inf(a); a)
Base.pointer(a::ECP_BN254) = reinterpret(Ptr{ECP_BN254}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BN254}}, a::ECP_BN254) = pointer(a)
Base.:(==)(a::ECP_BN254, b::ECP_BN254) = isone(ECP_BN254_equals(a, b))
ECP_BN254() = (a = ECP_BN254(undef); ECP_BN254_inf(a); a)
Base.pointer(a::ECP_BN254CX) = reinterpret(Ptr{ECP_BN254CX}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BN254CX}}, a::ECP_BN254CX) = pointer(a)
Base.:(==)(a::ECP_BN254CX, b::ECP_BN254CX) = isone(ECP_BN254CX_equals(a, b))
ECP_BN254CX() = (a = ECP_BN254CX(undef); ECP_BN254CX_inf(a); a)
Base.pointer(a::ECP_BRAINPOOL) = reinterpret(Ptr{ECP_BRAINPOOL}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_BRAINPOOL}}, a::ECP_BRAINPOOL) = pointer(a)
Base.:(==)(a::ECP_BRAINPOOL, b::ECP_BRAINPOOL) = isone(ECP_BRAINPOOL_equals(a, b))
ECP_BRAINPOOL() = (a = ECP_BRAINPOOL(undef); ECP_BRAINPOOL_inf(a); a)
Base.pointer(a::ECP_C25519) = reinterpret(Ptr{ECP_C25519}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_C25519}}, a::ECP_C25519) = pointer(a)
Base.:(==)(a::ECP_C25519, b::ECP_C25519) = isone(ECP_C25519_equals(a, b))
ECP_C25519() = (a = ECP_C25519(undef); ECP_C25519_inf(a); a)
Base.pointer(a::ECP_C41417) = reinterpret(Ptr{ECP_C41417}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_C41417}}, a::ECP_C41417) = pointer(a)
Base.:(==)(a::ECP_C41417, b::ECP_C41417) = isone(ECP_C41417_equals(a, b))
ECP_C41417() = (a = ECP_C41417(undef); ECP_C41417_inf(a); a)
Base.pointer(a::ECP_ED25519) = reinterpret(Ptr{ECP_ED25519}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_ED25519}}, a::ECP_ED25519) = pointer(a)
Base.:(==)(a::ECP_ED25519, b::ECP_ED25519) = isone(ECP_ED25519_equals(a, b))
ECP_ED25519() = (a = ECP_ED25519(undef); ECP_ED25519_inf(a); a)
Base.pointer(a::ECP_FP256BN) = reinterpret(Ptr{ECP_FP256BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_FP256BN}}, a::ECP_FP256BN) = pointer(a)
Base.:(==)(a::ECP_FP256BN, b::ECP_FP256BN) = isone(ECP_FP256BN_equals(a, b))
ECP_FP256BN() = (a = ECP_FP256BN(undef); ECP_FP256BN_inf(a); a)
Base.pointer(a::ECP_FP512BN) = reinterpret(Ptr{ECP_FP512BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_FP512BN}}, a::ECP_FP512BN) = pointer(a)
Base.:(==)(a::ECP_FP512BN, b::ECP_FP512BN) = isone(ECP_FP512BN_equals(a, b))
ECP_FP512BN() = (a = ECP_FP512BN(undef); ECP_FP512BN_inf(a); a)
Base.pointer(a::ECP_GOLDILOCKS) = reinterpret(Ptr{ECP_GOLDILOCKS}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_GOLDILOCKS}}, a::ECP_GOLDILOCKS) = pointer(a)
Base.:(==)(a::ECP_GOLDILOCKS, b::ECP_GOLDILOCKS) = isone(ECP_GOLDILOCKS_equals(a, b))
ECP_GOLDILOCKS() = (a = ECP_GOLDILOCKS(undef); ECP_GOLDILOCKS_inf(a); a)
Base.pointer(a::ECP_HIFIVE) = reinterpret(Ptr{ECP_HIFIVE}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_HIFIVE}}, a::ECP_HIFIVE) = pointer(a)
Base.:(==)(a::ECP_HIFIVE, b::ECP_HIFIVE) = isone(ECP_HIFIVE_equals(a, b))
ECP_HIFIVE() = (a = ECP_HIFIVE(undef); ECP_HIFIVE_inf(a); a)
Base.pointer(a::ECP_NIST256) = reinterpret(Ptr{ECP_NIST256}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NIST256}}, a::ECP_NIST256) = pointer(a)
Base.:(==)(a::ECP_NIST256, b::ECP_NIST256) = isone(ECP_NIST256_equals(a, b))
ECP_NIST256() = (a = ECP_NIST256(undef); ECP_NIST256_inf(a); a)
Base.pointer(a::ECP_NIST384) = reinterpret(Ptr{ECP_NIST384}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NIST384}}, a::ECP_NIST384) = pointer(a)
Base.:(==)(a::ECP_NIST384, b::ECP_NIST384) = isone(ECP_NIST384_equals(a, b))
ECP_NIST384() = (a = ECP_NIST384(undef); ECP_NIST384_inf(a); a)
Base.pointer(a::ECP_NIST521) = reinterpret(Ptr{ECP_NIST521}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NIST521}}, a::ECP_NIST521) = pointer(a)
Base.:(==)(a::ECP_NIST521, b::ECP_NIST521) = isone(ECP_NIST521_equals(a, b))
ECP_NIST521() = (a = ECP_NIST521(undef); ECP_NIST521_inf(a); a)
Base.pointer(a::ECP_NUMS256E) = reinterpret(Ptr{ECP_NUMS256E}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NUMS256E}}, a::ECP_NUMS256E) = pointer(a)
Base.:(==)(a::ECP_NUMS256E, b::ECP_NUMS256E) = isone(ECP_NUMS256E_equals(a, b))
ECP_NUMS256E() = (a = ECP_NUMS256E(undef); ECP_NUMS256E_inf(a); a)
Base.pointer(a::ECP_NUMS256W) = reinterpret(Ptr{ECP_NUMS256W}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NUMS256W}}, a::ECP_NUMS256W) = pointer(a)
Base.:(==)(a::ECP_NUMS256W, b::ECP_NUMS256W) = isone(ECP_NUMS256W_equals(a, b))
ECP_NUMS256W() = (a = ECP_NUMS256W(undef); ECP_NUMS256W_inf(a); a)
Base.pointer(a::ECP_NUMS384E) = reinterpret(Ptr{ECP_NUMS384E}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NUMS384E}}, a::ECP_NUMS384E) = pointer(a)
Base.:(==)(a::ECP_NUMS384E, b::ECP_NUMS384E) = isone(ECP_NUMS384E_equals(a, b))
ECP_NUMS384E() = (a = ECP_NUMS384E(undef); ECP_NUMS384E_inf(a); a)
Base.pointer(a::ECP_NUMS384W) = reinterpret(Ptr{ECP_NUMS384W}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NUMS384W}}, a::ECP_NUMS384W) = pointer(a)
Base.:(==)(a::ECP_NUMS384W, b::ECP_NUMS384W) = isone(ECP_NUMS384W_equals(a, b))
ECP_NUMS384W() = (a = ECP_NUMS384W(undef); ECP_NUMS384W_inf(a); a)
Base.pointer(a::ECP_NUMS512E) = reinterpret(Ptr{ECP_NUMS512E}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NUMS512E}}, a::ECP_NUMS512E) = pointer(a)
Base.:(==)(a::ECP_NUMS512E, b::ECP_NUMS512E) = isone(ECP_NUMS512E_equals(a, b))
ECP_NUMS512E() = (a = ECP_NUMS512E(undef); ECP_NUMS512E_inf(a); a)
Base.pointer(a::ECP_NUMS512W) = reinterpret(Ptr{ECP_NUMS512W}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_NUMS512W}}, a::ECP_NUMS512W) = pointer(a)
Base.:(==)(a::ECP_NUMS512W, b::ECP_NUMS512W) = isone(ECP_NUMS512W_equals(a, b))
ECP_NUMS512W() = (a = ECP_NUMS512W(undef); ECP_NUMS512W_inf(a); a)
Base.pointer(a::ECP_SECP256K1) = reinterpret(Ptr{ECP_SECP256K1}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{ECP_SECP256K1}}, a::ECP_SECP256K1) = pointer(a)
Base.:(==)(a::ECP_SECP256K1, b::ECP_SECP256K1) = isone(ECP_SECP256K1_equals(a, b))
ECP_SECP256K1() = (a = ECP_SECP256K1(undef); ECP_SECP256K1_inf(a); a)
Base.pointer(a::FP12_BLS381) = reinterpret(Ptr{FP12_BLS381}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP12_BLS381}}, a::FP12_BLS381) = pointer(a)
Base.:(==)(a::FP12_BLS381, b::FP12_BLS381) = isone(FP12_BLS381_equals(a, b))
FP12_BLS381() = (a = FP12_BLS381(undef); FP12_BLS381_zero(a); a)
Base.pointer(a::FP12_BLS383) = reinterpret(Ptr{FP12_BLS383}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP12_BLS383}}, a::FP12_BLS383) = pointer(a)
Base.:(==)(a::FP12_BLS383, b::FP12_BLS383) = isone(FP12_BLS383_equals(a, b))
FP12_BLS383() = (a = FP12_BLS383(undef); FP12_BLS383_zero(a); a)
Base.pointer(a::FP12_BLS461) = reinterpret(Ptr{FP12_BLS461}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP12_BLS461}}, a::FP12_BLS461) = pointer(a)
Base.:(==)(a::FP12_BLS461, b::FP12_BLS461) = isone(FP12_BLS461_equals(a, b))
FP12_BLS461() = (a = FP12_BLS461(undef); FP12_BLS461_zero(a); a)
Base.pointer(a::FP12_BN254) = reinterpret(Ptr{FP12_BN254}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP12_BN254}}, a::FP12_BN254) = pointer(a)
Base.:(==)(a::FP12_BN254, b::FP12_BN254) = isone(FP12_BN254_equals(a, b))
FP12_BN254() = (a = FP12_BN254(undef); FP12_BN254_zero(a); a)
Base.pointer(a::FP12_BN254CX) = reinterpret(Ptr{FP12_BN254CX}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP12_BN254CX}}, a::FP12_BN254CX) = pointer(a)
Base.:(==)(a::FP12_BN254CX, b::FP12_BN254CX) = isone(FP12_BN254CX_equals(a, b))
FP12_BN254CX() = (a = FP12_BN254CX(undef); FP12_BN254CX_zero(a); a)
Base.pointer(a::FP12_FP256BN) = reinterpret(Ptr{FP12_FP256BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP12_FP256BN}}, a::FP12_FP256BN) = pointer(a)
Base.:(==)(a::FP12_FP256BN, b::FP12_FP256BN) = isone(FP12_FP256BN_equals(a, b))
FP12_FP256BN() = (a = FP12_FP256BN(undef); FP12_FP256BN_zero(a); a)
Base.pointer(a::FP12_FP512BN) = reinterpret(Ptr{FP12_FP512BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP12_FP512BN}}, a::FP12_FP512BN) = pointer(a)
Base.:(==)(a::FP12_FP512BN, b::FP12_FP512BN) = isone(FP12_FP512BN_equals(a, b))
FP12_FP512BN() = (a = FP12_FP512BN(undef); FP12_FP512BN_zero(a); a)
Base.pointer(a::FP16_BLS48) = reinterpret(Ptr{FP16_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP16_BLS48}}, a::FP16_BLS48) = pointer(a)
Base.:(==)(a::FP16_BLS48, b::FP16_BLS48) = isone(FP16_BLS48_equals(a, b))
FP16_BLS48() = (a = FP16_BLS48(undef); FP16_BLS48_zero(a); a)
Base.pointer(a::FP24_BLS24) = reinterpret(Ptr{FP24_BLS24}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP24_BLS24}}, a::FP24_BLS24) = pointer(a)
Base.:(==)(a::FP24_BLS24, b::FP24_BLS24) = isone(FP24_BLS24_equals(a, b))
FP24_BLS24() = (a = FP24_BLS24(undef); FP24_BLS24_zero(a); a)
Base.pointer(a::FP2_BLS24) = reinterpret(Ptr{FP2_BLS24}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_BLS24}}, a::FP2_BLS24) = pointer(a)
Base.:(==)(a::FP2_BLS24, b::FP2_BLS24) = isone(FP2_BLS24_equals(a, b))
FP2_BLS24() = (a = FP2_BLS24(undef); FP2_BLS24_zero(a); a)
Base.pointer(a::FP2_BLS381) = reinterpret(Ptr{FP2_BLS381}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_BLS381}}, a::FP2_BLS381) = pointer(a)
Base.:(==)(a::FP2_BLS381, b::FP2_BLS381) = isone(FP2_BLS381_equals(a, b))
FP2_BLS381() = (a = FP2_BLS381(undef); FP2_BLS381_zero(a); a)
Base.pointer(a::FP2_BLS383) = reinterpret(Ptr{FP2_BLS383}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_BLS383}}, a::FP2_BLS383) = pointer(a)
Base.:(==)(a::FP2_BLS383, b::FP2_BLS383) = isone(FP2_BLS383_equals(a, b))
FP2_BLS383() = (a = FP2_BLS383(undef); FP2_BLS383_zero(a); a)
Base.pointer(a::FP2_BLS461) = reinterpret(Ptr{FP2_BLS461}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_BLS461}}, a::FP2_BLS461) = pointer(a)
Base.:(==)(a::FP2_BLS461, b::FP2_BLS461) = isone(FP2_BLS461_equals(a, b))
FP2_BLS461() = (a = FP2_BLS461(undef); FP2_BLS461_zero(a); a)
Base.pointer(a::FP2_BLS48) = reinterpret(Ptr{FP2_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_BLS48}}, a::FP2_BLS48) = pointer(a)
Base.:(==)(a::FP2_BLS48, b::FP2_BLS48) = isone(FP2_BLS48_equals(a, b))
FP2_BLS48() = (a = FP2_BLS48(undef); FP2_BLS48_zero(a); a)
Base.pointer(a::FP2_BN254) = reinterpret(Ptr{FP2_BN254}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_BN254}}, a::FP2_BN254) = pointer(a)
Base.:(==)(a::FP2_BN254, b::FP2_BN254) = isone(FP2_BN254_equals(a, b))
FP2_BN254() = (a = FP2_BN254(undef); FP2_BN254_zero(a); a)
Base.pointer(a::FP2_BN254CX) = reinterpret(Ptr{FP2_BN254CX}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_BN254CX}}, a::FP2_BN254CX) = pointer(a)
Base.:(==)(a::FP2_BN254CX, b::FP2_BN254CX) = isone(FP2_BN254CX_equals(a, b))
FP2_BN254CX() = (a = FP2_BN254CX(undef); FP2_BN254CX_zero(a); a)
Base.pointer(a::FP2_FP256BN) = reinterpret(Ptr{FP2_FP256BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_FP256BN}}, a::FP2_FP256BN) = pointer(a)
Base.:(==)(a::FP2_FP256BN, b::FP2_FP256BN) = isone(FP2_FP256BN_equals(a, b))
FP2_FP256BN() = (a = FP2_FP256BN(undef); FP2_FP256BN_zero(a); a)
Base.pointer(a::FP2_FP512BN) = reinterpret(Ptr{FP2_FP512BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP2_FP512BN}}, a::FP2_FP512BN) = pointer(a)
Base.:(==)(a::FP2_FP512BN, b::FP2_FP512BN) = isone(FP2_FP512BN_equals(a, b))
FP2_FP512BN() = (a = FP2_FP512BN(undef); FP2_FP512BN_zero(a); a)
Base.pointer(a::FP48_BLS48) = reinterpret(Ptr{FP48_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP48_BLS48}}, a::FP48_BLS48) = pointer(a)
Base.:(==)(a::FP48_BLS48, b::FP48_BLS48) = isone(FP48_BLS48_equals(a, b))
FP48_BLS48() = (a = FP48_BLS48(undef); FP48_BLS48_zero(a); a)
Base.pointer(a::FP4_BLS24) = reinterpret(Ptr{FP4_BLS24}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_BLS24}}, a::FP4_BLS24) = pointer(a)
Base.:(==)(a::FP4_BLS24, b::FP4_BLS24) = isone(FP4_BLS24_equals(a, b))
FP4_BLS24() = (a = FP4_BLS24(undef); FP4_BLS24_zero(a); a)
Base.pointer(a::FP4_BLS381) = reinterpret(Ptr{FP4_BLS381}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_BLS381}}, a::FP4_BLS381) = pointer(a)
Base.:(==)(a::FP4_BLS381, b::FP4_BLS381) = isone(FP4_BLS381_equals(a, b))
FP4_BLS381() = (a = FP4_BLS381(undef); FP4_BLS381_zero(a); a)
Base.pointer(a::FP4_BLS383) = reinterpret(Ptr{FP4_BLS383}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_BLS383}}, a::FP4_BLS383) = pointer(a)
Base.:(==)(a::FP4_BLS383, b::FP4_BLS383) = isone(FP4_BLS383_equals(a, b))
FP4_BLS383() = (a = FP4_BLS383(undef); FP4_BLS383_zero(a); a)
Base.pointer(a::FP4_BLS461) = reinterpret(Ptr{FP4_BLS461}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_BLS461}}, a::FP4_BLS461) = pointer(a)
Base.:(==)(a::FP4_BLS461, b::FP4_BLS461) = isone(FP4_BLS461_equals(a, b))
FP4_BLS461() = (a = FP4_BLS461(undef); FP4_BLS461_zero(a); a)
Base.pointer(a::FP4_BLS48) = reinterpret(Ptr{FP4_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_BLS48}}, a::FP4_BLS48) = pointer(a)
Base.:(==)(a::FP4_BLS48, b::FP4_BLS48) = isone(FP4_BLS48_equals(a, b))
FP4_BLS48() = (a = FP4_BLS48(undef); FP4_BLS48_zero(a); a)
Base.pointer(a::FP4_BN254) = reinterpret(Ptr{FP4_BN254}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_BN254}}, a::FP4_BN254) = pointer(a)
Base.:(==)(a::FP4_BN254, b::FP4_BN254) = isone(FP4_BN254_equals(a, b))
FP4_BN254() = (a = FP4_BN254(undef); FP4_BN254_zero(a); a)
Base.pointer(a::FP4_BN254CX) = reinterpret(Ptr{FP4_BN254CX}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_BN254CX}}, a::FP4_BN254CX) = pointer(a)
Base.:(==)(a::FP4_BN254CX, b::FP4_BN254CX) = isone(FP4_BN254CX_equals(a, b))
FP4_BN254CX() = (a = FP4_BN254CX(undef); FP4_BN254CX_zero(a); a)
Base.pointer(a::FP4_FP256BN) = reinterpret(Ptr{FP4_FP256BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_FP256BN}}, a::FP4_FP256BN) = pointer(a)
Base.:(==)(a::FP4_FP256BN, b::FP4_FP256BN) = isone(FP4_FP256BN_equals(a, b))
FP4_FP256BN() = (a = FP4_FP256BN(undef); FP4_FP256BN_zero(a); a)
Base.pointer(a::FP4_FP512BN) = reinterpret(Ptr{FP4_FP512BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP4_FP512BN}}, a::FP4_FP512BN) = pointer(a)
Base.:(==)(a::FP4_FP512BN, b::FP4_FP512BN) = isone(FP4_FP512BN_equals(a, b))
FP4_FP512BN() = (a = FP4_FP512BN(undef); FP4_FP512BN_zero(a); a)
Base.pointer(a::FP8_BLS24) = reinterpret(Ptr{FP8_BLS24}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP8_BLS24}}, a::FP8_BLS24) = pointer(a)
Base.:(==)(a::FP8_BLS24, b::FP8_BLS24) = isone(FP8_BLS24_equals(a, b))
FP8_BLS24() = (a = FP8_BLS24(undef); FP8_BLS24_zero(a); a)
Base.pointer(a::FP8_BLS48) = reinterpret(Ptr{FP8_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP8_BLS48}}, a::FP8_BLS48) = pointer(a)
Base.:(==)(a::FP8_BLS48, b::FP8_BLS48) = isone(FP8_BLS48_equals(a, b))
FP8_BLS48() = (a = FP8_BLS48(undef); FP8_BLS48_zero(a); a)
Base.pointer(a::FP_25519) = reinterpret(Ptr{FP_25519}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_25519}}, a::FP_25519) = pointer(a)
Base.:(==)(a::FP_25519, b::FP_25519) = isone(FP_25519_equals(a, b))
FP_25519() = (a = FP_25519(undef); FP_25519_zero(a); a)
Base.pointer(a::FP_256PME) = reinterpret(Ptr{FP_256PME}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_256PME}}, a::FP_256PME) = pointer(a)
Base.:(==)(a::FP_256PME, b::FP_256PME) = isone(FP_256PME_equals(a, b))
FP_256PME() = (a = FP_256PME(undef); FP_256PME_zero(a); a)
Base.pointer(a::FP_256PMW) = reinterpret(Ptr{FP_256PMW}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_256PMW}}, a::FP_256PMW) = pointer(a)
Base.:(==)(a::FP_256PMW, b::FP_256PMW) = isone(FP_256PMW_equals(a, b))
FP_256PMW() = (a = FP_256PMW(undef); FP_256PMW_zero(a); a)
Base.pointer(a::FP_384PM) = reinterpret(Ptr{FP_384PM}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_384PM}}, a::FP_384PM) = pointer(a)
Base.:(==)(a::FP_384PM, b::FP_384PM) = isone(FP_384PM_equals(a, b))
FP_384PM() = (a = FP_384PM(undef); FP_384PM_zero(a); a)
Base.pointer(a::FP_512PM) = reinterpret(Ptr{FP_512PM}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_512PM}}, a::FP_512PM) = pointer(a)
Base.:(==)(a::FP_512PM, b::FP_512PM) = isone(FP_512PM_equals(a, b))
FP_512PM() = (a = FP_512PM(undef); FP_512PM_zero(a); a)
Base.pointer(a::FP_ANSSI) = reinterpret(Ptr{FP_ANSSI}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_ANSSI}}, a::FP_ANSSI) = pointer(a)
Base.:(==)(a::FP_ANSSI, b::FP_ANSSI) = isone(FP_ANSSI_equals(a, b))
FP_ANSSI() = (a = FP_ANSSI(undef); FP_ANSSI_zero(a); a)
Base.pointer(a::FP_BLS24) = reinterpret(Ptr{FP_BLS24}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BLS24}}, a::FP_BLS24) = pointer(a)
Base.:(==)(a::FP_BLS24, b::FP_BLS24) = isone(FP_BLS24_equals(a, b))
FP_BLS24() = (a = FP_BLS24(undef); FP_BLS24_zero(a); a)
Base.pointer(a::FP_BLS381) = reinterpret(Ptr{FP_BLS381}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BLS381}}, a::FP_BLS381) = pointer(a)
Base.:(==)(a::FP_BLS381, b::FP_BLS381) = isone(FP_BLS381_equals(a, b))
FP_BLS381() = (a = FP_BLS381(undef); FP_BLS381_zero(a); a)
Base.pointer(a::FP_BLS383) = reinterpret(Ptr{FP_BLS383}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BLS383}}, a::FP_BLS383) = pointer(a)
Base.:(==)(a::FP_BLS383, b::FP_BLS383) = isone(FP_BLS383_equals(a, b))
FP_BLS383() = (a = FP_BLS383(undef); FP_BLS383_zero(a); a)
Base.pointer(a::FP_BLS461) = reinterpret(Ptr{FP_BLS461}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BLS461}}, a::FP_BLS461) = pointer(a)
Base.:(==)(a::FP_BLS461, b::FP_BLS461) = isone(FP_BLS461_equals(a, b))
FP_BLS461() = (a = FP_BLS461(undef); FP_BLS461_zero(a); a)
Base.pointer(a::FP_BLS48) = reinterpret(Ptr{FP_BLS48}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BLS48}}, a::FP_BLS48) = pointer(a)
Base.:(==)(a::FP_BLS48, b::FP_BLS48) = isone(FP_BLS48_equals(a, b))
FP_BLS48() = (a = FP_BLS48(undef); FP_BLS48_zero(a); a)
Base.pointer(a::FP_BN254) = reinterpret(Ptr{FP_BN254}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BN254}}, a::FP_BN254) = pointer(a)
Base.:(==)(a::FP_BN254, b::FP_BN254) = isone(FP_BN254_equals(a, b))
FP_BN254() = (a = FP_BN254(undef); FP_BN254_zero(a); a)
Base.pointer(a::FP_BN254CX) = reinterpret(Ptr{FP_BN254CX}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BN254CX}}, a::FP_BN254CX) = pointer(a)
Base.:(==)(a::FP_BN254CX, b::FP_BN254CX) = isone(FP_BN254CX_equals(a, b))
FP_BN254CX() = (a = FP_BN254CX(undef); FP_BN254CX_zero(a); a)
Base.pointer(a::FP_BRAINPOOL) = reinterpret(Ptr{FP_BRAINPOOL}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_BRAINPOOL}}, a::FP_BRAINPOOL) = pointer(a)
Base.:(==)(a::FP_BRAINPOOL, b::FP_BRAINPOOL) = isone(FP_BRAINPOOL_equals(a, b))
FP_BRAINPOOL() = (a = FP_BRAINPOOL(undef); FP_BRAINPOOL_zero(a); a)
Base.pointer(a::FP_C41417) = reinterpret(Ptr{FP_C41417}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_C41417}}, a::FP_C41417) = pointer(a)
Base.:(==)(a::FP_C41417, b::FP_C41417) = isone(FP_C41417_equals(a, b))
FP_C41417() = (a = FP_C41417(undef); FP_C41417_zero(a); a)
Base.pointer(a::FP_FP256BN) = reinterpret(Ptr{FP_FP256BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_FP256BN}}, a::FP_FP256BN) = pointer(a)
Base.:(==)(a::FP_FP256BN, b::FP_FP256BN) = isone(FP_FP256BN_equals(a, b))
FP_FP256BN() = (a = FP_FP256BN(undef); FP_FP256BN_zero(a); a)
Base.pointer(a::FP_FP512BN) = reinterpret(Ptr{FP_FP512BN}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_FP512BN}}, a::FP_FP512BN) = pointer(a)
Base.:(==)(a::FP_FP512BN, b::FP_FP512BN) = isone(FP_FP512BN_equals(a, b))
FP_FP512BN() = (a = FP_FP512BN(undef); FP_FP512BN_zero(a); a)
Base.pointer(a::FP_GOLDILOCKS) = reinterpret(Ptr{FP_GOLDILOCKS}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_GOLDILOCKS}}, a::FP_GOLDILOCKS) = pointer(a)
Base.:(==)(a::FP_GOLDILOCKS, b::FP_GOLDILOCKS) = isone(FP_GOLDILOCKS_equals(a, b))
FP_GOLDILOCKS() = (a = FP_GOLDILOCKS(undef); FP_GOLDILOCKS_zero(a); a)
Base.pointer(a::FP_HIFIVE) = reinterpret(Ptr{FP_HIFIVE}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_HIFIVE}}, a::FP_HIFIVE) = pointer(a)
Base.:(==)(a::FP_HIFIVE, b::FP_HIFIVE) = isone(FP_HIFIVE_equals(a, b))
FP_HIFIVE() = (a = FP_HIFIVE(undef); FP_HIFIVE_zero(a); a)
Base.pointer(a::FP_NIST256) = reinterpret(Ptr{FP_NIST256}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_NIST256}}, a::FP_NIST256) = pointer(a)
Base.:(==)(a::FP_NIST256, b::FP_NIST256) = isone(FP_NIST256_equals(a, b))
FP_NIST256() = (a = FP_NIST256(undef); FP_NIST256_zero(a); a)
Base.pointer(a::FP_NIST384) = reinterpret(Ptr{FP_NIST384}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_NIST384}}, a::FP_NIST384) = pointer(a)
Base.:(==)(a::FP_NIST384, b::FP_NIST384) = isone(FP_NIST384_equals(a, b))
FP_NIST384() = (a = FP_NIST384(undef); FP_NIST384_zero(a); a)
Base.pointer(a::FP_NIST521) = reinterpret(Ptr{FP_NIST521}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_NIST521}}, a::FP_NIST521) = pointer(a)
Base.:(==)(a::FP_NIST521, b::FP_NIST521) = isone(FP_NIST521_equals(a, b))
FP_NIST521() = (a = FP_NIST521(undef); FP_NIST521_zero(a); a)
Base.pointer(a::FP_SECP256K1) = reinterpret(Ptr{FP_SECP256K1}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{FP_SECP256K1}}, a::FP_SECP256K1) = pointer(a)
Base.:(==)(a::FP_SECP256K1, b::FP_SECP256K1) = isone(FP_SECP256K1_equals(a, b))
FP_SECP256K1() = (a = FP_SECP256K1(undef); FP_SECP256K1_zero(a); a)
Base.pointer(a::amcl_aes) = reinterpret(Ptr{amcl_aes}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{amcl_aes}}, a::amcl_aes) = pointer(a)
Base.pointer(a::csprng) = reinterpret(Ptr{csprng}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{csprng}}, a::csprng) = pointer(a)
Base.pointer(a::gcm) = reinterpret(Ptr{gcm}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{gcm}}, a::gcm) = pointer(a)
Base.pointer(a::hash256) = reinterpret(Ptr{hash256}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{hash256}}, a::hash256) = pointer(a)
Base.pointer(a::hash512) = reinterpret(Ptr{hash512}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{hash512}}, a::hash512) = pointer(a)
Base.pointer(a::octet) = reinterpret(Ptr{octet}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{octet}}, a::octet) = pointer(a)
Base.:(==)(a::octet, b::octet) = isone(AMCL.OCT_comp(a, b))
Base.pointer(a::pktype) = reinterpret(Ptr{pktype}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{pktype}}, a::pktype) = pointer(a)
Base.pointer(a::rsa_private_key_2048) = reinterpret(Ptr{rsa_private_key_2048}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{rsa_private_key_2048}}, a::rsa_private_key_2048) = pointer(a)
Base.pointer(a::rsa_private_key_3072) = reinterpret(Ptr{rsa_private_key_3072}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{rsa_private_key_3072}}, a::rsa_private_key_3072) = pointer(a)
Base.pointer(a::rsa_private_key_4096) = reinterpret(Ptr{rsa_private_key_4096}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{rsa_private_key_4096}}, a::rsa_private_key_4096) = pointer(a)
Base.pointer(a::rsa_public_key_2048) = reinterpret(Ptr{rsa_public_key_2048}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{rsa_public_key_2048}}, a::rsa_public_key_2048) = pointer(a)
Base.pointer(a::rsa_public_key_3072) = reinterpret(Ptr{rsa_public_key_3072}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{rsa_public_key_3072}}, a::rsa_public_key_3072) = pointer(a)
Base.pointer(a::rsa_public_key_4096) = reinterpret(Ptr{rsa_public_key_4096}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{rsa_public_key_4096}}, a::rsa_public_key_4096) = pointer(a)
Base.pointer(a::sha3) = reinterpret(Ptr{sha3}, pointer_from_objref(a))
Base.unsafe_convert(::Type{Ptr{sha3}}, a::sha3) = pointer(a)


text:
export RigCategory, SymmetricRigCategory, DistributiveMonoidalCategory,
  DistributiveSemiadditiveCategory, DistributiveCategory

# Distributive categories
#########################

""" Theory of a *rig category*, also known as a *bimonoidal category*

[Rig categories](https://ncatlab.org/nlab/show/rig+category) are the most
general in the hierarchy of [distributive monoidal
structures](https://ncatlab.org/nlab/show/distributivity+for+monoidal+structures).

TODO: Do we also want the distributivty and absorption isomorphisms? Usually we
ignore coherence isomorphisms such as associators and unitors.

FIXME: This theory should also inherit `MonoidalCategory`, but multiple
inheritance is not supported.
"""
@signature RigCategory{Ob,Hom} <: SymmetricMonoidalCategoryAdditive{Ob,Hom} begin
  otimes(A::Ob, B::Ob)::Ob
  otimes(f::(A → B), g::(C → D))::((A ⊗ C) → (B ⊗ D)) ⊣
    (A::Ob, B::Ob, C::Ob, D::Ob)
  @op (⊗) := otimes
  munit()::Ob
end

""" Theory of a *symmetric rig category*

FIXME: Should also inherit `SymmetricMonoidalCategory`.
"""
@signature SymmetricRigCategory{Ob,Hom} <: RigCategory{Ob,Hom} begin
  braid(A::Ob, B::Ob)::((A ⊗ B) → (B ⊗ A))
  @op (σ) := braid
end

""" Theory of a *distributive (symmetric) monoidal category*

Reference: Jay, 1992, LFCS tech report LFCS-92-205, "Tail recursion through
universal invariants", Section 3.2

FIXME: Should also inherit `CocartesianCategory`.
"""
@theory DistributiveMonoidalCategory{Ob,Hom} <: SymmetricRigCategory{Ob,Hom} begin
  plus(A::Ob)::((A ⊕ A) → A)
  zero(A::Ob)::(mzero() → A)

  copair(f::(A → C), g::(B → C))::((A ⊕ B) → C) <= (A::Ob, B::Ob, C::Ob)
  coproj1(A::Ob, B::Ob)::(A → (A ⊕ B))
  coproj2(A::Ob, B::Ob)::(B → (A ⊕ B))

  copair(f,g) == (f⊕g)⋅plus(C) ⊣ (A::Ob, B::Ob, C::Ob, f::(A → C), g::(B → C))
  coproj1(A,B) == id(A)⊕zero(B) ⊣ (A::Ob, B::Ob)
  coproj2(A,B) == zero(A)⊕id(B) ⊣ (A::Ob, B::Ob)

  # Naturality axioms.
  plus(A)⋅f == (f⊕f)⋅plus(B) ⊣ (A::Ob, B::Ob, f::(A → B))
  zero(A)⋅f == zero(B) ⊣ (A::Ob, B::Ob, f::(A → B))
end

""" Theory of a *distributive monoidal category with diagonals*

FIXME: Should also inherit `MonoidalCategoryWithDiagonals`.
"""
@theory DistributiveMonoidalCategoryWithDiagonals{Ob,Hom} <:
    DistributiveMonoidalCategory{Ob,Hom} begin
  mcopy(A::Ob)::(A → (A ⊗ A))
  @op (Δ) := mcopy
  delete(A::Ob)::(A → munit())
  @op (◊) := delete
end

""" Theory of a *distributive semiadditive category*

This terminology is not standard but the concept occurs frequently. A
distributive semiadditive category is a semiadditive category (or biproduct)
category, written additively, with a tensor product that distributes over the
biproduct.

FIXME: Should also inherit `SemiadditiveCategory`
"""
@theory DistributiveSemiadditiveCategory{Ob,Hom} <: DistributiveMonoidalCategory{Ob,Hom} begin
  mcopy(A::Ob)::(A → (A ⊕ A))
  @op (Δ) := mcopy
  delete(A::Ob)::(A → mzero())
  @op (◊) := delete

  pair(f::(A → B), g::(A → C))::(A → (B ⊕ C)) ⊣ (A::Ob, B::Ob, C::Ob)
  proj1(A::Ob, B::Ob)::((A ⊕ B) → A)
  proj2(A::Ob, B::Ob)::((A ⊕ B) → B)

  # Naturality axioms.
  f⋅Δ(B) == Δ(A)⋅(f⊕f) ⊣ (A::Ob, B::Ob, f::(A → B))
  f⋅◊(B) == ◊(A) ⊣ (A::Ob, B::Ob, f::(A → B))
end

""" Theory of a *distributive category*

A distributive category is a distributive monoidal category whose tensor product
is the cartesian product, see [`DistributiveMonoidalCategory`](@ref).

FIXME: Should also inherit `CartesianCategory`.
"""
@theory DistributiveCategory{Ob,Hom} <: DistributiveMonoidalCategoryWithDiagonals{Ob,Hom} begin
  pair(f::(A → B), g::(A → C))::(A → (B ⊗ C)) ⊣ (A::Ob, B::Ob, C::Ob)
  proj1(A::Ob, B::Ob)::((A ⊗ B) → A)
  proj2(A::Ob, B::Ob)::((A ⊗ B) → B)

  pair(f,g) == Δ(C)⋅(f⊗g) ⊣ (A::Ob, B::Ob, C::Ob, f::(C → A), g::(C → B))
  proj1(A,B) == id(A)⊗◊(B) ⊣ (A::Ob, B::Ob)
  proj2(A,B) == ◊(A)⊗id(B) ⊣ (A::Ob, B::Ob)

  # Naturality axioms.
  f⋅Δ(B) == Δ(A)⋅(f⊗f) ⊣ (A::Ob, B::Ob, f::(A → B))
  f⋅◊(B) == ◊(A) ⊣ (A::Ob, B::Ob, f::(A → B))
end

ext: jl


text:
using FredData
using Test

@testset "Basic usage" begin
    f = Fred()
    s1 = get_data(f, "GDPC1")
end

@testset "Sanity tests on simple queries" begin
    function sanity_test_on_query_response(id)
        f = Fred()
        s = get_data(f, id)
        @test s.id == id
        @test !isempty(s.data)
    end

    for id in ["GDPC1"]
        sanity_test_on_query_response(id)
    end
end

@testset "Consistent responses from specific vintages" begin
    f = Fred()
    vintage_dates = "2015-01-01"
    s = get_data(f, "GDPC1"; units="chg", vintage_dates=vintage_dates)
    @test size(s.data) == (271, 4)
    @test s.realtime_start == vintage_dates
    @test s.realtime_end == vintage_dates
end

@testset "Bad requests throw exceptions" begin
    f = Fred()
    @test_throws Exception get_data(f, "GDPC1"; limit="foo")
    @test_throws Exception get_data(f, "GDPC1"; vintage_dates="bar")
end

nothing


text:
@testset "piecewisepolynomial" begin
    D = 2
    v1 = rand(D)
    v2 = rand(D)
    maha = Matrix{Float64}(I, D, D)
    degree = 3

    k = PiecewisePolynomialKernel(; degree=degree, dim=D)
    k2 = PiecewisePolynomialKernel{degree}(; dim=D)

    @test k2(v1, v2) == k(v1, v2)

    @test_throws UndefKeywordError PiecewisePolynomialKernel()
    @test_throws UndefKeywordError PiecewisePolynomialKernel(; degree=degree)
    @test_throws UndefKeywordError PiecewisePolynomialKernel{4}()
    @test_throws ErrorException PiecewisePolynomialKernel{4}(; dim=D)
    @test_throws ErrorException PiecewisePolynomialKernel{degree}(; dim=-1)

    # default degree
    @test PiecewisePolynomialKernel(; dim=D) isa PiecewisePolynomialKernel{0}

    @test repr(k) ==
          "Piecewise Polynomial Kernel (degree = $(degree), ⌊dim/2⌋ = $(div(D, 2)), metric = Euclidean(0.0))"

    k3 = PiecewisePolynomialKernel(;
        degree=degree, dim=D, metric=WeightedEuclidean(ones(D))
    )
    @test metric(k3) isa WeightedEuclidean
    @test k3(v1, v2) ≈ k(v1, v2)

    # Standardised tests.
    TestUtils.test_interface(k, ColVecs{Float64}; dim_in=2)
    TestUtils.test_interface(k, RowVecs{Float64}; dim_in=2)
    test_ADs(() -> PiecewisePolynomialKernel{degree}(; dim=D))

    test_params(k, ())
end


text:
include("../src/api.jl")

function uwu()

    for (i, (filename, system)) in enumerate(load_ODEs_if(from_size=1, to_size=30))

        @info "$i-th, loaded a system $filename of size $(length(system))"

        equations = [system[x] for x in sort(collect(keys(system)), by=string)]

        As = construct_jacobians(equations)

        if filename != "e2.ode"
            continue
        end

        # matrices
        V1 = find_basis(deepcopy(As))

        println("radical... \n----------")
        @time R = find_radical_2(V1)
        println("\n----------")

    end

end

function owo()

    for (i, (filename, system)) in enumerate(load_ODEs_if(from_size=1, to_size=30))

        @info "$i-th, loaded a system $filename of size $(length(system))"

        if !(i in [7])
            continue
        end

        equations = [system[x] for x in sort(collect(keys(system)), by=string)]

        As = construct_jacobians(equations)
        println(equations)

        V = invariant_subspace(As)

        R = parent(equations[1])

        println(V)
        @assert check_invariance!(construct_jacobians(equations), deepcopy(V))

        polyform = polynormalize(V, parent(first(equations)))

        println(length(polyform))
        println(join(string.(polyform), "\n"))
    end

end

Vs = []
function rororo()

    for (i, (filename, system)) in enumerate(load_ODEs_if(from_size=50, to_size=55))

        @info "$i-th, loaded a system $filename of size $(length(system))"

        equations = [system[x] for x in sort(collect(keys(system)), by=string)]

        As = construct_jacobians(equations)

        global Vs
        Vs = many_invariant_subspaces(As, backend_algorithm=invariant_subspace_1)
        println(length(Vs))

        for v in Vs
            println("-----------------------")
            polyform = polynormalize(v, parent(first(equations)))
            println(length(polyform))
            println(join(string.(polyform), "\n"))
            println("-----------------------")
        end

        break
    end

end

# owo()
# uwu()
# owo()

#------------------------------------------------------------------------------

#=
C2 = @sparse [
    2 1 0;
    2 -1 3;
    0 0 1;
]

C1 = @sparse [
    1 0 0;
    0 2 2;
    0 2 2;
]

A1 = @sparse [
    1 1 0 0;
    1 1 0 0;
    0 0 1 2;
    0 0 0 1;
]
A2 = @sparse [
    0 1 0 0;
    1 0 0 0;
    0 0 0 2;
    0 0 2 0;
]

B1 = @sparse [
    0 0 0 0 0;
    0 0 0 0 0;
    0 0 3 0 0;
    0 0 3 3 1;
    0 0 0 0 2;
]

Vs = many_invariant_subspaces([B1])
println(length(Vs), "\n", Vs)
=#


text:
## -- Load external packages
    if VERSION>=v"0.7"
        using Statistics
        using DelimitedFiles
        using SpecialFunctions
    end

    using Plots; gr(); default(fmt=:svg);
    using StatGeochem

## --- Plot GSC map area
    data = readdlm("GSCmaparea.csv",',')
    sedarea = elementify(data)

    h = plot(sedarea["age_Ma"],sedarea["sed_global_km2_Myr"],label="Global",color=:darkred)
    plot!(h,sedarea["age_Ma"],sedarea["sed_Nam_km2_Myr"],label="N.Am.",color=continentcolors[3])
    plot!(h,sedarea["age_Ma"],sedarea["sed_non_Nam_km2_Myr"],label="Globe - N.Am.",color=:black)
    plot!(h,xlims=(0,4000),ylims=(0,110000),xflip=true,legend=:topleft,fg_color_legend=:white,framestyle=:box,grid=false)
    plot!(h,xlabel="Age (Ma)", ylabel="Exposed bedrock area (km2/Myr)")
    savefig(h,"GSC Bedrock exposure, [meta]sedimentary.pdf")
    display(h)
    plot!(h,xlims=(0,2500))
    savefig(h,"GSC Bedrock exposure, [meta]sedimentary [0-2500].pdf")
    plot!(h,xlims=(0,1600))
    savefig(h,"GSC Bedrock exposure, [meta]sedimentary [0-1600].pdf")

## ---

max_stars_repo_name: brenhinkeller/GreatUnconformity

max_issues_repo_name: brenhinkeller/GreatUnconformity

max_forks_repo_name: brenhinkeller/GreatUnconformity


text:
include("IOM/src/share/LogSystem.jl")
include("IOM/src/share/PolelikeCoordinate.jl")
include("IOM/src/models/EMOM/ENGINE_EMOM.jl")
include("IOM/src/driver/driver_working.jl")
include("IOM/src/share/CyclicData.jl")
include("DataLoader.jl")

using MPI
using CFTime, Dates
using ArgParse
using TOML
using DataStructures
using NCDatasets
using .PolelikeCoordinate
using .LogSystem
using .CyclicData
using .DataLoader

function parse_commandline()

    s = ArgParseSettings()

    @add_arg_table s begin

        "--config-file"
            help = "Configuration file."
            arg_type = String
            required = true

    end

    return parse_args(s)
end

parsed = parse_commandline()

MPI.Init()
comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
is_master = rank == 0

config = nothing
if is_master

    config = TOML.parsefile(parsed["config-file"])
    config["DRIVER"]["sync_thermo_state_before_stepping"] = true

    # We will strictly use a day
    Δt_float = 86400.0
    Δt = Dates.Second(Δt_float)
    read_restart = false

    cfgmc = config["MODEL_CORE"]
    cfgmm = config["MODEL_MISC"]

    cfgmc["Qflx"] = "off"
    cfgmc["weak_restoring"] = "off"
    cfgmc["transform_vector_field"] = false

    Nz = length(cfgmc["z_w"])-1

    first_run = true

    t_start = DateTimeNoLeap(1, 1, 1, 0, 0, 0)
    t_end   = DateTimeNoLeap(1, 2, 1, 0, 0, 0)

end

global data = nothing
coupler_funcs = (

    master_before_model_init = function()

        return read_restart, t_start
    end,

    master_after_model_init! = function(OMMODULE, OMDATA)
            # setup forcing
        println("# Model beg time: $(string(t_start))")
        println("# Model end time: $(string(t_end))")

    end,

    master_before_model_run! = function(OMMODULE, OMDATA)

        global first_run, data

        if first_run

            first_run = false

        end

        OMDATA.x2o["NSWFLX"] .=  -2000.0

        write_restart = OMDATA.clock.time == t_end
        end_phase = OMDATA.clock.time > t_end

        if ! end_phase
            return_values = ( :RUN,  Δt, write_restart )
        else
            return_values = ( :END, 0.0, write_restart  )
        end

        return return_values
    end,

    master_after_model_run! = function(OMMODULE, OMDATA)

        fi = OMDATA.mb.fi

#        data_next = DataLoader.loadInitDataAndForcing(dli, OMDATA.clock.time + Δt)

        #_, m, d = DataLoader.getYMD(OMDATA.clock.time)

#        pred_cnt += 1
        #if any(d .== compute_qflx_dates[m])
#        if pred_cnt == pred_steps

#            writeLog("# [Warning] Compare to OGCM, compute QFLX and reinitialize")

            # compute QFLX
#            _Δt = Δt_float * pred_steps
#            @. fi.sv[:QFLXT] = (data_next["TEMP"] - fi.sv[:TEMP]) / _Δt
#            @. fi.sv[:QFLXS] = (data_next["SALT"] - fi.sv[:SALT]) / _Δt
#
#            reinitModel!(OMDATA, data_next; forcing=true, thermal=true)

    end,

    master_finalize! = function(OMMODULE, OMDATA)
        writeLog("[Coupler] Finalize")
    end,
)

runModel(
    ENGINE_EMOM,
    coupler_funcs,
    config,
)

max_stars_repo_name: meteorologytoday/IOM

max_issues_repo_name: meteorologytoday/IOM

max_forks_repo_name: meteorologytoday/IOM


text: include("CamoCore.jl")

max_stars_repo_name: Cocytee/CamoGen

max_issues_repo_name: Cocytee/CamoGen

max_forks_repo_name: Cocytee/CamoGen


text:
"""
    read_parquet(path)

Returns the table contained in the parquet file in an Tables.jl compatible format.

One can easily convert the returned object to any Tables.jl compatible table e.g.
DataFrames.DataFrame via

```
using DataFrames
df = DataFrame(read_parquet(path; copycols=false))
```
"""
function read_parquet(path)
    parquetfile = Parquet.File(path);

    # read all the chunks
    chunks = [chunk for chunk in BatchedColumnsCursor(parquetfile)]

    result_dict = Dict()

    column_names = keys(chunks[1])

    for key in column_names
        # combine all chunks' key into one column
        one_column = reduce(vcat, chunk[key] for chunk in chunks)
        result_dict[key] = one_column
    end

    result_dict
end


text:
@testset "Simulator: Rotations" begin
	# 3D
	a = cos(0.25 * π)
	env = ContactImplicitMPC.Environment{R3,FrictionCone}(x -> 1.0 * x[1], x -> [1.0; 0.0])

	R = rotation(env, [0.0; 0.0])
	λ = [0.0; 0.0; 1.0]
	@test norm(R' * λ - [-a; 0.0; a]) < 1.0e-8

	λ = [1.0; 0.0; 0.0]
	@test norm(R' * λ - [a; 0.0; a]) < 1.0e-8

	λ = [0.0; 1.0; 0.0]
	@test norm(R' * λ - [0.0; 1.0; 0.0]) < 1.0e-8

	env = ContactImplicitMPC.Environment{R3,FrictionCone}(x -> x' * x, x -> 2.0 * x)

	R = rotation(env, [0.0; 0.0])
	λ = [0.0; 0.0; 1.0]
	@test norm(R' * λ - [0.0; 0.0; 1.0]) < 1.0e-8

	λ = [1.0; 0.0; 0.0]
	@test norm(R' * λ - [1.0; 0.0; 0.0]) < 1.0e-8

	λ = [0.0; 1.0; 0.0]
	@test norm(R' * λ - [0.0; 1.0; 0.0]) < 1.0e-8

	a = 1 / 3
	b = 2 / 3
	R = rotation(env, [1.0; 1.0])
	λ = [0.0; 0.0; 1.0]
	@test norm(R' * λ - [-b; -b; a]) < 1.0e-8

	R' * λ
	λ = [1.0; 0.0; 0.0]
	@test norm(R' * λ - [b; -a; b]) < 1.0e-8

	λ = [0.0; 1.0; 0.0]
	@test norm(R' * λ - [-a; b; b]) < 1.0e-8

	# 2D
	a = cos(0.25 * π)
	x1 = [1.0; 0.0]
	x2 = [0.0; 1.0]
	env = ContactImplicitMPC.Environment{R2,FrictionCone}(x -> 1.0 * x[1], x -> 1.0)

	R = rotation(env, [0.0])
	λ = [0.0; 1.0]
	@test norm(R' * λ - [-a; a]) < 1.0e-8

	λ = [1.0; 0.0]
	@test norm(R' * λ - [a; a]) < 1.0e-8
end


text:
# SimLynx.jl Repeatable Process-Based Discrete-Event Simulation Example

using SimLynx
SimLynx.greet()

using Distributions: Exponential, Uniform
using Random

const N_TELLERS = 2
const MEAN_INTERARRIVAL_TIME = 4.0
const MIN_SERVICE_TIME = 2.0
const MAX_SERVICE_TIME = 10.0

const GENERATOR_RNG = 1
const CUSTOMER_RNG = 2

tellers = nothing

"Process to generate n customers arriving into the system."
@process generator(n::Integer) begin
    rng = MersenneTwister(seed(GENERATOR_RNG))
    dist = Exponential(MEAN_INTERARRIVAL_TIME)
    for i = 1:n
        @schedule now customer(i)
        work(rand(rng, dist))
    end
end

"The ith customer into the system."
@process customer(i::Integer) begin
    rng = MersenneTwister(seed(CUSTOMER_RNG, i))
    dist = Uniform(MIN_SERVICE_TIME, MAX_SERVICE_TIME)
    @with_resource tellers begin
        work(rand(rng, dist))
    end
end

"Run the simulation for n customers."
function run_simulation(n::Integer)
    println("SimLynx.jl Repeatable Process-Based Discrete-Event Simulation Example")
    println("$N_TELLERS Teller, Single Queue Bank Model")
    println("  Inter-arrival time = Exponential($MEAN_INTERARRIVAL_TIME)")
    println("  Service time = Uniform($MIN_SERVICE_TIME, $MAX_SERVICE_TIME)")
    println("  Number of customers = $n")
    @simulation begin
        global tellers = Resource(N_TELLERS, "tellers")
        @schedule at 0.0 generator(n)
        start_simulation()
        println("--- Simulation results after $(current_time()) minutes ---")
        print_stats(tellers.allocated, title="Teller Allocation Statistics")
        print_stats(tellers.queue_length, title="Teller Queue Length Statistics")
        plot_history(tellers.queue_length, title="Teller Queue Length History")
        print_stats(tellers.wait, title="Teller Queue Wait Time Statistics")
        plot_history(tellers.wait, title="Teller Queue Wait Time History")
    end
end

run_simulation(100)


text:
import CompactBases: locs, weights

function fd_compare_staggered_non_uniform()
    N = 50
    rmax = 30.0

    B1 = StaggeredFiniteDifferences(rmax, N)

    ρmin = 0.001
    ρmax = 1.0
    α = 0.1
    B2 = StaggeredFiniteDifferences(ρmin, ρmax, α, rmax)

    S1 = B1'B1
    S2 = B2'B2

    x1 = locs(B1)
    x2 = locs(B2)
    w1 = weights(B1)
    w2 = weights(B2)

    cfigure("staggered non_uniform grid") do
        csubplot(211,nox=true) do
            plot(eachindex(x1), x1, ".-", label="Uniform")
            plot(eachindex(x2), x2, ".-", label="Non-uniform")
            ylabel("Node location")
            legend()
        end
        csubplot(212) do
            plot(eachindex(x1), w1, ".-")
            plot(eachindex(x2), w2, ".-")
            ylabel("Weights")
            xlabel("Node index")
        end
    end
    savedocfig("fd/compare_staggered_non_uniform_grid")

    ξ = 10.0 .^ range(-3, stop=log10(25), length=1000)
    χ1 = B1[ξ, :]
    χ2 = B2[ξ, :]

    cfigure("staggered non_uniform basis") do
        csubplot(211,nox=true) do
            semilogx(ξ, χ1)
            ylabel("Uniform")
        end
        csubplot(212) do
            semilogx(ξ, χ2)
            ylabel("Non-uniform")
        end
    end
    savedocfig("fd/compare_staggered_non_uniform_basis")

    f = x -> sin(2π*x/rmax)*exp(-4x/rmax)

    xx1 = axes(B1,1)
    c1 = B1 \ f.(xx1)
    xx2 = axes(B2,1)
    c2 = B2 \ f.(xx2)

    f1 = χ1*c1
    f2 = χ2*c2
    fe = f.(ξ)

    cfigure("staggered non_uniform reconstruction") do
        csubplot(211,nox=true) do
            l = plot(x1, c1, ".:", label="Uniform coeffs")[1]
            plot(ξ, f1, color=l.get_color(), label="Uniform reconstruction")
            l = plot(x2, c2, ".:", label="Non-uniform coeffs")[1]
            plot(ξ, f2, "--", color=l.get_color(), label="Non-uniform reconstruction")
            plot(ξ, fe, ":", label="Exact")
            xscale("log")
            legend(loc=2)
        end
        csubplot(212) do
            loglog(ξ, abs.(f1-fe), label="Uniform error")
            loglog(ξ, abs.(f2-fe), label="Non-uniform error")
            legend(loc=2)
            xlabel(L"x")
        end
    end
    savedocfig("fd/compare_staggered_non_uniform_reconstruction")
end

mkpath(joinpath(fig_dir, "fd"))
@echo fd_compare_staggered_non_uniform()


text:
using Test
using JSExpr
using JSExpr: @crawl, deparse, JSTerminal

@testset "arithmetic infix operators" begin
    @testset "addition infix operator" begin
        jsast = @crawl(foo + bar)
        @test jsast.head == :(+)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo + bar"
    end

    @testset "string concatenation infix operator" begin
        @test string(@js(key + " => " + value)) == "key + \" => \" + value"
    end

    @testset "subtraction infix operator" begin
        jsast = @crawl(foo - bar)
        @test jsast.head == :(-)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo - bar"
    end

    @testset "multiplication infix operator" begin
        jsast = @crawl(foo * bar)
        @test jsast.head == :(*)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo * bar"
    end

    @testset "division infix operator" begin
        jsast = @crawl(foo / bar)
        @test jsast.head == :(/)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo / bar"
    end

    @testset "associativity of infix operators" begin
        @test string(@js(5 * (1 + 2))) == "5 * (1 + 2)"
    end
end

@testset "unary infix operators" begin
    @test @js(-123) == js"-123"
    @test @js(-foo) == js"-foo"
    @test @js(+@new Date) == js"+new Date"
    @test @js(-foo + bar) == js"-foo + bar"
    @test @js(-(foo + bar)) == js"-(foo + bar)"
end

@testset "object infix operators" begin
    @testset "dot infix operator" begin
        jsast = @crawl(foo.bar)
        @test jsast.head == :(.)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo.bar"
    end
end

@testset "assignment infix operators" begin
    @testset "equals infix operator" begin
        jsast = @crawl(foo = bar)
        @test jsast.head == :(=)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo = bar"
    end

    @testset "plus-equals infix operator" begin
        jsast = @crawl(foo += bar)
        @test jsast.head == :(+=)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo += bar"
    end

    @testset "times-equals infix operator" begin
        jsast = @crawl(foo *= bar)
        @test jsast.head == :(*=)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo *= bar"
    end

    @testset "minus-equals infix operator" begin
        jsast = @crawl(foo -= bar)
        @test jsast.head == :(-=)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo -= bar"
    end

    @testset "divide-equals infix operator" begin
        jsast = @crawl(foo /= bar)
        @test jsast.head == :(/=)
        @test length(jsast.args) == 2
        @test jsast.args[1] == JSTerminal(:foo)
        @test jsast.args[2] == JSTerminal(:bar)

        jsstr = deparse(jsast)
        @test jsstr == js"foo /= bar"
    end

    @testset "equality infix operator" begin
        @test @js(foo == bar) == JSString("foo == bar")
    end

    @testset "not-equality infix operator" begin
        @test @js(foo != bar) == JSString("foo != bar")
    end
end

@testset "logical infix operators" begin
    @testset "&&" begin
        @test string(@js foo && bar) == "foo && bar"
        @test string(@js foo && bar && spam) == "foo && bar && spam"
    end

    @testset "logical infix associativity" begin
        @test string(@js foo && (bar || spam)) == "foo && (bar || spam)"
    end

    @testset "parenthesization" begin
        @test string(@js foo && bar()) == "foo && bar()"
        @test string(@js (foo && bar()) || spam()) == "(foo && bar()) || spam()"
    end
end


text:
module Testsuite

using ..KernelAbstractions
using ..Test

include("test.jl")
include("localmem.jl")
include("private.jl")
include("unroll.jl")
include("nditeration.jl")
include("async_copy.jl")
include("events.jl")
include("print_test.jl")
include("compiler.jl")
include("reflection.jl")
include("examples.jl")

function testsuite(backend, backend_str, backend_mod, AT, DAT)
    @testset "Unittests" begin
        unittest_testsuite(backend, backend_str, backend_mod, AT, DAT)
    end

    @testset "Localmem" begin
        localmem_testsuite(backend, AT)
    end

    @testset "Private" begin
        private_testsuite(backend, AT)
    end

    if backend_str != "ROCM"
        @testset "Unroll" begin
            unroll_testsuite(backend, AT)
        end
    end

    @testset "NDIteration" begin
        nditeration_testsuite()
    end

    if backend_str != "ROCM"
        @testset "async_copy!" begin
            asynccopy_testsuite(backend, AT)
        end
    end

    @testset "Events" begin
        events_testsuite()
    end

    if backend_str != "ROCM"
        @testset "Printing" begin
            printing_testsuite(backend)
        end
    end

    if backend_str != "ROCM"
        @testset "Compiler" begin
            compiler_testsuite(backend, AT)
        end
    end

    @testset "Reflection" begin
        reflection_testsuite(backend, AT)
    end

    if backend_str == "CUDA"
        @testset "Examples" begin
            examples_testsuite()
        end
    end
end

end


text:
using Optim, HTTP, GLM, LinearAlgebra, Random, Statistics, DataFrames, CSV, FreqTables
function ps3()
	#Question 1
	url = "https://raw.githubusercontent.com/OU-PhD-Econometrics/fall-2020/master/ProblemSets/PS3-gev/nlsw88w.csv"
	df = CSV.read(HTTP.get(url).body)
	X = [df.age df.white df.collgrad]
	Z = hcat(df.elnwage1, df.elnwage2, df.elnwage3, df.elnwage4,
	df.elnwage5, df.elnwage6, df.elnwage7, df.elnwage8)
	y = df.occupation;

	#Question 2
	#pass the concatenated array
	C= [X Z]
	function mnlogit(alpha, x, d)
		c=[i==j ? 1 : 0 for i in d , j in 1:6]
		log_mat=[log(exp.(x[i,:]'*alpha[:,j])/(1+sum(exp.(x[i,:]'*alpha)))) for i in 1:size(x,1) ,j in 1:6]
		loglike=-sum(c.*log_mat)

		return loglike
	end

	beta_mnlog = optimize(b -> mnlogit(b, C, y), rand(C,6), LBFGS(), Optim.Options(g_tol=1e-7, iterations=100_000, show_trace=true))
	#println(beta_mnlog.minimizer)

	#Question 4

	df.white = df.race.==1
	α̂ = glm(@formula(married ~ age + white + collgrad), df, Binomial(), LogitLink())
	println(α̂)

	#Question 5
	freqtable(df, :occupation) # note small number of obs in some occupations
	df = dropmissing(df, :occupation)
	df[df.occupation.>7,:occupation] .= 7
	freqtable(df, :occupation) # problem solved

	X = [ones(size(df,1),1) df.age df.race.==1 df.collgrad.==1]
	y = df.occupation

	function mnlogit(alpha, x, d)
		c=[i==j ? 1 : 0 for i in d , j in 1:6]
		log_mat=[log(exp.(x[i,:]'*alpha[:,j])/(1+sum(exp.(x[i,:]'*alpha)))) for i in 1:size(x,1) ,j in 1:6]
		loglike=-sum(c.*log_mat)

		return loglike
	end

	beta_mnlog = optimize(b -> mnlogit(b, X, y), rand(size(X,2),6), LBFGS(), Optim.Options(g_tol=1e-7, iterations=100_000, show_trace=true))
	println(beta_mnlog.minimizer)
end

ps2()


text:
module TestAlgebra

using Test
using LinearAlgebra
using CovarianceFunctions: AbstractKernel, IsotropicKernel, ismercer, isstationary, isisotropic

using CovarianceFunctions
using CovarianceFunctions: Constant, EQ, RQ, Exp, γExp, Delta, Cosine, MaternP, Matern #, SM
using CovarianceFunctions: separable, gramian, LazyGrid
using KroneckerProducts: KroneckerProduct

# TODO:
# test SymmetricKernel
# test higher input dimensions
# test type stability
@testset "stationary kernels" begin

    k1 = EQ()
    k2 = Matern(5*rand())
    k3 = CovarianceFunctions.Dot()

    @test typeof(k1 * k3) <: AbstractKernel
    @test ismercer(k1 * k3)
    # evaluations
    x = randn()
    y = randn()
    # sum
    @test k1(x, y) + k2(x, y) ≈ (k1+k2)(x, y)
    @test k1(x, y) + k2(x, y) ≈ (k2+k1)(x, y)
    @test k1(x, y) + k3(x, y) ≈ (k1+k3)(x, y)
    @test k1(x, y) + k3(x, y) ≈ (k3+k1)(x, y)

    # product
    @test k1(x, y) * k2(x, y) ≈ (k1*k2)(x, y)
    @test k1(x, y) * k2(x, y) ≈ (k2*k1)(x, y)
    @test k1(x, y) * k3(x, y) ≈ (k1*k3)(x, y)
    @test k1(x, y) * k3(x, y) ≈ (k3*k1)(x, y)

    # scalar test
    a = exp(randn())
    @test a*k1(x, y) ≈ (a*k1)(x, y)
    @test a*k1(x, y) ≈ (k1*a)(x, y)
    @test a + k1(x, y) ≈ (a+k1)(x, y)
    @test a + k1(x, y) ≈ (k1+a)(x, y)

    # power
    for p = 1:4
        @test k1(x, y)^p ≈ (k1^p)(x, y)
        @test k2(x, y)^p ≈ (k2^p)(x, y)
        @test k3(x, y)^p ≈ (k3^p)(x, y)
    end

    # TODO: Test invalid inputs for Power kernels
    # k_strings = ["Exponentiated Quadratic", "Exponential", "δ",
    #             "Constant", "Rational Quadratic",
    #             "γ-Exponential", "Cosine",
    #             "Matern"]#, "Spectral Mixture"]

    # T = Float64
    # k_arr = [EQ(), Exp(), Delta(),
    #         Constant(r), RQ(r),
    #         γExp(r), Cosine(r),
    #         Matern(r)]#, SM]
    # n = 16
    # d = 1
    # x = randn(T, n)
    # Σ = zeros(T, (n, n))
end

@testset "separable kernels" begin
    n = 4
    d = 3
    a, b = randn(d), randn(d)
    x = randn(n)
    gx = LazyGrid(x, d)
    y = randn(2n) # this applies the second kernel
    gy = LazyGrid(y, d)

    k = CovarianceFunctions.EQ()
    p3 = separable(*, (k for _ in 1:d)...)
    @test p3(a, b) ≈ separable(^, k, d)(a, b)
    @test gramian(p3, gx, gy) isa KroneckerProduct
    @test size(gramian(p3, gx, gy)) == (n^d, (2n)^d)

    @test p3(a, b) ≈ k(a, b) # since EQ is separable in dimension

    G = gramian(p3, gx, gy)
    @test G isa KroneckerProduct
    @test Matrix(G) ≈ p3.(gx, permutedims(gy))

    # separable sum
    s3 = separable(+, k, k, k)
    Gs3 = gramian(s3, gx, gy)
    @test Gs3 isa Gramian
    @test Matrix(Gs3) ≈ s3.(gx, permutedims(gy))

end

end # TestAlgebra

# moving to trait-based system ...
# @test typeof(k1 + k2) <: IsotropicKernel
# @test typeof(k1 * k2) <: IsotropicKernel
# @test typeof(k2 * k1) <: IsotropicKernel
# for p = 2:4
#     @test typeof(k1^p) <: IsotropicKernel
#     @test typeof(k2^p) <: IsotropicKernel
#     @test typeof(float(p)*k1) <: IsotropicKernel
# end


text:
"""
    a = rand_regular_bipartite(n,k)

Random k-regular bipartite graph between two sets of n vertices.
No repeat edges, so can take a long time to build of k is close to n.

Returns a (possibly) asymmetric matrix that contains the upper-right block.
"""
function rand_regular_bipartite(n,k)
    @assert k <= div(n,2)

    p = randperm(n)

    # start by building the upper-right block
    b = sparse(1:n, p, 1, n, n)

    for i in 2:k
        done = false
        while !done
            p = randperm(n)
            done = true
            for i in 1:n
                if b[i,p[i]] > 0
                    done = false
                end
            end
            if done
                b = b + sparse(1:n, p, 1, n, n)
            end
        end

    end

    return b
end

function test_regular_bipartite(B)
    d = maximum(sum(B,dims=1))
    d == minimum(sum(B,dims=1)) &&
    d == minimum(sum(B,dims=2)) &&
    d == maximum(sum(B,dims=2)) &&
    length(unique(B)) <= 2
end

function regular_bipartite_matching(B)
    @assert test_regular_bipartite(B)

    n = size(B,1)
    match = zeros(Int,n)

    # match is indexed by right vertices, and gives name of match on left

    matched = zeros(Bool,n) # indicates which vertices on left are matched

    d = maximum(sum(B,dims=1))
    if d == 1
        return invperm(B.rowval)
    end

    for i in 1:n
        ops = match_walk(B, match, matched, n, d)

        # eliminate loops in ops
        us = [op[1] for op in ops]

        firsts = indexin(us,us)
        i = length(ops)
        while i > 0
            (u,v) = ops[i]
            match[v] = u
            matched[u] = true

            if firsts[i] < i
                i = firsts[i] - 1
            else
                i = i - 1
            end
        end

    end

    return match
end

function match_walk(B, match, matched, n, d)

    ops = Tuple{Int64,Int64}[]

    u = rand(findall(.!matched))
    v = 0

    done = false
    while !done

        foundv = false
        while !foundv
            i = rand(1:d)
            v = B.rowval[B.colptr[u]+i-1]
            foundv = (u != match[v])
        end

        push!(ops,(u,v))

        if match[v] == 0
            done = true
        else
            u = match[v]
        end

    end

    return ops
end

"""
    S = latin_square(n)

Computes a random (but not uniformly random) n-by-n latin square.
"""
function latin_square(n)

    S = zeros(Int,n,n)

    B = ones(Int,n,n)

    for j in 1:n

        match = regular_bipartite_matching(sparse(B))
        for i in 1:n
            S[i,match[i]] = j
            B[i,match[i]] = 0
        end
    end

    return S
end

function test_latin_square(S)
    n = size(S,1)

    b = true
    b = b && size(S,2) == n

    for i in 1:n
        b = b && length(unique(S[:,i])) == n
        b = b && length(unique(S[i,:])) == n
    end

    b = b && length(unique(S)) == n
    return b
end

"""
    a = latin_square_graph(S::Matrix{Int})
    a = latin_square_graph(n::Int)

Construct the adjacency matrix of the latin square graph for the latin square S.
If only n is provided, construct a latin square graph of dimension n.
"""
function latin_square_graph(S::Matrix{Int})

    @assert test_latin_square(S)

    n = size(S,1)

    ijv = Laplacians.complete_graph_ijv(n)
    ci = copy(ijv.i)
    cj = copy(ijv.j)

    lsgi = Int[]
    lsgj = Int[]

    # construct the column cliques
    for i in 1:n
        append!(lsgi, ci .+ n*(i-1))
        append!(lsgj, cj .+ n*(i-1))
    end

    # construct the row cliques
    for i in 1:n
        append!(lsgi, n*ci .+ (i-n))
        append!(lsgj, n*cj .+ (i-n))
    end

    # construct the value cliques
    nums = reshape([1:n^2;],n,n)

    for i in 1:n
        ind = nums[S .== i]
        append!(lsgi, ind[ci])
        append!(lsgj, ind[cj])
    end

    return sparse(lsgi, lsgj, 1.0, n^2, n^2)
end

latin_square_graph(n::Int) = latin_square_graph(latin_square(n))


text:
using LinearAlgebra

function so3ToVec(so3mat)
    if( size(so3mat)!=(3,3) )
        println("!Warning! : Input matrix should be 3x3.")
        return
    end
    if( !((so3mat[1,1]==so3mat[2,2]==so3mat[3,3]==0)) )
        println("!Warning! : Diagonals should be zero.")
        return
    end
    if( so3mat[2,1]!=-so3mat[1,2] ||
        so3mat[3,1]!=-so3mat[1,3] ||
        so3mat[3,2]!=-so3mat[2,3] )
        println("!Warning! : Entered matrix isn't a skew symmetric matrix.")
        return
    end
    ret_vec = [so3mat[3,2];
               so3mat[1,3];
               so3mat[2,1] ]
        return ret_vec
end

function vecToSo3(omg)
    if( size(omg)!=(3,) )
        println("!Warning! : Input matrix should be 3x1.")
        return
    end

    ret_ss_matrix = [0      -omg[3]   omg[2];
                     omg[3]    0     -omg[1];
                    -omg[2]  omg[1]      0];
    return ret_ss_matrix
end

max_stars_repo_name: veysiadn/AdvancedRoboticsJulia

max_issues_repo_name: veysiadn/AdvancedRoboticsJulia

max_forks_repo_name: veysiadn/AdvancedRoboticsJulia


text:
# This file includes the simulation of five node network simulation

import Cairo, Fontconfig
using GraphPlot
using Graphs
using SimpleWeightedGraphs
using LinearAlgebra
using DynamicalNetworks
using PyPlot
pygui(true)
close("all")

# Helper functions
getwave(x, i, d) = getindex.(x, (i - 1) * d + 1)

# Node settings
nodetype = Lorenz           # Node type
P = diagm([1.0, 0.0, 0])    # State coupling matrix
ηt = 10.0                   # Threshold for maximum Lyapuno exponents

# Topology
n = 8
graph = SimpleWeightedGraph(cycle_graph(n))
add_edge!(graph, 2, 7, 1)
add_edge!(graph, 3, 6, 1)
gplot(graph, nodelabel = 1:nv(graph), layout = circular_layout) |> display

# Coupling strength
W = laplacian_matrix(graph)
Q = [
    0 0 0 0 0 0 0 1
    0 0 0 0 0 0 1 0
    0 0 0 0 0 1 0 0
    0 0 0 0 1 0 0 0
    0 0 0 1 0 0 0 0
    0 0 1 0 0 0 0 0
    0 1 0 0 0 0 0 0
    1 0 0 0 0 0 0 0
]
M = eigvecs(Q)
G = inv(M) * (W ./ diag(W)) * M
B = G[1:4, 1:4]
D = G[5:8, 5:8]
λt = eigvals(B)
λs = eigvals(D)
λt[1] > λs[2] || error("Synchronization is not possible")
ϵr = ηt ./ [λt[1], λs[2]]
ϵ = ϵr[1] + abs(ϵr[2] - ϵr[1]) * 0.5

# Network
σ = 0.0  # Noise strength
H = getnoisemat(graph) * σ
net = SDENetwork(nodetype, ϵ, graph, H, P)
sol = solvenet!(net, (0.0, 100.0), solverkwargs = (saveat = 0.001,))
t = sol.t
x = sol.u

# Plots
d = dimension(nodetype)
subplot(221)
plot(t, abs.(getwave(x, 1, d) - getwave(x, 2, d)))
xlabel("Time")
ylabel("e12")
subplot(222)
plot(t, abs.(getwave(x, 1, d) - getwave(x, 8, d)))
xlabel("Time")
ylabel("e18")
subplot(223)
plot(t, getwave(x, 1, d))
xlabel("Time")
ylabel("x1")
subplot(224)
plot(getindex.(x, 1), getindex.(x, 2))
xlabel("x1")
ylabel("x2")
tight_layout()

figure()
plot(λt, zeros(length(λt)), marker = "*", label = L"\lambda_t")
plot(λs, ones(length(λs)), marker = "o", label = L"\lambda_s")
axvline.([λt[1], λs[2]], linestyle = "dashed", color = "red")
axvline(ηt / ϵ, linestyle = "dashed", color = "green")
xlabel(L"\lambda")
title("Eigenvalue distribution")
legend()


text:
using PyPlot

type Const
    C::Float64
    γ::Float64
    ϵ::Float64
    tol::Float64
    sampleSize::Int64
end

type Param
    α::Array{Float64}
    b::Float64
end

function rbfKernel(x, y, γ)
    s = 0
    for ele in x - y
        s += ele * ele
    end
    return exp(- γ * s)
end

function decision_f(params, y, G, i::Int64, CONST)
    f = 0
    for j in 1:CONST.sampleSize
        f += params.α[j] * y[j] * G[i, j]
    end
    return f - params.b
end

function decision_f(params, y, X, x::Array, CONST)
    f = 0
    for j in 1:CONST.sampleSize
        f += params.α[j] * y[j] * rbfKernel(X[j, :], x, CONST.γ)
    end
    return f - params.b
end

function takeStep(params, i1, i2, y2, α2, E2, y, G, errorCache, CONST)
    if i1 == i2
        return false
    end
    α1 = params.α[i1]
    y1 = y[i1]
    E1 = errorCache[i1]
    s = y1 * y2
    if y1 != y2
        L = max(0, α2 - α1)
        H = min(CONST.C, CONST.C + α2 - α1)
    else
        L = max(0, α2 + α1 - CONST.C)
        H = min(CONST.C, α2 + α1)
    end
    if abs(L - H) < CONST.ϵ
        return false
    end
    k11 = G[i1, i1]
    k12 = G[i1, i2]
    k22 = G[i2, i2]
    η = k11 + k22 - 2 * k12
    if η > 0
        a2 = α2 + y2 * (E1 - E2) / η
        if a2 < L
            a2 = L
        elseif a2 > H
            a2 = H
        end
    else
        L1 = α1 + s * (α2 - L)
        H1 = α1 + s * (α2 - H)
        f1 = y1 * (E1 + params.b) - α1 * k11 - s * α2 * k12
        f2 = y2 * (E2 + params.b) - s * α1 * k12 - α2 * k22
        Lobj = L1*f1 + L*f2 + 0.5*L1*L1*k11 + 0.5*L*L*k22 + s*L*L1*k12
        Hobj = H1*f1 + H*f2 + 0.5*H1*H1*k11 + 0.5*H*H*k22 + s*H*H1*k12
        if Lobj > Hobj + CONST.ϵ
            a2 = L
        elseif Lobj < Hobj - CONST.ϵ
            a2 = H
        else
            a2 = α2
        end
    end
    if abs(a2 - α2) < CONST.ϵ * (a2 + α2 + CONST.ϵ)
        return false
    end
    a1 = α1 + s * (α2 - a2)
    b1 = E1 + y1 * (a1 - α1) * k11 + y2 * (a2 - α2) * k12 + params.b
    b2 = E2 + y1 * (a1 - α1) * k12 + y2 * (a2 - α2) * k22 + params.b
    if a1 > 0 && a1 < CONST.C
        params.b = b1
    else
        if a2 > 0 && a2 < CONST.C
            params.b = b2
        else
            params.b = (b1 + b2) / 2.0
        end
    end

    #Update α
    params.α[i1] = a1
    params.α[i2] = a2
    #Update errorCache
    errorCache[i1] = decision_f(params, y, G, i1, CONST) - y[i1]
    errorCache[i2] = decision_f(params, y, G, i2, CONST) - y[i2]
    return true
end

function examineExample(params, y, G, errorCache, i2, CONST)
    y2 = y[i2]
    α2 = params.α[i2]
    E2 = errorCache[i2]
    r2 = E2 * y2
    if (r2 < -CONST.tol && α2 < CONST.C) || (r2 > CONST.tol && α2 > 0)
        idx_zero_or_C = Int64[]
        n = rand(1:CONST.sampleSize)
        for j in 1:CONST.sampleSize
            if j + n <= CONST.sampleSize
                j = j + n
            else
                j = j + n - CONST.sampleSize
            end
            if params.α[j] != 0 && params.α[j] != CONST.C
                i1 = j
                if takeStep(params, i1, i2, y2, α2, E2, y, G, errorCache, CONST)
                    return 1
                end
            else
                push!(idx_zero_or_C, j)
            end
        end
        n = rand(1:size(idx_zero_or_C)[1])
        for j in 1:size(idx_zero_or_C)[1]
            if j + n <= size(idx_zero_or_C)[1]
                j = j + n
            else
                j = j + n - size(idx_zero_or_C)[1]
            end
            i1 = idx_zero_or_C[j]
            if takeStep(params, i1, i2, y2, α2, E2, y, G, errorCache, CONST)
                return 1
            end
        end
    end
    return 0
end

function evaluate(predicted_P::Array{Float64, 2}, predicted_N::Array{Float64, 2})
    TP = 0
    FP = 0
    TN = 0
    FN = 0
    for i in 1:size(predicted_P)[1]
        if predicted_P[i, 1] * predicted_P[i, 2] >= 0
            TP += 1
        else
            FP += 1
        end
    end
    for i in 1:size(predicted_N)[1]
        if predicted_N[i, 1] * predicted_N[i, 2] < 0
            TN += 1
        else
            FN += 1
        end
    end
    return float(TP + TN) / (TP + FP + TN + FN)
end

function main()

    # Training sample preparation.
    n = 500
    srand(1234567)
    sample = 2*rand(n, 2) - 1
    X_P = Array{Float64, 2}[]
    X_N = Array{Float64, 2}[]
    for i in 1:n
        if sample[i, 1] * sample[i, 2] >= 0
            push!(X_P, sample[i, :])
        else
            push!(X_N, sample[i, :])
        end
    end
    X_P = vcat(X_P...)
    X_N = vcat(X_N...)
    y_p = ones(size(X_P)[1])
    y_n = ones(size(X_N)[1]) * -1
    #X_P = [1 1; -1 -1; 0.5 0.5; -0.5 -0.5; 0.3 0.3]
    #X_N = [-1 1; 1 -1; 0.5 -0.5; -0.5 0.5; -0.1 -0.1]
    #y_p = [1, 1, 1, 1, 1]
    #y_n = [-1, -1, -1, -1, -1]
    X = vcat(X_P, X_N)
    y = vcat(y_p, y_n)

    # Constant variables and Parameters.
    C = 2.0^-3
    γ = 2.0^2
    tol = 10.0 ^ -2
    b = 0.0
    ϵ = 10.0 ^ -6
    sampleSize = size(y)[1]
    CONST = Const(C, γ, ϵ, tol, sampleSize)
    α = zeros(CONST.sampleSize)
    params = Param(α, b)

    # Initialize Gram Matrix
    G = zeros(sampleSize, sampleSize)
    for j in 1:CONST.sampleSize
        for i in 1:CONST.sampleSize
            G[i, j] = rbfKernel(X[i, :], X[j, :], CONST.γ)
        end
    end

    # Initialize errorCache
    errorCache = zeros(CONST.sampleSize)
    for i in 1:CONST.sampleSize
        errorCache[i] = decision_f(params, y, G, i, CONST) - y[i]
    end

    # Optimization rootine
    numChanged = 0
    examineAll = true
    cnt = 0
    while numChanged > 0 || examineAll
        numChanged = 0
        if examineAll
            for i in 1:CONST.sampleSize
                numChanged += examineExample(params, y, G, errorCache, i, CONST)
            end
        else
            for i in 1:CONST.sampleSize
                if α[i] > 0 && α[i] < C
                    numChanged += examineExample(params, y, G, errorCache, i, CONST)
                end
            end
        end
        if examineAll
            examineAll = false
        elseif numChanged == 0
            examineAll = true
        end
        cnt += 1
    end
    #@show cnt

    # Test.
    #X_test = [0.6 0.6; -0.6 -0.6; 0.6 -0.6; -0.6 0.6]
    n = 5000
    srand(5678)
    X_test = 2*rand(n, 2) - 1.0

    # Prediction.
    predicted_P = Array{Float64, 2}[]
    predicted_N = Array{Float64, 2}[]
    for i in 1:n
        decision_v = decision_f(params, y, X, X_test[i, :], CONST)
        if decision_v >= 0
            push!(predicted_P, X_test[i, :])
        else
            push!(predicted_N, X_test[i, :])
        end
    end
    if size(predicted_P)[1] == 0
        println("predicted_P is empty")
    elseif size(predicted_N)[1] == 0
        println("predicted_N is empty")
    end
    predicted_P = vcat(predicted_P...)
    predicted_N = vcat(predicted_N...)

    # Evaluation.
    accuracy = evaluate(predicted_P, predicted_N)
    @show accuracy

    # Plotting.
    figure("sample", figsize=(8, 16))
    subplot(211)
    vlines(0, -1.2, 1.2)
    hlines(0, -1.2, 1.2)
    scatter(X_P[:, 1], X_P[:, 2], marker="o", color="r")
    scatter(X_N[:, 1], X_N[:, 2], marker="x", color="b")
    title("Training (500 samples)")
    subplot(212)
    vlines(0, -1.2, 1.2)
    hlines(0, -1.2, 1.2)
    scatter(predicted_P[:, 1], predicted_P[:, 2], marker="o", color="r")
    scatter(predicted_N[:, 1], predicted_N[:, 2], marker="x", color="b")
    title("Test (5000 samples)")
end

main()


text:
######################################################################
# Lockables are simple wrappers around arbitrary data combined with
# a lock/condition/`lock`able. The Lockable itself forwards Base
# sync functions.
# -----
# Licensed under Apache License 2.0
module Lockables
using Base.Threads

export Lockable
mutable struct Lockable{T}
    data::T
    lock
end
Lockable(init::T) where T = Lockable(init, Threads.ReentrantLock())

Base.lock(lockable::Lockable, args...; kwargs...) = lock(lockable.lock, args...; kwargs...)
Base.lock(cb, lockable::Lockable, args...; kwargs...) = lock(cb, lockable.lock, args...; kwargs...)
Base.unlock(lockable::Lockable, args...; kwargs...) = unlock(lockable.lock, args...; kwargs...)
Base.islocked(lockable::Lockable, args...; kwargs...) = islocked(lockable.lock, args...; kwargs...)

Base.notify(lockable::Lockable, args...; kwargs...) = notify(lockable.lock, args...; kwargs...)
Base.wait(lockable::Lockable, args...; kwargs...) = wait(lockable.lock, args...; kwargs...)

Base.getindex(lockable::Lockable) = lockable.data
Base.setindex!(lockable::Lockable{T1}, value::T2) where {T1, T2<:T1} = lockable.data = value
end


text:
# ---
# title: 1462. Course Schedule IV
# id: problem1462
# author: Tian Jun
# date: 2020-10-31
# difficulty: Medium
# categories: Graph
# link: <https://leetcode.com/problems/course-schedule-iv/description/>
# hidden: true
# ---
#
# There are a total of `n` courses you have to take, labeled from `0` to `n-1`.
#
# Some courses may have direct prerequisites, for example, to take course 0 you
# have first to take course 1, which is expressed as a pair: `[1,0]`
#
# Given the total number of courses `n`, a list of direct `prerequisite`
# **pairs** and a list of `queries` **pairs**.
#
# You should answer for each `queries[i]` whether the course `queries[i][0]` is
# a prerequisite of the course `queries[i][1]` or not.
#
# Return _a list of boolean_ , the answers to the given `queries`.
#
# Please note that if course **a** is a prerequisite of course **b** and course
# **b** is a prerequisite of course **c** , then, course **a** is a prerequisite
# of course **c**.
#
#
#
# **Example 1:**
#
# ![](https://assets.leetcode.com/uploads/2020/04/17/graph.png)
#
#
#
#     Input: n = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]
#     Output: [false,true]
#     Explanation: course 0 is not a prerequisite of course 1 but the opposite is true.
#
#
# **Example 2:**
#
#
#
#     Input: n = 2, prerequisites = [], queries = [[1,0],[0,1]]
#     Output: [false,false]
#     Explanation: There are no prerequisites and each course is independent.
#
#
# **Example 3:**
#
# ![](https://assets.leetcode.com/uploads/2020/04/17/graph-1.png)
#
#
#
#     Input: n = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]
#     Output: [true,true]
#
#
# **Example 4:**
#
#
#
#     Input: n = 3, prerequisites = [[1,0],[2,0]], queries = [[0,1],[2,0]]
#     Output: [false,true]
#
#
# **Example 5:**
#
#
#
#     Input: n = 5, prerequisites = [[0,1],[1,2],[2,3],[3,4]], queries = [[0,4],[4,0],[1,3],[3,0]]
#     Output: [true,false,true,false]
#
#
#
#
# **Constraints:**
#
#   * `2 <= n <= 100`
#   * `0 <= prerequisite.length <= (n * (n - 1) / 2)`
#   * `0 <= prerequisite[i][0], prerequisite[i][1] < n`
#   * `prerequisite[i][0] != prerequisite[i][1]`
#   * The prerequisites graph has no cycles.
#   * The prerequisites graph has no repeated edges.
#   * `1 <= queries.length <= 10^4`
#   * `queries[i][0] != queries[i][1]`
#
#
## @lc code=start
using LeetCode

## add your code here:
## @lc code=end


text:
# This file is part of EndemicModel project, which is licensed under BDS-3-Clause.
# See file LICENSE.md for more information.

const PathDesignator = Union{AbstractString,AbstractPath}

const Float = Float64
const OptFloat = Union{Missing,Float64}
const OptInt = Union{Missing,Int}

const DataDict = Dict{Symbol,Any}
const OrderedDataDict = OrderedDict{Symbol,Any}
const SortedDataDict = SortedDict{Symbol,Any}
const WeakKeyDataDict = WeakKeyDict{Symbol,Any}
const DataFrameDict = Dict{Symbol,DataFrame}
const AbstractDataDict = AbstractDict{Symbol,Any}

datadict(data::AbstractDict) = DataDict(data)
datadict(data::OrderedDict) = OrderedDataDict(data)
datadict(data::SortedDict) = SortedDataDict(data)
datadict(data::WeakKeyDict) = WeakKeyDataDict(data)

function csv_read(file::PathDesignator; kwargs...)::DataFrame
    CSV.read(string(file), DataFrame; kwargs...)
end
function csv_read(io; kwargs...)::DataFrame
    CSV.read(io, DataFrame; kwargs...)
end
csv_write(file::PathDesignator, table; kwargs...) =
    CSV.write(string(file), table; kwargs...)
csv_write(io, table; kwargs...) = CSV.write(io, table; kwargs...)

function ods_read(file::PathDesignator; kwargs...)::DataFrame
    OdsIO.ods_read(string(file); innerType = "DataFrame", kwargs...)
end
function ods_read(io; kwargs...)::DataFrame
    OdsIO.ods_read(io; innerType = "DataFrame", kwargs...)
end
function ods_readall(file::PathDesignator; kwargs...)::Dict{String,DataFrame}
    OdsIO.ods_readall(string(file); innerType = "DataFrame", kwargs...)
end
function ods_readall(io; kwargs...)::Dict{String,DataFrame}
    OdsIO.ods_readall(io; innerType = "DataFrame", kwargs...)
end
ods_write(file::PathDesignator, data; kwargs...) = OdsIO.ods_write(string(file), data)
ods_write(io, data; kwargs...) = OdsIO.ods_write(io, data)

function ensure_unique(key_collection, key::Symbol, postfix = :_)
    if key ∈ key_collection
        n = 1
        nkey = Symbol(key, postfix, string(n))
        while nkey ∈ key_collection
            n += 1
            nkey = Symbol(key, postfix, string(n))
        end
        nkey
    else
        key
    end
end

function ensure_unique(dict::AbstractDict, key::Symbol, postfix = :_)
    ensure_unique(keys(dict), key, postfix)
end

function ensure_unique(key_collection, ::Nothing, postfix = :_)
    acc = Symbol[key_collection[1]]
    for key::Symbol ∈ key_collection[2:end]
        push!(acc, ensure_unique(acc, key, postfix))
    end
    acc
end

ensure_unique(key_collection) = ensure_unique(key_collection, nothing, :_)

function make_symbols(vec::AbstractVector)
    ensure_unique(Symbol[sym = obj isa Symbol ? obj : Symbol(string(obj)) for obj ∈ vec])
end

function subdict(dict::AbstractDict, keys)
    if keys(dict) ⊆ keys
        dict
    else
        filter((k, v) -> k ∈ keys, dict)
    end
end

function get_input(
    table::AbstractString;
    directory = option(:parameter_directory),
    kwargs...,
)
    file = joinpath(Path(directory), Path(table * ".csv"))
    csv_read(file; kwargs...)
end

function get_parameters(
    table::AbstractString;
    directory = option(:parameter_directory),
    kwargs...,
)
    df = get_input(table; directory = directory, kwargs...)
    dfkeys = strip.(df.key)
    dfvalues = strip.(df.value)
    Dict((dfkeys .=> dfvalues)...)
end

function correct_countries!(countries::AbstractVector)
    country_dict = get_parameters("country")
    for (i, country) ∈ enumerate(countries)
        country = strip(country)
        countries[i] = get(country_dict, country, country)
    end
    countries
end

function correct_test_kind!(test_kinds::AbstractVector)
    test_dict = get_parameters("test_kind")
    for (i, test_kind) ∈ enumerate(test_kinds)
        test_kind = strip(test_kind)
        test_kinds[i] = get(test_dict, test_kind, test_kind)
    end
    test_kinds
end

prettify(obj::Any; kwargs...) = obj
function prettify(obj::AbstractVector; kwargs...)
    map(elt -> prettify(elt; kwargs...), obj)
end
prettify(obj::Integer; kwargs...) = obj
function prettify(obj::Real; digits = 2, kwargs...)
    obj < 1.0 && (digits += 1)
    obj < 0.1 && (digits += 1)
    round(obj; digits = digits)
end

function prettify(obj::Symbol; case = titlecase, replace_pairs = ["_" => " "], kwargs...)
    if isnothing(case) && isnothing(replace_pairs)
        obj
    else
        Symbol(prettify(string(obj); case = case, replace_pairs = replace_pairs, kwargs...))
    end
end

function prettify(obj::AbstractString; case = nothing, replace_pairs = nothing, kwargs...)
    !isnothing(replace_pairs) && (obj = replace(obj, replace_pairs...))
    if !isnothing(case) && all(c -> Int(c) < 255, obj)
        case(obj)
    else
        obj
    end
end

function prettify(obj::AbstractDataFrame; kwargs...)
    newcols = [prettify(col; kwargs...) for col ∈ eachcol(obj)]
    newnames = prettify(Symbol.(names(obj)); kwargs...)
    DataFrame(newcols, newnames)
end

function prettify(obj::AbstractDict; kwargs...)
    result = empty(obj)
    for (key, value) ∈ obj
        result[prettify(key; kwargs...)] = prettify(value; kwargs...)
    end
    result
end

function prettify(obj::Missing; kwargs...)
    nothing
end

simplify(obj::Any; kwargs...) = obj
function simplify(obj::AbstractVector; kwargs...)
    map(elt -> simplify(elt; kwargs...), obj)
end

function simplify(obj::Symbol; case = lowercase, replace_pairs = [" " => "_"], kwargs...)
    if isnothing(case) && isnothing(replace_pairs)
        obj
    else
        Symbol(simplify(string(obj); case = case, replace_pairs = replace_pairs, kwargs...))
    end
end

function simplify(obj::AbstractString; case = nothing, replace_pairs = nothing, kwargs...)
    !isnothing(replace_pairs) && (obj = replace(obj, replace_pairs...))
    if !isnothing(case) && all(c -> Int(c) < 255, obj)
        case(obj)
    else
        obj
    end
end

function simplify(obj::AbstractDataFrame; kwargs...)
    newcols = [simplify(col; kwargs...) for col ∈ eachcol(obj)]
    newnames = simplify(Symbol.(names(obj)); kwargs...)
    DataFrame(newcols, newnames)
end

function simplify(obj::Nothing; kwargs...)
    missing
end

function simplify(obj::AbstractDict; kwargs...)
    result = empty(obj)
    for (key, value) ∈ obj
        result[simplify(key; kwargs...)] = simplify(value; kwargs...)
    end
    result
end

nonmissing(value, default) = ismissing(value) ? default : value

function to_json_dict(
    data::AbstractDataFrame,
    keys = [:state, :city, :date];
    values = [:confirmed, :active, :recovered, :deaths],
    dfvalues = [:estimated_population],
)
    len = nrow(data)
    colnames = names(data)
    key = first(keys)
    restkeys = keys[2:end]
    @argcheck key ∈ colnames

    jsondict = OrderedDict()
    if isempty(restkeys)
        for jsonkey ∈ intersect(dfvalues, colnames)
            jsondict[jsonkey] = data[1, jsonkey]
        end
        values = intersect(values, colnames)
        for i ∈ 1:len
            jsonkey = data[i, key]
            jsonval =
                OrderedDict([string(index) => prettify(data[i, index]) for index ∈ values])
            jsondict[jsonkey] = jsonval
        end
    else
        for (gkey, gdata) ∈ pairs(groupby(data, key))
            jsondict[gkey[key]] = to_json_dict(gdata, restkeys)
        end
    end
    jsondict
end

function to_json(
    data::AbstractDataFrame,
    keys = [:state, :city, :date];
    values = [:confirmed, :active, :recovered, :deaths],
    dfvalues = [:estimated_population],
)
    JSON.json(to_json_dict(data, keys; values = values, dfvalues = dfvalues), 4)
end

function _debuginfo(df::AbstractDataFrame)
    summary(df) * " with columns " * "$(Tuple(Symbol.(names(df))))"
end

function _debuginfo(dict::AbstractDict)
    summary(dict) * " with keys " * "$(Tuple(keys(dict)))"
end

_debuginfo(object) = summary(object)

# function maybe_load_language(; force::Bool = false)
#     if Sys.iswindows() && (force || isnothing(get(ENV, "LANGUAGE", nothing)))
#         try
#             txt = read(
#                 `reg query "HKCU\Control Panel\Desktop" /v PreferredUILanguages`,
#                 String,
#             )
#             txt = filter(!isequal('\r'), txt)
#             lines = filter(!isempty, split(txt, '\n'))
#             if lines[1] == "HKEY_CURRENT_USER\\Control Panel\\Desktop"
#                 langs = filter(!isempty, _win_get_lang.(lines[2:end]))
#                 get!(ENV, "LANG", langs[1])
#                 ENV["LANGUAGE"] = join(langs, ':')
#             end
#         catch exc
#             ENV["LANGUAGE"] = "en"
#         end
#     end
#     if force || textdomain() != "endemicmodel"
#         bindtextdomain(
#             "endemicmodel",
#             realpath(joinpath(dirname(Base.pathof(EndemicModel)), "..", "languages")),
#         )
#         textdomain("endemicmodel")
#     end
# end

function _win_get_lang(line)
    tokens = filter(!isempty, split(line, ' '))
    if tokens[1] == "PreferredUILanguages"
        return replace(tokens[end], '-' => '_')
    end
    ""
end


text:
###################################################
## network/tools/yenksp.jl
## Yen's K-shortest path algorithm
###################################################

struct HeapEntry
  path::Vector{Int}
  length::Float64
end

# define appropriate comparators for heap entries
isless(e1::HeapEntry, e2::HeapEntry) = e1.length < e2.length
<(e1::HeapEntry, e2::HeapEntry) = e1.length < e2.length

"""
    `getPathFromParents(parents, orig, dest)`
    Returns path between origin and destination (list of node ids)
"""
function getPathFromParents(parents::Vector{Int}, orig::Int, dest::Int)
    path = Int[dest]
    lastNode = dest
    while lastNode != orig
        lastNode = parents[lastNode]
        push!(path, lastNode)
    end
    return path[end:-1:1]
end

"""
    `yenKSP`: Yen's K-shortest path algorithm
    Args:
        - timings   : NetworkTimings object (cost function of network)
        - t         : Network Trip for which we want to find paths
        - k         : number of shortest paths
    Returns:
        - vector of paths. each path is represented as a vector of edges
"""
function yenKSP(timings::NetworkTimings, t::NetworkTrip, k::Int)
    orig = t.orig[2]
    dest = t.dest[1]
    # check if dijkstra shortest paths have been computed already
    if !isdefined(timings, :pathTimes)
        error("The paths have not been computed yet")
    end
    pathList = Vector{Int}[getPath(timings, orig, dest)]
    # heap of new paths
    h = HeapEntry[]
    H = mutable_binary_minheap(h)
    # find k-1 more paths
    for i = 2:k
        # for every node in last path
        for (j, node) in enumerate(pathList[i-1][1:(end-1)])
            times = copy(timings.times)
            rootPath = pathList[i-1][1:j]
            for path in pathList
                if length(path) >= j && path[1:j] == rootPath
                    times[node, path[j+1]] = Inf
                end
            end
            for spurNode in rootPath
                for prev in RoutingNetworks.in_neighbors(timings.network.graph, spurNode)
                    times[prev,spurNode] = Inf
                end
            end
            d = dijkstra_shortest_paths(timings.network.graph, node, times)
            if d.dists[dest] < Inf
                append!(rootPath, getPathFromParents(d.parents, node, dest)[2:end])
                if !(rootPath in pathList)
                    push!(H, HeapEntry(rootPath, pathTime(timings, rootPath)))
                end
            end
        end
        if length(H) == 0
            break
        else
            newPathEntry = pop!(H)
            while newPathEntry.path in pathList
                newPathEntry = pop!(H)
            end
            push!(pathList, newPathEntry.path)
        end
    end
    pathEdgesList = [toPathEdgesDict(t, path) for path in pathList]
    return pathEdgesList
end

"""
    `yenKSP`: Yen's K-shortest path algorithm
    Same as above except for a vector of network trips
"""
function yenKSP(timings::NetworkTimings, trips::Vector{NetworkTrip}, k::Int)
    if nworkers() <= 1
        paths = Array(Vector{Dict{Edge,Float64}}, length(trips))
        for (i,t) in enumerate(trips)
            paths[i] = yenKSP(timings, t, k)
        end
    else
        paths = SharedArray(Vector{Dict{Edge, Float64}}, length(trips))
        @sync @distributed for (i,t) in enumerate(trips)
            paths[i] = yenKSP(timings, t, k)
        end
    end
    return paths
end


text:
include("functions.jl")

or(values...) = e -> (values |> any(x -> x == e))

when(f::Function) = x -> e -> (f(e))

default() = f -> true

match(options...) = c -> begin
    for o ∈ options
        f = o.first
        s = o.second
        if match_single(c, f)
            return evaluate(s)
        end
    end
    return nothing
end

equals(x, y) = x == y

match_single(c, f::Function) = f(c)

match_single(c, e) = c == e

evaluate(f::Function) = f()

evaluate(e) = e