Figure 2
A matrix-matrix multiplication program in DAPPLE.
// we'll multiply a PxQ matrix by a QxR matrix to get a PxR matrix
int P, Q, R;
cin >> P >> Q >> R;
// we'll compute C = A * B
intMatrix A(P,Q), B(Q,R), C(P,R);
// load matrices; row-major order, whitespace-separated integers
cin >> A;
cin >> B;
// loop through the result locations
for (int r = 0; r < P; r++)
for (int c = 0; c < R; c++)
C[r][c] = inner(A[r][_], B[_][c]);
cout << C;
intMatrix D(P,R); // D is what C should be
cin >> D;
if (any(C != D))
cout << "The answers are different!" << endl;
else
cout << "The answers are the same." << endl;