illustrateMatMult = function ({ A, B, C }) {
const color = d3.scaleSequential(d3.interpolateWarm).domain([0, A.ncol]);
const background = function (c) {
const c0 = d3.lab(c).brighter(1.5).toString();
return `${c0}`;
};
return html`
${renderMatrix(A.ncol, A.vals, {
title: tex`\bm{A}_{${A.nrow}×${A.ncol}}`,
background: (d, i, j) => (i === inspect[0] ? background(color(j)) : "")
})}
<span class=operator>${tex`×`}</span>
${renderMatrix(B.ncol, B.vals, {
title: tex`\bm{B}_{${B.nrow}×${B.ncol}}`,
background: (d, i, j) => (j === inspect[1] ? background(color(i)) : "")
})}
<span class=operator>${tex`=`}</span>
${renderMatrix(C.ncol, C.vals, {
title: tex`\bm{C}_{${C.nrow}×${C.ncol}}`,
background: (d, i, j) =>
i === inspect[0] && j === inspect[1]
? background("rgb(150, 150, 150)")
: "",
hover: (d, i, j) =>
i !== inspect[0] || j !== inspect[1] ? (mutable inspect = [i, j]) : null
})}
<div class='equation' >${kSumEq(A.ncol, inspect[0], inspect[1])}</div>
<div class='equation' >${abSumEq(A.ncol, inspect[0], inspect[1])}</div>
<div class='equation' >${valSumEq(
A.ncol,
inspect[0],
inspect[1],
A,
B,
C
)}</div>
`;
}