Exemplo n.º 1
0
void CRationalApproximation::compute_shifts_weights_const()
{
	float64_t PI=M_PI;
	
	// eigenvalues are always real in this case
	float64_t max_eig=m_eigen_solver->get_max_eigenvalue();
	float64_t min_eig=m_eigen_solver->get_min_eigenvalue();

	// we need $(\frac{\lambda_{M}}{\lambda_{m}})^{frac{1}{4}}$ and
	// $(\lambda_{M}*\lambda_{m})^{frac{1}{4}}$ for the rest of the
	// calculation where $lambda_{M}$ and $\lambda_{m} are the maximum
	// and minimum eigenvalue respectively
	float64_t m_div=CMath::pow(max_eig/min_eig, 0.25);
	float64_t m_mult=CMath::pow(max_eig*min_eig, 0.25);
	
	// k=$\frac{(\frac{\lambda_{M}}{\lambda_{m}})^\frac{1}{4}-1}
	// {(\frac{\lambda_{M}}{\lambda_{m}})^\frac{1}{4}+1}$
	float64_t k=(m_div-1)/(m_div+1);
	float64_t L=-CMath::log(k)/PI;
	
	// compute K and K'
	float64_t K=0.0, Kp=0.0;
	CJacobiEllipticFunctions::ellipKKp(L, K, Kp);
	
	// compute constant multiplier
	m_constant_multiplier=-8*K*m_mult/(k*PI*m_num_shifts);
	
	// compute Jacobi elliptic functions sn, cn, dn and compute shifts, weights
	// using conformal mapping of the quadrature rule for discretization of the
	// contour integral
	float64_t m=CMath::sq(k);

	for (index_t i=0; i<m_num_shifts; ++i)
	{
		complex64_t t=complex64_t(0.0, 0.5*Kp)-K+(0.5+i)*2*K/m_num_shifts;

		complex64_t sn, cn, dn;
		CJacobiEllipticFunctions::ellipJC(t, m, sn, cn, dn);

		complex64_t w=m_mult*(1.0+k*sn)/(1.0-k*sn);
		complex64_t dzdt=cn*dn/CMath::sq(1.0/k-sn);

		// compute shifts and weights as per Hale et. al. (2008) [2]
		m_shifts[i]=CMath::sq(w);

		switch (m_function_type)
		{
		case OF_SQRT:
			m_weights[i]=dzdt;
			break;
		case OF_LOG:
			m_weights[i]=2.0*CMath::log(w)*dzdt/w;
			break;
		case OF_POLY:
			SG_NOTIMPLEMENTED
			m_weights[i]=complex64_t(0.0);
			break;
		case OF_UNDEFINED:
			SG_WARNING("Operator function is undefined!\n")
			m_weights[i]=complex64_t(0.0);
			break;
		}
	}
}
Exemplo n.º 2
0
void SGVector<complex64_t>::zero()
{
	if (vector && vlen)
		set_const(complex64_t(0.0));
}