I’m working with particle positions in different arrays, something like (three particles):
import numpy as np
x = np.array([1, 2, 3])
y = np.array([2, 6, 1])
z = np.array([0, 3, 6])
I do it in this way because of matplotlib 3D plots, which require to have the different coordinates in different arrays (ax.scatter(x, y, z)
for example).
But the drawback of this approach is that if I want to multiply matrices:
mat = np.array([[10, 0, 0], [0, 10, 0], [0, 0, 10]])
I cannot use np.dot
directly because coordinates are in different arrays, therefore I have to merge then and unmerge after multiplication. I know how to do that (np.transpose([x, y, z])
), but I’m concerned about efficiency, I don’t know if these operations are hard for big arrays (I’m working with hundred thousands or millions of particles). Maybe there is a numpy function for this that I don’t know. Of course, it’s not hard to implement it by myself.