Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Identity-matrix/Jsish/identity-matrix.jsish
Normal file
33
Task/Identity-matrix/Jsish/identity-matrix.jsish
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* Identity matrix, in Jsish */
|
||||
function identityMatrix(n) {
|
||||
var mat = new Array(n).fill(0);
|
||||
for (var r in mat) {
|
||||
mat[r] = new Array(n).fill(0);
|
||||
mat[r][r] = 1;
|
||||
}
|
||||
return mat;
|
||||
}
|
||||
|
||||
provide('identityMatrix', 1);
|
||||
|
||||
if (Interp.conf('unitTest')) {
|
||||
; identityMatrix(0);
|
||||
; identityMatrix(1);
|
||||
; identityMatrix(2);
|
||||
; identityMatrix(3);
|
||||
var mat = identityMatrix(4);
|
||||
for (var r in mat) puts(mat[r]);
|
||||
}
|
||||
|
||||
/*
|
||||
=!EXPECTSTART!=
|
||||
identityMatrix(0) ==> []
|
||||
identityMatrix(1) ==> [ [ 1 ] ]
|
||||
identityMatrix(2) ==> [ [ 1, 0 ], [ 0, 1 ] ]
|
||||
identityMatrix(3) ==> [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]
|
||||
[ 1, 0, 0, 0 ]
|
||||
[ 0, 1, 0, 0 ]
|
||||
[ 0, 0, 1, 0 ]
|
||||
[ 0, 0, 0, 1 ]
|
||||
=!EXPECTEND!=
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue