def _matrix_transpose(self): """Get the transpose of a matrix. Returns: Get the transpose of a matrix. """ return matrix.Matrix([[self[i, j] for i in range(self.n)] for j in range(self.m)])
def _matrix_transpose(mat): """Permute the first two axes of the matrix. Args: mat (:class:`~taichi.lang.matrix.Matrix`): Input matrix. Returns: Transpose of the input matrix. """ return matrix.Matrix([[mat[i, j] for i in range(mat.n)] for j in range(mat.m)])
def _matrix_outer_product(self, other): """Perform the outer product with the input Vector (1-D Matrix). Args: other (:class:`~taichi.lang.matrix.Matrix`): The input Vector (1-D Matrix) to perform the outer product. Returns: :class:`~taichi.lang.matrix.Matrix`: The outer product result (Matrix) of the two Vectors. """ impl.static( impl.static_assert(self.m == 1, "lhs for outer_product is not a vector")) impl.static( impl.static_assert(other.m == 1, "rhs for outer_product is not a vector")) return matrix.Matrix([[self[i] * other[j] for j in range(other.n)] for i in range(self.n)])
def _matrix_cross3d(self, other): return matrix.Matrix([ self[1] * other[2] - self[2] * other[1], self[2] * other[0] - self[0] * other[2], self[0] * other[1] - self[1] * other[0], ])