A pure-Python matrix module with support for a range of linear algebra operations.

Sample syntax:

from pymatrix import matrix

m = matrix([
    [1, 2],
    [3, 4]

a = m + m * 2
b = m * m
c = m ** 3

d = m.det()
e = m.inv()

See the guide for a full list of available matrix methods.


Install directly from the Python package index using pip:

$ pip install pymatrix

Pymatrix requires Python >= 3.4. The package has no dependencies.

Command Line

Pymatrix doubles as a command line matrix analysis utility. Installing via pip automatically makes pymatrix available on the command line:

Usage: pymatrix [OPTIONS] [FLAGS]

  Matrix analysis utility. Enter a matrix interactively at the terminal or
  pipe to stdin from a file, e.g.

    $ pymatrix < matrix.txt

  Elements are parsed as fractions (rational numbers) by default. An
  alternative parser can be specified using the --parser flag.

  -p, --parser <str>    One of 'int', 'float', 'complex', 'fraction'.

      --help            Print the application's help text and exit.
      --version         Print the application's version number and exit.


This work has been placed in the public domain.