add numerical recipes library
This commit is contained in:
13
lib/nr/cpp/recipes/pythag.cpp
Normal file
13
lib/nr/cpp/recipes/pythag.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <cmath>
|
||||
#include "nr.h"
|
||||
using namespace std;
|
||||
|
||||
DP NR::pythag(const DP a, const DP b)
|
||||
{
|
||||
DP absa,absb;
|
||||
|
||||
absa=fabs(a);
|
||||
absb=fabs(b);
|
||||
if (absa > absb) return absa*sqrt(1.0+SQR(absb/absa));
|
||||
else return (absb == 0.0 ? 0.0 : absb*sqrt(1.0+SQR(absa/absb)));
|
||||
}
|
||||
Reference in New Issue
Block a user