Dec-15-2019, 07:04 PM
Hello,
I'm a physic student and I am working on a simulation and I have some weird results. I wonder if my errors didn't come from my misunderstanding of basics. For this work I need to create two functions : the first one to create an array using global variable (which are not array) and the second one to modify an array which already exist using the array created by the first function. I knows that there is some subtility with this tye of functions but I don't know them. Let's start with the firts one.
P.S :I cannot post all the code because if they see my code somewhere else they could accuse me of plagiarism and I don't want any problem. So I will just put '######' to replace parts of the code which I'm sure are correct.
Thanks for your help.
I'm a physic student and I am working on a simulation and I have some weird results. I wonder if my errors didn't come from my misunderstanding of basics. For this work I need to create two functions : the first one to create an array using global variable (which are not array) and the second one to modify an array which already exist using the array created by the first function. I knows that there is some subtility with this tye of functions but I don't know them. Let's start with the firts one.
P.S :I cannot post all the code because if they see my code somewhere else they could accuse me of plagiarism and I don't want any problem. So I will just put '######' to replace parts of the code which I'm sure are correct.
Import numpy as np def f1(l): # l is used in the program as an idex for the array B defined at the begining of my code. D is also an array q=(h/B[l])*D # h is a float defined at the begining of my code e=q[0]/(B[l]) A=np.diag(e) for i in range(0,n): # n,m int defined at the begining of my code ################ # part of the code wich inject q in A return ANow the second function which takes an existing array F and and int u.
def f2(F,u): for i in range(1,J): #J int defined at the begining of the code F[:,u]=f1(i)@F[:,u]@F[:,u-1] return FI need F[:,u] to be modified and F[:,u-1] to be non-modified. Then I used
for u in x: #x an array of int defined at the begining of my code f2(F,u)So I use the two functions to modify some columns of F. Is the structure of my code problematic ?
Thanks for your help.