Same behavior with m1=list(m2).

Code: Select all

```
import pyb #Testing pyboard math speed.
pyb.LED(3).on()
#5x5 matrix y=A*X, X unknoown, coded A:Y:I, solved to I:X:Ainv,
#This code may be shortened to solve only for X at minimal waste
m2=[ [ 0.0 for i in range(11) ] for j in range(5) ]
m1=[ [ 0.0 for i in range(11) ] for j in range(5) ]
m2=[[2.3,5.5,7.5,8.2,7.2,3.4,1,0,0,0,0],
[4.3,2.2,2.1,6.3,9.4,6.5,0,1,0,0,0],
[0,6.6,5.8,4.2,8.1,8.8,0,0,1,0,0],
[3.6,3.6,-8.6,0,-3.4,-3.1,0,0,0,1,0],
[8.1,-4.5,2.6,6.7,5.1,5,0,0,0,0,1]]
col=11 #total collumbs n+1+n, n+1 to not solve Ainv.
n= 5 #rows
m= 4 #n-1
i=0
j=0
k=0
e=0.0
f=0.0
g=0.0
h=0.0
d=1e-4 #zero? close enough
h=-d
itt =0
while itt<1001: #Increase until desired delay
#reset to initial matrix
"""
m1=list(m2)
"""
i=0
while i<n:
j=0
while j<col:
m1[i][j] = m2[i][j]
j+=1
i+=1
#
i=0
while i < n: #for each row
e=m1[i][i] #read the diagonal element
if d>e and e>h: #deal with zero diagonal element?
j=i
if j>=n:
pyb.LED(1).on() #error no solution
while j<m:#look for a row with non-zero element
j+=1
g=m1[j][i]
if g<h or g>d:#add the rows
k=i #zeros assumed to left
while k<col:
m1[i][k]+=m1[j][k]
k+=1
j=n
e=m1[i][i]#read the new diagonal element
#scale row for 1 in diagonal
e=1/e
j=i #zeros assumed to left
while j<col:
m1[i][j]=m1[i][j]*e
j+=1
j=0
while j<n:
if j!=i:
f=-m1[j][i]#value of element to eliminate
k=i+1#k=i to actualy eliminate it and give clean I
while k<col:
m1[j][k]+=m1[i][k]*f
k+=1
j+=1
i+=1
itt+=1
pyb.LED(4).toggle()
answer = 2.192383196 #X(0)
e = m1[0][5]-answer #error difference
if d>e and e>h:#little diff.
pyb.LED(2).on()#green light on
else:
pyb.LED(1).on()#red light on
```