← Back to team overview

yade-dev team mailing list archive

Re: wm3-eigen glue

 

OK, let the fun begin:

python: /usr/include/eigen2/Eigen/src/Core/MatrixStorage.h:44:
Eigen::ei_matrix_array<T, Size, MatrixOptions, Align>::ei_matrix_array()
[with T = double, int Size = 2, int MatrixOptions = 2, bool Align =
true]: Assertion `(reinterpret_cast<size_t>(array) & 0xf) == 0 && "this
assertion is explained here:
http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html  **** READ THIS
WEB PAGE !!! ****"' failed.

(read that page and you will see)

for the start, I would just disable alignment and vectorization, which
is the easy way.

Cheers, Vaclav

PS I got this error when running python script, running simulations just
hard-crashed. I attach this script, it is adapted version of the math
part of  py/tests/wrapper.py.


def assert_(a):
	if not a: print 'Error'
def assertAlmostEqual(a,b):
	if a!=b and abs(a-b)/abc(b)>1e-3:
			print 'Not equal ',a,b
def assertSeqAlmostEqual(v1,v2):
	"floating-point comparison of vectors/quaterions"
	assert(len(v1)==len(v2));
	for i in range(len(v1)): 
		if v1[i]!=v2[i] and abs(v1[i]-v2[i])/abs(v1[i])>1e-3:
			print 'Component '+str(i)+' of '+str(v1)+' and '+str(v2)

v=Vector2(1,2); v2=Vector2(3,4)
print v+v2==Vector2(4,6)
print Vector2().UNIT_X.Dot(Vector2().UNIT_Y)==0
print Vector2().ZERO.Length()==0
v=Vector3(3,4,5); v2=Vector3(3,4,5)
assert_(v[0]==3 and v[1]==4 and v[2]==5)
assert_(v.SquaredLength()==50)
assert_(v==(3,4,5)) # comparison with list/tuple
assert_(v==[3,4,5])
assert_(v==v2)
x,y,z,one=Vector3().UNIT_X,Vector3().UNIT_Y,Vector3().UNIT_Z,Vector3().ONE
assert_(x+y+z==one)
assert_(x.Dot(y)==0)
assert_(x.Cross(y)==z)
q1=Quaternion((0,0,1),pi/2)
q2=Quaternion(Vector3(0,0,1),pi/2)
q1==q2
x,y,z,one=Vector3().UNIT_X,Vector3().UNIT_Y,Vector3().UNIT_Z,Vector3().ONE
assertSeqAlmostEqual(q1*x,y)
assertSeqAlmostEqual(q1*q1*x,-x)
assertSeqAlmostEqual(q1*q1.Conjugate(),Quaternion().IDENTITY)
assertSeqAlmostEqual(q1.ToAxisAngle()[0],(0,0,1))
assertAlmostEqual(q1.ToAxisAngle()[1],pi/2)
#construction
m1=Matrix3(1,0,0,0,1,0,0,0,1)
# comparison
assert_(m1==Matrix3().IDENTITY)
# rotation matrix from quaternion
m1.FromAxisAngle(Vector3(0,0,1),pi/2)
# multiplication with vectors
assertSeqAlmostEqual(m1*Vector3().UNIT_X,Vector3().UNIT_Y)
# determinant
m2=Matrix3(-2,2,-3,-1,1,3,2,0,-1)
assertEqual(m2.Determinant(),18)
# inverse 
inv=Matrix3(-0.055555555555556,0.111111111111111,0.5,0.277777777777778,0.444444444444444,0.5,-0.111111111111111,0.222222222222222,0.0)
m2inv=m2.Inverse()
assertSeqAlmostEqual(m2inv,inv)
# matrix-matrix multiplication
assertSeqAlmostEqual(Matrix3().IDENTITY*Matrix3().IDENTITY,Matrix3().IDENTITY)
m3=Matrix3(1,2,3,4,5,6,-1,0,3)
m33=m3*m3
assertSeqAlmostEqual(m33,Matrix3(6,12,24,18,33,60,-4,-2,6))


Follow ups

References