def make_matching_dict_hash(diff_func_4wv_1,diff_func_4wv_2, phi1_range,phi2_range,nu3_range,eps=2e-4): ''' Make a dictionary mapping points close to solutions of a phase-matching condition to error values using hash tables. Args: phi1_range (numpy array): list of phi1 values phi2_range (numpy array): list of phi2 values nu3_range (numpy array): list of nu3 values eps (optional[float]): error allowed for phase-matching condition Returns: Dictionary (dict): dict mapping points to error values. ''' phi2_indices = range(len(phi2_range)) nu3_indices = range(len(nu3_range)) matching_dict = {} for phi1_index,phi1 in enumerate(phi1_range): y1 = diff_func_4wv_1(phi1,phi2_range) y2 = diff_func_4wv_2(phi1,nu3_range) y1_rounded = eps_multiply_digitize(y1,eps) y1_rounded_up = [ind + 1 for ind in y1_rounded] y2_rounded = eps_multiply_digitize(y2,eps) y2_rounded_up = [ind + 1 for ind in y2_rounded] D1 = make_dict_values_to_lists_of_inputs( y1_rounded+y1_rounded_up,2*phi2_indices) D2 = make_dict_values_to_lists_of_inputs( y2_rounded+y2_rounded_up,2*nu3_indices) inter = set(D1.keys()) & set(D2.keys()) for el in inter: for ind1 in D1[el]: for ind2 in D2[el]: err = y1[ind1]-y2[ind2] if abs(err) < eps: matching_dict[phi1_index,ind1,ind2] = err return matching_dict