This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exact square root of a known square integer | |
// =========================================== | |
// This snippet contains a function `isqrt64_exact` with signature | |
// | |
// uint32_t isqrt64_exact(uint64_t n); | |
// | |
// `isqrt64_exact` computes the 32-bit square root of its unsigned 64-bit | |
// integer input, under the assumption that that input is a perfect square. | |
// | |
// Compile under gcc or clang with: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
def hilbert(): | |
""" | |
Return NumPy array of shape (512, 3) containing successive coordinates | |
for a third-order three-dimensional Hilbert curve. | |
""" | |
a,b,c=numpy.indices((8,)*3).reshape(3,-1) | |
d=c[:8];r=abs(d-3>>1);g=(d^d>>1)*73;f=g[abs(d-1)&6] |