///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
// calulates the determinant of a matrix m with ord 
// columns.
float wasDeterminant(list m, integer ord) {
    float result = 0;
    integer i = 0;
    integer o = -1;
    do {
        //i * cof (i) - i * cof(i) + i * cof(i) - ...
        list cof = wasMatrixCofactor(m, 0, i, ord);
        if(llGetListLength(cof) == 2) {
            if(o = ~o) {
                result -= llList2Float(m, i) * llList2Float(cof, 0);
                jump next;
            }
            result += llList2Float(m, i) * llList2Float(cof, 0);
            jump next;
        }
        if(llGetListLength(cof) == 0) return llList2Float(m, i);
        if(o = ~o) {
            result -=  llList2Float(m, i) * wasDeterminant(cof, ord-1);
            jump next;
        }
        result +=  llList2Float(m, i) * wasDeterminant(cof, ord-1);
@next;
    } while(++i<ord);
    return result;
}