""" This code is supported by the website: https://www.guanjihuan.com The newest version of this code is on the web page: https://www.guanjihuan.com/archives/22604 """ import numpy as np import math import cmath # from numba import jit # @jit def rotation_of_degenerate_vectors(vector1, vector2, index1=None, index2=None, precision=0.01, criterion=0.01, show_theta=0): vector1 = np.array(vector1) vector2 = np.array(vector2) if index1 == None: index1 = np.argmax(np.abs(vector1)) if index2 == None: index2 = np.argmax(np.abs(vector2)) if np.abs(vector1[index2])>criterion or np.abs(vector2[index1])>criterion: for theta in np.arange(0, 2*math.pi, precision): if show_theta==1: print(theta) for phi1 in np.arange(0, 2*math.pi, precision): for phi2 in np.arange(0, 2*math.pi, precision): vector1_test = cmath.exp(1j*phi1)*vector1*math.cos(theta)+cmath.exp(1j*phi2)*vector2*math.sin(theta) vector2_test = -cmath.exp(-1j*phi2)*vector1*math.sin(theta)+cmath.exp(-1j*phi1)*vector2*math.cos(theta) if np.abs(vector1_test[index2])