コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
def escalarMultMatrix(escalar, a):
    return [[comp.producto(escalar, a[i][j]) for j in range(len(a[0]))]
            for i in range(len(a))]
コード例 #7
0
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
コード例 #8
0
def escalarMultVect(escalar, a):
    ans = []
    for i in range(len(a)):
        ans = ans + [comp.producto(escalar, a[i])]
    return ans
コード例 #9
0
def inverVect(a):
    ans = []
    for i in range(len(a)):
        escalar = (-1, 0)
        ans = ans + [comp.producto(escalar, a[i])]
    return ans