Melang

Logo

A script language of preemptive scheduling coroutine in single thread

View the Project on GitHub Water-Melon/Melang

Matrix

Import

m = Import('matrix');
mul

Matrix multiplication.

m.mul(array1, array2);

Input:

Return value:

Error:

Example:

m = Import('matrix');
sys = Import('sys');

array1 = ['row': 3, 'col': 2, 'data':[1,0,0,1,1,1]];
array2 = ['row': 2, 'col': 2, 'data':[1,2,3,4]];
res_array = m.mul(array1, array2);
sys.print(res_array['row']);
sys.print(res_array['col']);
sys.print(res_array['data']);

The output is:

3
2
[1.000000, 2.000000, 3.000000, 4.000000, 4.000000, 6.000000, ]
inv

Matrix inversion.

m.inv(array);

Input:

Return value:

Error:

Example:

m = Import('matrix');
sys = Import('sys');

array = ['row': 2, 'col': 2, 'data':[1,0,1,1]];
res_array = m.inv(array);
sys.print(res_array['row']);
sys.print(res_array['col']);
sys.print(res_array['data']);

The output is:

2
2
[1.000000, 0.000000, -1.000000, 1.000000, ]