Macaulay2 » Documentation
Packages » Python » PythonObject » PythonObject @ PythonObject
next | previous | forward | backward | up | index | toc

PythonObject @ PythonObject -- matrix multiplication of Python objects

Description

Multiply two Python objects (e.g., NumPy arrays) as matrices.

i1 : installNumPyMethods();
i2 : a = toPython matrix {{1, 0}, {0, 1}}

o2 = [[1 0]
      [0 1]]

o2 : PythonObject of class numpy.ndarray
i3 : b = toPython matrix {{4, 1}, {2, 2}}

o3 = [[4 1]
      [2 2]]

o3 : PythonObject of class numpy.ndarray
i4 : a @ b

o4 = [[4 1]
      [2 2]]

o4 : PythonObject of class numpy.ndarray

In Macaulay2, the * operator is used for matrix multiplication, but in NumPy, this results in componentwise multiplication.

i5 : a * b

o5 = [[4 0]
      [0 2]]

o5 : PythonObject of class numpy.ndarray

See also

Menu

Ways to use this method:


The source of this document is in Python/doc/arithmetic.m2:297:0.