Skip to content
Advertisement

Numpy matrix creation timing oddity

My application requires a starting matrix where each column is staggered-by-1 from the previous. It will contain millions of complex numbers representing a signal, but a small example is:

JavaScript

I tried two creation methods, one fast, one slow. I don’t understand why the fast matrix creation method causes subsequent calculations to run slowly, while the slow matrix creation results in faster running calculations. The subroutine calcs() simply takes FFTs to offer minimal code to demonstrate the issue I see in my actual signal processing code. A sample run yields:

JavaScript

Code follows. Any insight would be appreciated!

JavaScript

Advertisement

Answer

user3483203’s comment, above, provides answer to the issue. If I avoid the transpose by creating the matrix with:

JavaScript

subsequent calcs() timing is as expected. Thank you, user3483203!

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement