Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Kronecker-product/JavaScript/kronecker-product-1.js
Normal file
17
Task/Kronecker-product/JavaScript/kronecker-product-1.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// matkronprod.js
|
||||
// Prime function:
|
||||
// mkp arrow function: Return the Kronecker product of the a and b matrices.
|
||||
// Note: both a and b must be matrices, i.e., 2D rectangular arrays.
|
||||
mkp=(a,b)=>a.map(a=>b.map(b=>a.map(y=>b.map(x=>r.push(y*x)),t.push(r=[]))),t=[])&&t;
|
||||
// Helper functions:
|
||||
// Log title and matrix mat to console
|
||||
function matl2cons(title,mat) {console.log(title); console.log(mat.join`\n`)}
|
||||
// Print title to document
|
||||
function pttl2doc(title) {document.write('<b>'+title+'</b><br />')}
|
||||
// Print title and matrix mat to document
|
||||
function matp2doc(title,mat) {
|
||||
document.write('<b>'+title+'</b>:<br />');
|
||||
for (var i = 0; i < mat.length; i++) {
|
||||
document.write(' '+mat[i].join(' ')+'<br />');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue