This is a README for libcomplex.py
and libmatcplx.py
, a complex libraries functions for python.
Download the folder "cnyt" from this repository with
git clone https://github.com/christiantorres29/cnyt.git
You will get a folrder with libcomplex.py
& libmatcplx.py
, just copy-paste the file to your working directory and import it with
from libcomplex import *
from libmatcplx import *
For libcomplex.py
, a complex number a+bj is denoted as a tuple (a,b).
This complex library contents the following functions
- cplxsum()
- cplxsus()
- cplxprod()
- cplxdiv()
- module()
- phase()
- conj()
- rec2pol()
- pol2rec()
- pcarprint()
- ppolprint()
For libmatcplx.py
arrays are defined like [a, b, c...] and matrices as array of arrays, like this [[a, b, c], [d, e, f], ...]. In both cases a, b, c, d ... elements are complex numbers in form a+bj .
The library contents the following functions
Vector functions
Matrix functions
All these functions receive two parameters, two complex numbers as tuples, and returns one tuple. Resolves correspondingly to addition, sustraction, multiplication and divition of 2 complex numbers.
cplxsum((a,b),(c,d))
cplxsus((a,b),(c,d))
cplxprod((a,b),(c,d))
cplxdiv((a,b),(c,d))
Magnitude module()
of a complex number.
Phase phase()
in radians of a complex number, this function takes values from cero to 2 π (6.283185307179586).
Conjugate conj()
of a complex number
whole functions returns a float.
module((a,b))
phase((a,b))
conj((a,b))
Convert a tuple in cartesian coordinates to polar coordinates or visceversa.
rec2pol((a,b))
pol2rec((a,b))
Pretty cartesian print and pretty polar print.
The pcarprint()
print in a+bj format.
The ppolprint()
print in r∠θ format, where θ are expressed in terms of π
pcarprint((a,b))
ppolprint((a,b))
Whole vector functions receive one, or two vectors, but the functions cannot recognize between column or row vectors.
Legend: u and v are arrays, and c is a scalar
vsum(u,v) ## add of v and u
vinv(u) ## aditive inverse of u
vscp(c,u) ## scalar product of c and v
vtrans(v) ## transpose(do nothing)
vconj(u) ## conjugate of u
vdagger(u) ## adjoint of u
vinnp(u,v) ## inner product between u and v
vnorm(u) ## norm of u
vdist(u,v) ## distance between u and v
vtproduct(u,v) ## tensor product between u and v
Whole matrix functions receive one, or two arrays.
Legend: u and v are matrices, and c is a scalar
msum(u,v) ## add of v and u
minv(u) ## aditive inverse of u
mscp(c,u) ## scalar product of c and v
mtrans(v) ## transpose of v
mconj(u) ## conjugate of u
mdagger(u) ## adjoint of u
mprod(u,v) ## matricial product between u and v
actmov(u,v) ## action of u on vector v
unitm(u) ## determines if u is an unitary matrix (1 yes, 0 not)
hertm(u,v) ## determines if u is an hermitian matrix (1 yes, 0 not)
mtprod(u,v) ## tensor product between u and v
- Christian Torres - nothing to say - christiantorres29
This project is not licensed, trust me I'm a dolphin, not a virus