Guest User

Untitled

a guest
Nov 23rd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. String leftMatrix = "l";
  2. String rightMatrix = "r";
  3.  
  4. /// Print the calculation which multiplies two 4x4 matrices.
  5. ///
  6. /// The matrices store their elements in a flat array in column order.
  7. void main() {
  8. for (int c in new Iterable.generate(4)) {
  9. for (int r in new Iterable.generate(4)) {
  10. print("l[${0 + r}]*r[${c * 4 + 0}] + l[${4 + r}]*r[${c * 4 + 1}] + "
  11. "l[${8 + r}]*r[${c * 4 + 2}] + l[${12 + r}]*r[${c * 4 + 3}],");
  12. }
  13. }
  14. }
  15.  
  16. /*
  17. l[0]*r[0] + l[4]*r[1] + l[8]*r[2] + l[12]*r[3],
  18. l[1]*r[0] + l[5]*r[1] + l[9]*r[2] + l[13]*r[3],
  19. l[2]*r[0] + l[6]*r[1] + l[10]*r[2] + l[14]*r[3],
  20. l[3]*r[0] + l[7]*r[1] + l[11]*r[2] + l[15]*r[3],
  21. l[0]*r[4] + l[4]*r[5] + l[8]*r[6] + l[12]*r[7],
  22. l[1]*r[4] + l[5]*r[5] + l[9]*r[6] + l[13]*r[7],
  23. l[2]*r[4] + l[6]*r[5] + l[10]*r[6] + l[14]*r[7],
  24. l[3]*r[4] + l[7]*r[5] + l[11]*r[6] + l[15]*r[7],
  25. l[0]*r[8] + l[4]*r[9] + l[8]*r[10] + l[12]*r[11],
  26. l[1]*r[8] + l[5]*r[9] + l[9]*r[10] + l[13]*r[11],
  27. l[2]*r[8] + l[6]*r[9] + l[10]*r[10] + l[14]*r[11],
  28. l[3]*r[8] + l[7]*r[9] + l[11]*r[10] + l[15]*r[11],
  29. l[0]*r[12] + l[4]*r[13] + l[8]*r[14] + l[12]*r[15],
  30. l[1]*r[12] + l[5]*r[13] + l[9]*r[14] + l[13]*r[15],
  31. l[2]*r[12] + l[6]*r[13] + l[10]*r[14] + l[14]*r[15],
  32. l[3]*r[12] + l[7]*r[13] + l[11]*r[14] + l[15]*r[15],
  33. */
Add Comment
Please, Sign In to add comment