I have this function:
def fun(x): # x is a vector with size: (size_x*size_y) = n
c = 0
f_vec = np.zeros((size_x*size_y))
for i in range(size_x):
for j in range(size_y):
f_vec[c]=i*j*x[c]
c=c+1
return f_vec
I do this because what happens is that the vector x is (considering size_x=4 and size_y=3)
x[0]=x00 #c=0 i=0,j=0
x[1]=x01 #c=1 i=0, j=1
x[2]=x02 #c=2 i=0. j=size_y-1
x[3]=x10 #c=3 i=1, j=0
x[4]=x11
...
x[n]=x32 #c=n i=size_x-1, j= size_y-1
Can I avoid the nested loop and do a simple vector operation? I would like to have something like f[c] = F[x[c]] *i *j
But it is not that simple to find i and j by knowing the c value. Do you know a way?
Thanks.