Matrix multiplication: Difference between revisions

Content added Content deleted
(→‎JS ES6: Adjusted primitives, tidied.)
m (→‎JS ES6: Tidied)
Line 3,757: Line 3,757:
<lang JavaScript>((() => {
<lang JavaScript>((() => {
"use strict";
"use strict";

// -------------- MATRIX MULTIPLICATION --------------


// matrixMultiply :: Num a => [[a]] -> [[a]] -> [[a]]
// matrixMultiply :: Num a => [[a]] -> [[a]] -> [[a]]
Line 3,770: Line 3,772:
);
);
};
};

// dotProduct :: Num a => [[a]] -> [[a]] -> [[a]]
const dotProduct = xs =>
compose(sum, zipWith(mul)(xs));




Line 3,784: Line 3,782:
[-3, 5, 0],
[-3, 5, 0],
[3, 7, -2]
[3, 7, -2]
])([
]
)([
[-1, 1, 4, 8],
[-1, 1, 4, 8],
[6, 9, 10, 2],
[6, 9, 10, 2],
Line 3,801: Line 3,800:
x => x
x => x
);
);


// dotProduct :: Num a => [[a]] -> [[a]] -> [[a]]
const dotProduct = xs =>
compose(sum, zipWith(mul)(xs));