Skip to main content

Help you calculate matrix.

Project description

Xmatrix

xmatrixy Logo

CodeFactor

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

Usage

install

pip install xmatrix

Add import in your file

import xmatrix as Mx
from xmatrix import * # This would be better.

create a matrix

  • Matrix("row ; row ...")
my_matrix = Mx.Matrix("1,2;3,4")

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

we also support bigger matrix

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

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

simple calculate

my_matrix = Mx.Matrix("1,2;3,4")
my_matrix2 = Mx.Matrix("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 = Mx.Matrix("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)
#result:
[1, 4, 7]
[2, 5, 8]
[3, 6, 9]

my_matrix2 = Matrix("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.transpose)
#result:
[1, 5, 9, 13.1]
[2, 6, 10, 14.2]
[3, 7, 11, 15.3]
[4, 8, 12, 16.4]

Inverse

my_matrix = Mx.Matrix("1,2;3,4")

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

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

my_matrix2 = Mx.Matrix("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.inverse)
#result:
#The determinant is zero, can't be inverse.
#None

my_matrix3 = Mx.Matrix("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 = Mx.Matrix("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.inverse)
#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 = Mx.Matrix("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 = Mx.UnitMatrix(3)

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

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.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

xmatrix-1.1.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xmatrix-1.1.2.tar.gz
  • Upload date:
  • Size: 5.0 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.43.0 CPython/3.8.2

File hashes

Hashes for xmatrix-1.1.2.tar.gz
Algorithm Hash digest
SHA256 89913ca75e3acf3463e291b3983324f036102e03aeac3d31cad355aaad7aee46
MD5 d62074769aeeebb23f175790b1ba340b
BLAKE2b-256 ce692516769d07a3243a515fbbc3db8f23b4f9ec2aaf1874c68fcd5866a15a4b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xmatrix-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 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.43.0 CPython/3.8.2

File hashes

Hashes for xmatrix-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab64f65a1c9d8bf6e02be7cbe29436be312704e5883401a658672894ce3f33f3
MD5 368c855bebd1fd29e071a02ba41f719b
BLAKE2b-256 a30e822f2dab5d19efd10b5f0a95167a32924a3256694d61b436aabafab5bed3

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