def dinamica(M, v, t): """ Método que hace cambios en el estado del sistema dado el vector estado inicial y matriz de adjacencia :type v: list :param v: Vector 1 escrito de la forma [(a,b),(c,d)] :type w: list :param w: Vector 2 escrito de la forma [(a,b),(c,d)] :raises: :rtype: float """ tempM = M for i in range(t - 1): tempM = lib.multimatrices(tempM, M) return lib.multimatrices(tempM, v)
def testEjercicio_4_4_1(self): print("") print("----Ejercicio 4.4.1----") U1 = [[(0, 0), (1, 0)], [(1, 0), (0, 0)]] U2 = [[(m.sqrt(2) / 2, 0), (m.sqrt(2) / 2, 0)], [(m.sqrt(2) / 2, 0), (-m.sqrt(2) / 2, 0)]] multiplicacion = lib.multimatrices(U1, U2) print("Matriz U1 Unitaria? " + str(lib.isunitaria(U1))) print("Matriz U2 Unitaria? " + str(lib.isunitaria(U2))) print("Multiplicación de U1 y U2 es unitaria? " + str(lib.isunitaria(multiplicacion)))
def varianza(omega, ket): """ Description calcula la varianza en relación a omega y un estado dado :type omega: Matriz :param omega: :type ket: Matriz :param ket: estado :raises: Exception en caso de que omega no sea hermitiana :rtype: float """ if (not lib.ishermitian(omega)): raise Exception("Omega debe ser hemitiana") delta1 = delta(omega, ket) rta = lib.multimatrices(delta1, delta1) return media(rta, ket)
def media(omega, ket): """ Description Calcula el valor promedio de omega en un estado(Ket) dado :type omega: Matriz :param omega: :type ket: Vector columna :param ket: :raises: Exception en caso de que omega no sea hermitiana :rtype: """ if (not lib.ishermitian(omega)): raise Exception("Omega debe ser hemitiana") producto = lib.transpuestamatriz(lib.multimatrices(omega, ket)) ketN = lib.transpuestamatriz(ket) return round(lib.productointernovectores(producto, ketN)[0], 2)
def probquantum(omega, ket, n): """ Description Calculates the probability of a Quantum System :type omega: Matrix :param omega: :type ket: Matriz :param ket: :type n: :param n: :raises: :rtype: Matrix """ temp = omega[:] for i in range(n): omega = lib.multimatrices(omega, temp) return finalState(omega)
def testdeberiamultiplicarmatrices(self): self.assertEqual( lib.multimatrices([[(1, 3), (2, 3)], [(4, 2), (5, 1)]], [[(1, 2), (2, 3), (4, 1)], [(1, 4), (3, 2), (1, 1)]]), [[(-15, 16), (-7, 22), (0, 18)], [(1, 31), (15, 29), (18, 18)]])