Skip to main content

Help you calculate matrix.

Project description

Xmatrix

xmatrixy Logo

CodeFactor Python PyPi

  • A python package to calculate Matrix math problems.
  • python version: 3.6 and above.

Usage

install

pip3 install xmatrix --upgrade

Add import in your file

from xmatrix import *

create a matrix

  • Matrix("row ; row ...") or Matrix([[1,2,3],[4,5,6],[7,8,9]])
  • xm("row ; row ...") or xm([[1,2,3],[4,5,6],[7,8,9]])
my_matrix = Matrix("1,2;3,4")
my_matrix_also_equal_to = xm("1,2;3,4")

#result:
[1, 2]
[3, 4]

we also support bigger matrix

my_matrix = xm("1,2,3;4,5,6;7,8,9")

#result:
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]

simple calculate

my_matrix = xm("1,2;3,4")
my_matrix2 = xm("4,6;2,9")

print(my_matrix + my_matrix2)
#result:
[5, 8]
[5, 13]

print(my_matrix - my_matrix2)
#result:
[-3, -4]
[1, -5]

print(my_matrix * my_matrix2)
#result:
[8, 24]
[20, 54]

print(my_matrix * 87)
#result:
[87, 174]
[261, 348]

print(my_matrix ** 7)
#result:
[30853, 44966]
[67449, 98302]

print(my_matrix == my_matrix2)
#result:
False

Transpose Matrix

my_matrix = xm("1,2,3;4,5,6;7,8,9")

print(my_matrix)
#result:
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]

print(my_matrix.transpose)
print(my_matrix.tp)
#result:
[1, 4, 7]
[2, 5, 8]
[3, 6, 9]

my_matrix2 = xm("1,2,3,4;5,6,7,8;9,10,11,12;13.1,14.2,15.3,16.4")

print(my_matrix2)
#result:
[1, 2, 3, 4]
[5, 6, 7, 8]
[9, 10, 11, 12]
[13.1, 14.2, 15.3, 16.4]

print(my_matrix2.tp)
#result:
[1, 5, 9, 13.1]
[2, 6, 10, 14.2]
[3, 7, 11, 15.3]
[4, 8, 12, 16.4]

Inverse

my_matrix = xm("1,2;3,4")

print(my_matrix)
#result:
[1, 2]
[3, 4]

print(my_matrix.inverse)
print(my_matrix.iv)
#result:
[-2, 1]
[1.5, -0.5]

#special use by '**' power operator:
print(my_matrix ** -1)
#result:
[-2, 1]
[1.5, -0.5]

my_matrix2 = xm("1,2,3;4,5,6;7,8,9")

print(my_matrix2)
#result:
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]

print(my_matrix2.iv)
#result:
#The determinant is zero, can't be inverse.
#None

my_matrix3 = mv("1,1,1;1,2,3;1,4,5")

print(my_matrix3)
#result:
[1, 1, 1]
[1, 2, 3]
[1, 4, 5]

print(my_matrix3.inverse)
#result:
[1, 0.5, -0.5]
[1, -2, 1]
[-1, 1.5, -0.5]

my_matrix4 = mv("1,1,2,1;1,1,0,0;1,1,0,1;1,0,1,0")

print(my_matrix4)
#result:
[1, 1, 2, 1]
[1, 1, 0, 0]
[1, 1, 0, 1]
[1, 0, 1, 0]

print(my_matrix4.iv)
#result:
[-0.5, 0, 0.5, 1]
[0.5, 1, -0.5, -1]
[0.5, 0, -0.5, 0]
[0, -1, 1, 0]

#and more...

get the matrix by list

my_matrix = xm("1,2,3;4,5,6;7,8,9")

print(my_matrix.raw)
#result:
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]

get identity Matrix

i = IdentityMatrix(3)
i_also_equal_to = ixm(3)

#result:
print(i)
[1, 0, 0]
[0, 1, 0]
[0, 0, 1]

Gaussian elimination Row Reduced Echelon Form

my_matrix=xm('1,-3,2,8;-1,4,-2,-9;-3,9,4,6')

#result
print(my_matrix)
[1, -3, 2, 8]
[-1, 4, -2, -9]
[-3, 9, 4, 6]

# Row Reduced Echelon Form (rref)
print(my_matrix.rref)
[1, 0, 0, -1]
[0, 1, 0, -1]
[0, 0, 1, 3]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xmatrix-1.4.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

xmatrix-1.4.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file xmatrix-1.4.1.tar.gz.

File metadata

  • Download URL: xmatrix-1.4.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for xmatrix-1.4.1.tar.gz
Algorithm Hash digest
SHA256 8239d1c9fbedef2f10d8966303b13aa04c6e72a220ee3bd550a9a7e6b404f6b4
MD5 1b33483dd51e92080ea280e86b344a9e
BLAKE2b-256 36cd77d0581a5b73714c7fa1532a710af8261d5345b44b4e3c68b79843f1bb71

See more details on using hashes here.

File details

Details for the file xmatrix-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: xmatrix-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for xmatrix-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 999317ae294efd1252606c1363ad97b53b44a54d2bdd7038c48441a0c449fecf
MD5 87a4ffb174a0d7276dfbc89b16a64cc9
BLAKE2b-256 ed550532c23cef7545efa348d22c3867704f6c18e8355e3935bcba2950d67208

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page