correct tensor random access to elements. Now need to improve for time efficiency
bug with static allocation
try linear memory