Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String leftMatrix = "l";
- String rightMatrix = "r";
- /// Print the calculation which multiplies two 4x4 matrices.
- ///
- /// The matrices store their elements in a flat array in column order.
- void main() {
- for (int c in new Iterable.generate(4)) {
- for (int r in new Iterable.generate(4)) {
- print("l[${0 + r}]*r[${c * 4 + 0}] + l[${4 + r}]*r[${c * 4 + 1}] + "
- "l[${8 + r}]*r[${c * 4 + 2}] + l[${12 + r}]*r[${c * 4 + 3}],");
- }
- }
- }
- /*
- l[0]*r[0] + l[4]*r[1] + l[8]*r[2] + l[12]*r[3],
- l[1]*r[0] + l[5]*r[1] + l[9]*r[2] + l[13]*r[3],
- l[2]*r[0] + l[6]*r[1] + l[10]*r[2] + l[14]*r[3],
- l[3]*r[0] + l[7]*r[1] + l[11]*r[2] + l[15]*r[3],
- l[0]*r[4] + l[4]*r[5] + l[8]*r[6] + l[12]*r[7],
- l[1]*r[4] + l[5]*r[5] + l[9]*r[6] + l[13]*r[7],
- l[2]*r[4] + l[6]*r[5] + l[10]*r[6] + l[14]*r[7],
- l[3]*r[4] + l[7]*r[5] + l[11]*r[6] + l[15]*r[7],
- l[0]*r[8] + l[4]*r[9] + l[8]*r[10] + l[12]*r[11],
- l[1]*r[8] + l[5]*r[9] + l[9]*r[10] + l[13]*r[11],
- l[2]*r[8] + l[6]*r[9] + l[10]*r[10] + l[14]*r[11],
- l[3]*r[8] + l[7]*r[9] + l[11]*r[10] + l[15]*r[11],
- l[0]*r[12] + l[4]*r[13] + l[8]*r[14] + l[12]*r[15],
- l[1]*r[12] + l[5]*r[13] + l[9]*r[14] + l[13]*r[15],
- l[2]*r[12] + l[6]*r[13] + l[10]*r[14] + l[14]*r[15],
- l[3]*r[12] + l[7]*r[13] + l[11]*r[14] + l[15]*r[15],
- */
Add Comment
Please, Sign In to add comment