L1VM - vector math

Mit dem neuen Vector Math Modul kann man Berechnungen mit Arrays durchführen. Man kann z.B. zu einem Arraybereich eine Zahl zu allen Array Indexen addieren. Oder zwei Arrays miteinander addieren und die Ergebnisse in einem dritten Array speichern. Man kann alle vier Grundrechenarten verwenden! (+, -, *, /) Die Vectorberechnungen können sehr schnell ausgeführt werden

With the new vector math module you can do calculations on arrays. It is for example possible to add a number to all array indexes in a set range. Or you can add two arrays and store the result in a third array. It is possible to use all four math kinds! (+, -, *, /) The vector calculations can be run fast.

Here is an example: The two arrays “av” and “bv” are multiplied and stored in array “cv”.

// math-lib-vect.l1com
(main func)
	(set int64 1 zero 0)
	(set int64 1 max 9)
	(set int64 10 av 1 2 3 4 5 6 7 8 9 10)
	(set int64 10 bv 2 4 6 8 10 12 14 16 18 20)
	(set int64 10 cv)
	(set int64 1 av_addr 16)
	(set int64 1 bv_addr 96)
	(set int64 1 cv_addr 176)
	(set int64 1 i 0)
	(set int64 1 offset 8)
	(set int64 1 real_ind 0)
	(set int64 1 f 0)
	(set int64 1 x 0)
	(set int64 1 one 1)
	(zero :math_vect_init call)
	(loadreg)
	(av_addr bv_addr zero max cv_addr :vmath_mul_int_array call)
	(loadreg)
	// print cv array
	(:loop)
	(cv [ real_ind ] x =)
	(4 x 0 0 intr0)
	(7 0 0 0 intr0)
	((real_ind offset +) real_ind =)
	((i one +) i =)
	(((i max <=) f =) f if)
		(:loop jmp)
	(endif)
	// close module
	(1 zero 0 0 intr0)
	(255 zero 0 0 intr0)
(funcend)
#include <math-lib-vect.l1h>