1

I have a matrix-valued function (i.e. $M(t): R \to R^2$) and I want to make a numpy array (i.e. [[t1, M(t1)], [t2, M(t2)], ...]). My solution is pretty obvious and clumsy:

bigM = np.zeros(100, 10, 10)
tArray = np.linspace(1, 101, 100)
for i in range(100):
    bigM[i,:,:] = smallM(tArray[i])

But it really slow and it has memory problems in some cases (in fact, the 10's and 100 are much more then 10 and 100 :) ). So, there are two questions:

  1. Is there some vectorization procedure that could deal with it quicker?

  2. Am I able to solve memory problems without putting more RAM into my semiconductor friend?

UPD: Sometimes I have to deal with the same problem without introduction of bigM matrix. I.e.:

tArray = np.linspace(1, 101, 100)
someArray = np.zeros(len(tArray))
for i in range(100):
    M = smallM(tArray[i])
    ...
    someArray[i] = someFunction(M)
    ...

And still, same 2 questions arise.

UPD 2: smallM is a matrix-valued function from third-party library.

Indian
  • 1
  • 3

0 Answers0