///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
// returns the dot-product of two matrices providing that
// the number of columns (ord_m) of matrix m is equal to
// the number of rows of matrix n
list wasMatrixDotProduct(list m, list n, integer ord_m, integer ord_n) {
    list result = [];
    integer i = 0;
    integer j = 0;
    do {
        do {
            integer sub_i = i;
            integer sub_j = j;
            float val = 0;
            do {
                val += llList2Float(m, sub_i) * llList2Float(n, sub_j);
                sub_j += ord_n;
                ++sub_i;
            } while(sub_j<llGetListLength(n));
            result += val;
        }
        while(++j<ord_n);
        i+=ord_m;
        j=0;
    } while(i<llGetListLength(m));
    return result;
}