Pymatrix

Pymatrix is a lightweight matrix library built in Python.

Home


Pymatrix is a lightweight matrix library built in Python. It supports a range of basic linear algebra operations.

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 list of available matrix methods.

Installation

Install directly from the Python package index using pip:

$ pip install pymatrix

Pymatrix requires Python 3.4 or later. The package has no dependencies.

Command Line

Pymatrix doubles as a simple 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.

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

Flags:
      --help            Print the application's help text.
      --version         Print the application's version.

License

This work has been placed in the public domain.