コード例 #1
0
ファイル: analytic_soln.hpp プロジェクト: Kyushick/sight
inline Scalar soln(Scalar x, Scalar y, Scalar z, int max_p, int max_q)
{
  Scalar sum = 0;
  for(int p=0; p<=max_p; ++p) {
    const Scalar p21y = fcn(p, y);
    const Scalar sin_py = std::sin(p21y)/(2*p+1);
    for(int q=0; q<=max_q; ++q) {
      const Scalar q21z = fcn(q, z);
      const Scalar sin_qz = std::sin(q21z)/(2*q+1);

      const Scalar l = fcn_l(p, q);

      const Scalar sinh1 = std::sinh(l*x);
      const Scalar sinh2 = std::sinh(l);

      const Scalar tmp = (sinh1*sin_py)*(sin_qz/sinh2);

      //if the scalar l gets too big, sinh(l) becomes inf.
      //if that happens, tmp is a NaN.
      //crude check for NaN:
      //if tmp != tmp, tmp is NaN
      if (tmp == tmp) {
        sum += tmp;
      }
      else {
        //if we got a NaN, break out of this inner loop and go to
        //the next iteration of the outer loop.
        break;
      }
    }
  }
  return term0*sum;
}
コード例 #2
0
ファイル: if_chain.c プロジェクト: 7vikram7/uncrustify
void foo(void)
{
   if (cond_a) {
       fcn_a();
       fcn_b();
   } else {
       fcn_c();
   }

   if (cond_b) {
       fcn_d();
   } else {
       fcn_e();
   }

   if (cond_c) {
       fcn_f();
       fcn_g();
   } else
       fcn_h();

   if (cond_d)
       fcn_i();
   else {
       fcn_j();
       fcn_k();
   }

   if (cond_e)
       fcn_l();
   else
       fcn_m();

   	if (cond_f)
		fcn_n();
	else if (cond_g) {
                fcn_o();
		while (cond_g) {
			fcn_p();
		}
	} else if (cond_h)
		while (cond_i) {
			fcn_q();
			fcn_r();
		}
	else
		fcn_s();
}