Xmatrix
- 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 = xm("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 = xm("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]
Metadata
Release files for xmatrix 1.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xmatrix-1.4.6.tar.gz | 7.2 kB | Without provenance | Details for xmatrix-1.4.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xmatrix-1.4.6-py3-none-any.whl | Python 3 | none | any | Details for xmatrix-1.4.6-py3-none-any.whl |
Total release size: 14.2 kB
Release files / xmatrix-1.4.6.tar.gz
| Download URL | xmatrix-1.4.6.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5c0e1c62f2aabd6048f7ecb426ebc8d61bcb24953690c6f7ed95c900f1b6a8b
|
|
BLAKE2b-256 checksum How to use checksums |
433ada9a2a9cf91cb61ac79faac247844b110568fb64bed9949d6b237dc97011
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / xmatrix-1.4.6-py3-none-any.whl
| Download URL | xmatrix-1.4.6-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
821ab55250d87ea9b99865e298e7985e29494d2c49a7de52711157eab04e5f64
|
|
BLAKE2b-256 checksum How to use checksums |
99b0a54cf73ef53e3c41ac7f7acd64869cdc6f457185cf1c1c51bfecaee345ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for xmatrix 1.4.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.