lundi 4 décembre 2023

How to translate a np.array.view() operation to c++ function

How can I perform this operation in c++ : y = y.view(dtype=int64) * (2**-18), where y is a numpy array where each element holds 16 uint8_t values (128-bits in total).

This is my input y :

[0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0],
[0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0],
[209  97 173 255 255 255 255 255 157 210  83   0   0   0   0   0],
[ 99 139 170 255 255 255 255 255   4 214  86   0   0   0   0   0],
[ 46 172 247 255 255 255 255 255 225 125   8   0   0   0   0   0],
[178 109 184 255 255 255 255 255 223 166  72   0   0   0   0   0],
[0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0],
[0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0]

and here is the expected output:

y_fpga: [[  1.           0.        ]
 [  1.           0.        ]
 [-20.65447617  20.95567703]
 [-21.36388016  21.70899963]
 [ -2.08185577   2.12292862]
 [-17.89287567  18.16296005]
 [  1.           0.        ]
 [  1.           0.        ]]

Aucun commentaire:

Enregistrer un commentaire