def babai_round(self, lattice, target): self.log("Start Babai's Rounding.") b = np.empty((lattice.nrows, lattice.ncols), "f8") lattice.to_matrix(b) b = matrix_inverse(b) res = np.dot(target, b) return self.vector_from_coeffs(res, lattice)
def cell_angles_and_rotation(axes): ca = cell_angles(axes) ska = skew_axes(ca) na = [normalize_vector(v) for v in axes] from numpy.linalg import inv as matrix_inverse from numpy import dot as matrix_multiply r = matrix_multiply(matrix_inverse(ska), na).transpose() return ca, r
def _invertMatrix(tf): tf = np.array(tf) r = tf[:, :3] t = tf[:, 3] tfinv = np.zeros((3, 4), np.float) rinv = tfinv[:, :3] tinv = tfinv[:, 3] rinv[:, :] = matrix_inverse(r) tinv[:] = matrix_multiply(rinv, -t) return tfinv
def invert_matrix(tf): from numpy import array, zeros, float tf = array(tf) r = tf[:, :3] t = tf[:, 3] tfinv = zeros((3, 4), float) rinv = tfinv[:, :3] tinv = tfinv[:, 3] from numpy.linalg import inv as matrix_inverse from numpy import dot as matrix_multiply rinv[:, :] = matrix_inverse(r) tinv[:] = matrix_multiply(rinv, -t) return tfinv
def invert_matrix(tf): from numpy import array, zeros, float tf = array(tf) r = tf[:,:3] t = tf[:,3] tfinv = zeros((3,4), float) rinv = tfinv[:,:3] tinv = tfinv[:,3] from numpy.linalg import inv as matrix_inverse from numpy import dot as matrix_multiply rinv[:,:] = matrix_inverse(r) tinv[:] = matrix_multiply(rinv, -t) return tfinv