import numpy as np def vmodsquare(t): return np.sum(t * np.conj(t), axis=(0, 1)).real…
Jump to turn (10)
- 1import numpy as np def vmodsquare(t): return np.sum(t np.conj(t), axis=(0, 1)).r
- 2the result i want is hex numbers
- 3def randn(args): cnum = np.random.randn(args) + \ np.random.randn(args) 1j retur
- 4how to change the random number in range(-10, 10)
- 5how to write a matrix insists with complex numbers into a text, which one line i
- 6according to the information above, if i got a 1616 matrix i want to write into
- 7np.savetxt(f, block, fmt='%.2f%+.2fj', delimiter=' ') ValueError: fmt has wrong
- 8still wrong, maybe we could change the FLOAT16 number into hex to save it
- 9where's the complex parts i need to join the real number and plural part without
- 10A = np.array([ [1, 2, 3, 4], [5,6,7,8], [9,10,11,12], [13,14,15,16]]) i think u
- User
import numpy as np
def vmodsquare(t): return np.sum(t * np.conj(t), axis=(0, 1)).real
def compute(left, right, rin): rout = left @ rin @ right pout = vmodsquare(rout) return rout, pout
def randn(*args): cnum = np.random.randn(args) + np.random.randn(args) * 1j return cnum.astype(np.csingle)
if name == ‘main’: RE, RB, M, N = 4, 4, 48, 32
left = randn(M, M) #4848 right = randn(N, N) #3232 rin = randn(RB, RE, M, N) #4, 4, 48, 32
print('left = ', left.shape, ‘\n’, left) print('right = ', right.shape, ‘\n’, right) print('rin = ', rin.shape, ‘\n’, rin)
rout, pout = compute(left, right, rin)
print('rout = ', rout.shape, ‘\n’, rout) print('pout = ', pout.shape, ‘\n’, pout)
write a script to write the result “rout” and “pout” into a text “output.txt”, format like addr:147456, size:200 0x34234134 0xae691476 … the result number need to change into FLOAT16 and one line include two FLOAT16 numbers
- Assistant