yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #03634
Matrix3
Hello,
In Yade I work with two independent Matrix3 objects. Initially, they have all elements zeros, so I used Matrix3.Zero. But if I change an element in one matrix, it is changed in the other one as well.. here is an interactive session:
Yade [1]: a = Matrix3.Zero
Yade [2]: a
-> [2]: Matrix3(0,0,0, 0,0,0, 0,0,0)
Yade [3]:
Yade [4]: b = Matrix3.Zero
Yade [5]: b
-> [5]: Matrix3(0,0,0, 0,0,0, 0,0,0)
Yade [6]:
Yade [7]: a==b
-> [7]: True
Yade [8]:
Yade [9]: a is b
-> [9]: False
Yade [10]:
Yade [11]: a[0,1] = 2.
Yade [12]:
Yade [13]: a
-> [13]: Matrix3(0,2,0, 0,0,0, 0,0,0)
Yade [14]:
Yade [15]: b
-> [15]: Matrix3(0,2,0, 0,0,0, 0,0,0)
Yade [16]:
Yade [17]: a == b
-> [17]: True
Yade [18]:
Yade [19]: a is b
-> [19]: False
One possibility I found is not to use .Zero function:
Yade [1]: a = Matrix3()
Yade [2]: a
-> [2]: Matrix3(-1.49871e-63,-1.49737e-63,-1.49856e-63, -1.49841e-63,-1.49871e-63,-1.49852e-63, -1.49826e-63,-1.49826e-63,-1.49826e-63)
Yade [3]:
Yade [4]: for i in range(3):
...: for j in range(3):
...: a[i,j] = 0.
...:
...:
Yade [5]: a
-> [5]: Matrix3(0,0,0, 0,0,0, 0,0,0)
Yade [6]:
Yade [7]: b = Matrix3()
Yade [8]: b
-> [8]: Matrix3(7.84852e-314,1.9098e-313,7.46175e-308, -1.0674e-63,1.9034e-312,0, 2.96439e-323,1.71882e-312,0)
Yade [9]: for i in range(3):
for j in range(3):
b[i,j] = 0.
....:
....:
Yade [12]: b
-> [12]: Matrix3(0,0,0, 0,0,0, 0,0,0)
Yade [13]:
Yade [14]: a[0,1] = 2.
Yade [15]: a
-> [15]: Matrix3(0,2,0, 0,0,0, 0,0,0)
Yade [16]:
Yade [17]: b
-> [17]: Matrix3(0,0,0, 0,0,0, 0,0,0)
My question is, if there is some simplier procedure to achieve two independent Matrix3 objects with elements equal zero?
Thanks,
Jan
Follow ups