use zeros() instead of explicitly zeroing
This commit is contained in:
parent
0e98ea5cb5
commit
b8314f290c
15
Sketch.py
15
Sketch.py
@ -28,12 +28,8 @@ class Sketch(object):
|
|||||||
shape_vars[shape_var] = varid
|
shape_vars[shape_var] = varid
|
||||||
varid += 1
|
varid += 1
|
||||||
varid_to_shape_var.append(shape_var)
|
varid_to_shape_var.append(shape_var)
|
||||||
C = empty((len(equations), len(shape_vars)))
|
C = zeros((len(equations), len(shape_vars)))
|
||||||
d = empty(len(equations))
|
d = zeros(len(equations))
|
||||||
for row in range(len(equations)):
|
|
||||||
for col in range(len(shape_vars)):
|
|
||||||
C[row][col] = 0.0
|
|
||||||
d[row] = 0.0
|
|
||||||
for i in range(len(equations)):
|
for i in range(len(equations)):
|
||||||
e = equations[i]
|
e = equations[i]
|
||||||
coeffs = e[0]
|
coeffs = e[0]
|
||||||
@ -41,9 +37,16 @@ class Sketch(object):
|
|||||||
var_index = shape_vars[c[1]]
|
var_index = shape_vars[c[1]]
|
||||||
C[i][var_index] = c[0]
|
C[i][var_index] = c[0]
|
||||||
d[i] = e[1]
|
d[i] = e[1]
|
||||||
|
# for row in range(len(equations)):
|
||||||
|
# print '[',
|
||||||
|
# for col in range(len(shape_vars)):
|
||||||
|
# print C[row][col],
|
||||||
|
# print ',',
|
||||||
|
# print '] [%f]' % d[row]
|
||||||
s = SLE(C, d)
|
s = SLE(C, d)
|
||||||
r = s.solve()
|
r = s.solve()
|
||||||
solved_vars = r.xf
|
solved_vars = r.xf
|
||||||
|
print "SOLVED: ", solved_vars
|
||||||
for i in range(len(solved_vars)):
|
for i in range(len(solved_vars)):
|
||||||
varid_to_shape_var[i][0].setVar(varid_to_shape_var[i][1],
|
varid_to_shape_var[i][0].setVar(varid_to_shape_var[i][1],
|
||||||
solved_vars[i])
|
solved_vars[i])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user