numpy.linspace
is one-dimensional linear gradient. For example: numpy.linspace(0, 3, 4):
[0, 1, 2, 3]
It is easy to imagine 2-dimensional linear gradient:
[[[0, 0], [1, 0], [2, 0], [3, 0]],
[[0, 1], [1, 1], [2, 1], [3, 1]],
[[0, 2], [1, 2], [2, 2], [3, 2]],
[[0, 3], [1, 3], [2, 3], [3, 3]]]
What I need is 3 or even 4-dimensional linear gradients using numpy.
I can easily achieve it using Python code, but it is too slow.
%time arr = numpy.array([
[
[
(a, b, c)
for a in range(65)
]
for b in range(65)
]
for c in range(65)
])
Wall time: 177 ms
arr.shape
(65, 65, 65, 3)