Advertisement
Guest User

Untitled

a guest
Oct 13th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. private static A reduce(A x, int axis, int id, ByteByteByteFunction f) {
  2. if (x.s.length == 0) return x;
  3. if (axis < 0) axis += x.s.length;
  4. int n0 = intProduct(x.s, 0, axis), n1 = x.s[axis], n2 = intProduct(x.s, axis + 1, x.s.length);
  5. int[] s = intDelAt(x.s, axis);
  6. byte[] r = new byte[n0 * n2];
  7. if (id != 0) fill(r, (byte) id);
  8. for (int i = 0; i < n0; i++)
  9. for (int j = 0; j < n1; j++)
  10. for (int k = 0; k < n2; k++)
  11. r[i * n2 + k] = f.apply(r[i * n2 + k], x.a[i * n1 * n2 + j * n2 + k]);
  12. return new A(r, s);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement