def test_vspht_vispht_one_added_args(self): """::Test vspht when only nmax is passed. """ c = sp.random_coefs(100, 100, coef_type=sp.vector) p = sp.vispht(c) c2 = sp.vspht(p, 5) res = True if (sp.L2_coef(c[0:5, :] - c2) / sp.L2_coef(c[0:5, :])) > 1e-13: res = False self.assertTrue(res)
def test_vspht_vispht_no_added_args(self): """::Test spht and ispht when nmax, mmax, nrows, ncols are not passed. """ c = sp.random_coefs(100, 100, coef_type=sp.vector) p = sp.vispht(c) c2 = sp.vspht(p) res = True if (sp.L2_coef(c - c2) / sp.L2_coef(c)) > 1e-13: res = False self.assertTrue(res)
def test_vspht_with_large_random(self): """::Generate 100 random modes and test both vspht and vispht. """ c = sp.random_coefs(100, 100, coef_type=sp.vector) p = sp.vispht(c, 202, 202) c2 = sp.vspht(p, 100, 100) res = True if (sp.L2_coef(c - c2) / sp.L2_coef(c)) > 1e-13: res = False self.assertTrue(res)
def verify_vspht(pattf1, pattf2, scoeff1, scoeff2): vfpatt = fl.load_vpatt(pattf1, pattf2) fsc1 = fl.load_coef(scoeff1) fsc2 = fl.load_coef(scoeff2) vfsc = sp.VectorCoefs(fsc1._vec, fsc2._vec, fsc1.nmax, fsc1.mmax) vsc = sp.vspht(vfpatt, fsc1.nmax, fsc1.mmax) diff = vfsc - vsc return (sp.L2_coef(diff), sp.LInf_coef(diff), sp.L2_coef(diff) / sp.L2_coef(vfsc), sp.LInf_coef(diff) / sp.LInf_coef(vfsc))
def test_vec_with_individual_coefficients_set(self): """::Testing vspht and vispht with single coefficients, first 5 modes. """ res = True for n in xrange(1, 6): for m in xrange(-n, n + 1): rnd1 = np.random.normal(0, 10) rnd2 = np.random.normal(0, 10) vc = sp.zeros_coefs(15, 15, coef_type=sp.vector) vc[n, m] = (rnd1, rnd2) p = sp.vispht(vc, 50, 50) vc2 = sp.vspht(p, 15, 15) s = sp.L2_coef(vc - vc2) / sp.L2_coef(vc) if s > 1e-10: res = False self.assertTrue(res)
print("") for nm in XX: vc = sp.random_coefs(nm, nm, coef_type = sp.vector) start_time = time.time() p = sp.vispht(vc, Nrows, Nrows) elapsed = time.time() - start_time evt.append(elapsed) print("***Mode Number***: " + str(nm)) print("") print(" Forward Elapsed: " + str(elapsed)) start_time = time.time() c = sp.vspht(p, nm, nm) elapsed = time.time() - start_time evit.append(elapsed) print(" Backward Elapsed: " + str(elapsed)) print("") l1, = plt.plot(np.array(XX), np.array(est),label='spht') l2, = plt.plot(np.array(XX), np.array(eist),label='ispht') l3, = plt.plot(np.array(XX), np.array(evt),label='vspht') l4, = plt.plot(np.array(XX), np.array(evit),label='vispht') plt.legend(handles=[l1, l2, l3, l4],loc=2) plt.xlabel('Nmax') plt.ylabel('E-Time [sec]') plt.show()