The overhead of the np.matrix class is quite high for small matrices. See for example the following code:
import numpy as np
The second implementation performs much better by using a copy instead of a constructor. Is there a way to efficiency create a new np.matrix object? For other functions in my code I do not have the option to copy an existing matrix, but I need to construct a new object or perform a cast from np.array to np.matrix.
I am already aware of two alternatives:
- Using the .dot functions from np.array. This works, but personally I like the notation using np.matrix much better.
With kind regards,