Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

114 lines (101 sloc) 3.432 kB
<!DOCTYPE html>
<html data-require="math math-format kmatrix matrix-input">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scalar matrix multiplication</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="MAT_A">randRange(-2, 4, ROWS, COLS)</var>
<var id="SCALAR">randFromArray([-1, 1]) * (rand(4) === 0 ? randRange(1, 3) / 4 : randRange(2, 5))</var>
<var id="SCALAR_TEXT">decimalFraction(SCALAR, true)</var>
<var id="OPERATION">"\\times"</var>
<var id="SOLN_MAT">
deepZipWith(2, function(a) {
return a * SCALAR;
}, MAT_A)
</var>
<var id="PADDED_SOLN_MAT">matrixPad(SOLN_MAT, 3, 3)</var>
<var id="MAT_A_COLOR">BLUE</var>
<var id="SCALAR_COLOR">GREEN</var>
<var id="SOLN_MAT_COLOR">PINK</var>
<var id="PRETTY_MAT_A">
printSimpleMatrix(MAT_A, MAT_A_COLOR)
</var>
<var id="PRETTY_HINT_MAT">
printMatrix(function(a) {
var s = colorMarkup(SCALAR_TEXT, SCALAR_COLOR);
var b = colorMarkup(a, MAT_A_COLOR);
return s + OPERATION + b;
}, MAT_A)
</var>
<var id="PRETTY_SOLN_MAT">
printFractionMatrix(SOLN_MAT, SOLN_MAT_COLOR)
</var>
</div>
<div class="question">
<code>
\Large{
\color{<var>SCALAR_COLOR</var>}{<var>SCALAR_TEXT</var>}
<var>OPERATION</var>
<var>PRETTY_MAT_A</var> = {?}
}
</code>
</div>
<div class="hints">
<div>
<p>To multiply a matrix by a number, multiply each item of the matrix by the number.</p>
<div>
<code>\Large{<var>PRETTY_HINT_MAT</var>}</code>
</div>
</div>
<div>
<p>Now, simplify:</p>
<div>
<code>\Large{<var>PRETTY_SOLN_MAT</var>}</code>
</div>
</div>
</div>
<div class="solution" data-type="multiple">
<div class="matrix-row" data-each="PADDED_SOLN_MAT as row">
<span data-each="row as elem">
<span class="sol" data-if="elem !== ''">
<var>elem</var>
</span>
<span class="sol" data-else="" data-type="text">
<var>elem</var>
</span>
</span>
</div>
</div>
<div class="problems">
<div id="2x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">2</var>
</div>
</div>
<div id="2x3">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">3</var>
</div>
</div>
<div id="3x1">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">1</var>
</div>
</div>
<div id="3x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">2</var>
</div>
</div>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.