Created
May 19, 2021 12:46
-
-
Save nbecker/da7509661f031a0ce56baaef32e9e728 to your computer and use it in GitHub Desktop.
orthogonal_mod
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 as np | |
#pythran export orthogonal_mod (int[:], int) | |
#pythran export orthogonal_mod (int32[:], int) | |
def orthogonal_mod (x, nbits): | |
out = np.zeros ((len(x), 1<<nbits), dtype=complex) | |
for e in range (len (x)): | |
out[e,x[e]] = 1 | |
return out | |
def test1 (): | |
x = np.arange (16) | |
u = orthogonal_mod (x, 4) | |
return u |
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 as np | |
from orthogonal_mod import orthogonal_mod | |
x = np.array ([0,1,0,1], dtype=np.int32) | |
o = orthogonal_mod (x, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment