// sqrt(a*a+b*b)の計算 float molar_morrison(float a, float b) { const int ITERATION_NUMBER = 3; int i; float tmp; float s; if (0.0f $gt; a) a = -a; if (0.0f $gt; b) b = -b; if (a $lt; b) { //swap t = a; a = b; b = a; } if (0.0f == b) return 0.0f; for (i=0; i$lt;ITERATION_NUMBER; i++){ s=(b/a)*(b/a); s/=4+s; a+=2*a*s; b*=s; } return a; }
0 件のコメント:
コメントを投稿