def amplitudTransicionKet(ket1, ket2): bra = cM.adjMatrix(ket2) amplitud = cM.productMatrix(bra, ket1)[0][0] norma1 = cM.normaVec(ket1) norma2 = cM.normaVec(ket2) ans = compl.division(amplitud, compl.producto((norma1, 0), (norma2, 0))) return ans
def normalizarVector(vector): vectorNormalizado, v = [], [] norma = cM.normaVec(vector) for i in range(len(vector)): v += [compl.producto((1 / norma, 0), vector[i][0])] vectorNormalizado += [v] return vectorNormalizado
def meanValue(probabilidad, valoresPropios): mean, ans = [], (0, 0) for i in range(len(probabilidad)): mean += [compl.producto(probabilidad[i], valoresPropios[i])] for j in range(len(mean)): ans = compl.suma(mean[i], ans) return ans
def accionMatrixVector(a, v): if verificacionMult(a, v): ans, res = [], (0, 0) for i in range(len(a)): for j in range(len(a[0])): res = comp.suma(comp.producto(a[i][j], v[j]), res) ans = ans + [res] res = (0, 0) else: ans = "Indefinido" return ans
def productMatrix(a, b): if verificacionMult(a, b): ans = [[(0, 0) for j in range(len(a[0]))] for i in range(len(a))] for i in range(len(a)): for j in range(len(b[0])): for k in range(len(b)): ans[i][j] = comp.suma(comp.producto(a[i][k], b[k][j]), ans[i][j]) else: ans = "Indefinido" return ans
def escalarMultMatrix(escalar, a): return [[comp.producto(escalar, a[i][j]) for j in range(len(a[0]))] for i in range(len(a))]
def inverMatrix(a): escalar = (-1, 0) ans = [[comp.producto(escalar, a[i][j]) for j in range(len(a[0]))] for i in range(len(a))] return ans
def escalarMultVect(escalar, a): ans = [] for i in range(len(a)): ans = ans + [comp.producto(escalar, a[i])] return ans
def inverVect(a): ans = [] for i in range(len(a)): escalar = (-1, 0) ans = ans + [comp.producto(escalar, a[i])] return ans