Array operations

Status
Not open for further replies.

lelox93

Active member
Hi everyone,
I'm working with Teensy 3.2 and I'm here to ask if there is a fast way (e.g. parallel computations) to multiply element-wise two arrays like
  • array1: 1 2 3 4 5 6 7 8 9
  • array2: 2 2 2 2 2 2 2 2 2
  • result.: 2 4 6 8 10 12 14 16 18
Best regards :)
 
if all 3 arrays are of same size you can use a simple for loop

for ( uint16_t i = 0; i < sizeof(array1); i++ ) result = array1 * array2;

take care to consider array value sizes well, in case your multiplications exceed 255 in value, you may switch to uint16_t or uint32_t for array data
 
Status
Not open for further replies.
Back
Top