Skip to content

Instantly share code, notes, and snippets.

@nbecker
Created May 19, 2021 12:46
Show Gist options
  • Save nbecker/da7509661f031a0ce56baaef32e9e728 to your computer and use it in GitHub Desktop.
Save nbecker/da7509661f031a0ce56baaef32e9e728 to your computer and use it in GitHub Desktop.
orthogonal_mod
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
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