import numpy as np import matrix as eigenpy verbose = False if verbose: print "===> From MatrixXd to Py" M = eigenpy.naturals(3, 3, verbose) Mcheck = np.reshape(np.matrix(range(9), np.double), [3, 3]) assert np.array_equal(Mcheck, M) if verbose: print "===> From Matrix3d to Py" M33 = eigenpy.naturals33(verbose) assert np.array_equal(Mcheck, M33) if verbose: print "===> From VectorXd to Py" v = eigenpy.naturalsX(3, verbose) vcheck = np.matrix([ range(3), ], np.double).T assert np.array_equal(vcheck, v) if verbose: print "===> From Py to Eigen::MatrixXd" if verbose: print "===> From Py to Eigen::MatrixXd" if verbose: print "===> From Py to Eigen::MatrixXd" Mref = np.reshape(np.matrix(range(64), np.double), [8, 8]) if verbose: print "===> Matrix 8x8" M = Mref assert (np.array_equal(M, eigenpy.reflex(M, verbose))) if verbose: print "===> Block 0:3x0:3"
import numpy as np import matrix as eigenpy verbose = False if verbose: print "===> From MatrixXd to Py" M = eigenpy.naturals(3,3,verbose) Mcheck = np.reshape(np.matrix(range(9),np.double),[3,3]) assert np.array_equal(Mcheck,M) if verbose: print "===> From Matrix3d to Py" M33= eigenpy.naturals33(verbose) assert np.array_equal(Mcheck,M33) if verbose: print "===> From VectorXd to Py" v = eigenpy.naturalsX(3,verbose) vcheck = np.matrix([range(3),],np.double).T assert np.array_equal(vcheck ,v) if verbose: print "===> From Py to Eigen::MatrixXd" if verbose: print "===> From Py to Eigen::MatrixXd" if verbose: print "===> From Py to Eigen::MatrixXd" Mref = np.reshape(np.matrix(range(64),np.double),[8,8]) if verbose: print "===> Matrix 8x8" M = Mref assert( np.array_equal(M,eigenpy.reflex(M,verbose)) ); if verbose: print "===> Block 0:3x0:3" M = Mref[0:3,0:3] assert( np.array_equal(M,eigenpy.reflex(M,verbose)) );