12 lines
408 B
Plaintext
12 lines
408 B
Plaintext
var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library)
|
|
fcn perm(A){ // should verify A is square
|
|
numRows:=A.rows;
|
|
Utils.Helpers.permute(numRows.toList()).reduce( // permute(0,1,..numRows)
|
|
'wrap(s,pm){ s + numRows.reduce('wrap(x,i){ x*A[i,pm[i]] },1.0) },
|
|
0.0)
|
|
}
|
|
test:=fcn(A){
|
|
println(A.format());
|
|
println("Permanent: %.2f, determinant: %.2f".fmt(perm(A),A.det()));
|
|
};
|