13 lines
550 B
Plaintext
13 lines
550 B
Plaintext
var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library)
|
|
M:=GSL.Matrix(3,3).set(3,5,7, 1,2,3, 2,4,6);
|
|
x:=2;
|
|
println("M = \n%s\nx = %s".fmt(M.format(),x));
|
|
foreach op in (T('+,'-,'*,'/)){
|
|
println("M %s x:\n%s\n".fmt(op.toString()[3,1],op(M.copy(),x).format()));
|
|
}
|
|
foreach op in (T("addElements","subElements","mulElements","divElements")){
|
|
println("M %s M:\n%s\n".fmt(op, M.copy().resolve(op)(M).format()));
|
|
}
|
|
mSqrd:=M.pump(0,M.copy(),fcn(x){ x*x }); // M element by element
|
|
println("M square elements:\n%s\n".fmt(mSqrd.format()));
|