Skip to content

Commit

Permalink
Cleanup of debug code.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydumont committed Jul 21, 2014
1 parent a8cc337 commit 33a480a
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/wignerSymbols-cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ std::vector<double> wigner3j(double l2, double l3,
double m1, double m2, double m3)
{
// We compute the numeric limits of double precision.
double huge = sqrt(std::numeric_limits<double>::max()/20.0);
double huge = sqrt(std::numeric_limits<double>::max()/40.0);
double srhuge = sqrt(huge);
double tiny = std::numeric_limits<double>::min();
double srtiny = sqrt(tiny);
Expand Down Expand Up @@ -188,16 +188,16 @@ std::vector<double> wigner3j(double l2, double l3,
{
sum += (2.0*(l1min+k)+1.0)*thrcof[k]*thrcof[k];
}
std::cout << sum << std::endl;
//std::cout << sum << std::endl;

std::cout << "(-1)^(l2-l3-m1): " << pow(-1.0,l2-l3-m1) << " sgn:" << sgn(thrcof[size-1]) << std::endl;
//std::cout << "(-1)^(l2-l3-m1): " << pow(-1.0,l2-l3-m1) << " sgn:" << sgn(thrcof[size-1]) << std::endl;
double c1 = pow(-1.0,l2-l3-m1)*sgn(thrcof[size-1]);
std::cout << "c1: " << c1 << std::endl;
//std::cout << "c1: " << c1 << std::endl;
for (std::vector<double>::iterator it = thrcof.begin(); it != thrcof.end(); ++it)
{
std::cout << *it << ", " << c1 << ", ";
//std::cout << *it << ", " << c1 << ", ";
*it *= c1/sqrt(sum);
std::cout << *it << std::endl;
//std::cout << *it << std::endl;
}
return thrcof;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/gh-issue-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ int main (int argc, char* argv[])
std::cout << "FOR impl.: " << test42 << std::endl;
std::cout << std::endl;

std::vector<double> test5 = WignerSymbols::wigner3j(856, 1200, 464, -828, 364);
double test51 WignerSymbols::wigner3j(751, 856, 1200, 464, -828, 364);
double test52 WignerSymbols::wigner3j_f(751, 856, 1200, 464, -828, 364);

/*
[ 841 379 1011 -631 313 318] -2.44096504011e-41 -0.0
[ 570 1007 1392 327 -933 606] -1.74376347733e-98 0.0
[ 970 727 1202 533 -663 130] -6.93009562166e-12 0.0
[ 905 919 1670 869 -594 -275] -3.48516309858e-195 -0.0
[ 895 574 1392 793 -365 -428] -1.41868655509e-146 -0.0
*/
return 0;
}

87 changes: 87 additions & 0 deletions tests/gh-issue-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*******************************************************-/
* This source code is subject to the terms of the GNU -/
* Lesser Public License. If a copy of the LGPL was not -/
* distributed with this file, you can obtain one at -/
* https://www.gnu.org/licenses/lgpl.html -/
********************************************************/

/*! \file gh-issue-1.cpp
* \author Joey Dumont <[email protected]>
* \since 2014-07-11
* \brief Tests Issue 2 of WignerSymbols (see valandil.github.com/wignerSymbols.
* \copyright LGPL
* This file tests the bug described in Issue #2 of WignerSymbols (GitHub).
* It seems that for some values of l1, the algorithm returns a set
* of zeros even though it should return proper coefficients.
*
*/

#include <wignerSymbols.h>

int main (int argc, char* argv[])
{
double test11 = WignerSymbols::wigner3j(325, 999, 1221, 280, 899, -1179);
double test12 = WignerSymbols::wigner3j(999, 1221, 325, 899, -1179, 280);
double test13 = WignerSymbols::wigner3j(1221, 325, 999, -1179, 280, 899);
double test14 = WignerSymbols::wigner3j_f(325, 999, 1221, 280, 899, -1179);
double test15 = WignerSymbols::wigner3j_f(999, 1221, 325, 899, -1179, 280);
double test16 = WignerSymbols::wigner3j_f(1221, 325, 999, -1179, 280, 899);

double test21 = WignerSymbols::wigner3j(693, 896, 1371, 513, -838, 325);
double test22 = WignerSymbols::wigner3j(896, 1371, 693, -838, 325, 513);
double test23 = WignerSymbols::wigner3j(1371, 693, 896, 325, 513, -838);
double test24 = WignerSymbols::wigner3j_f(693, 896, 1371, 513, -838, 325);
double test25 = WignerSymbols::wigner3j_f(896, 1371, 693, -838, 325, 513);
double test26 = WignerSymbols::wigner3j_f(1371, 693, 896, 325, 513, -838);

double test31 = WignerSymbols::wigner3j(772, 874, 1231, 442, 756, -1198);
double test32 = WignerSymbols::wigner3j(874, 1231, 772, 756, -1198, 442);
double test33 = WignerSymbols::wigner3j(1231, 772, 874, -1198, 442, 756);
double test34 = WignerSymbols::wigner3j_f(772, 874, 1231, 442, 756, -1198);
double test35 = WignerSymbols::wigner3j_f(874, 1231, 772, 756, -1198, 442);
double test36 = WignerSymbols::wigner3j_f(1231, 772, 874, -1198, 442, 756);

std::cout << test11 << std::endl;
std::cout << WignerSymbols::wigner3j(693, 896, 1371, 513, -838, 325) << std::endl;
std::cout << WignerSymbols::wigner3j(772, 874, 1231, 442, 756, -1198) << std::endl;
std::cout << WignerSymbols::wigner3j(842, 996, 1714, 376, 979, -1355) << std::endl;
std::cout << WignerSymbols::wigner3j(101, 987, 1084, -80, -935, 1015) << std::endl;
std::cout << WignerSymbols::wigner3j( 51, 1003, 978, -32, 993, -961) << std::endl;
std::cout << WignerSymbols::wigner3j(217, 1008, 1107, -76, -987, 1063)<< std::endl;
std::cout << WignerSymbols::wigner3j(408, 894, 954, -114, -840, 954) << std::endl;
std::cout << WignerSymbols::wigner3j(808, 980, 1734, 341, 954, -1295) << std::endl;
std::cout << WignerSymbols::wigner3j(827, 1020, 1570, 590, 902, -1492)<< std::endl;

std::cout << "C++ impl.: " << test11 << ", " << test12 << ", " << test13 << std::endl;
std::cout << "FOR impl.: " << test14 << ", " << test15 << ", " << test16 << std::endl;
std::cout << "C++ impl.: " << test21 << ", " << test22 << ", " << test23 << std::endl;
std::cout << "FOR impl.: " << test24 << ", " << test25 << ", " << test26 << std::endl;
std::cout << "C++ impl.: " << test31 << ", " << test32 << ", " << test33 << std::endl;
std::cout << "FOR impl.: " << test34 << ", " << test35 << ", " << test36 << std::endl;

std::vector<double> test4 = WignerSymbols::wigner3j(992, 1243, 196, -901, 705);
double test41 = WignerSymbols::wigner3j(529, 992, 1243, 196, -901, 705);
double test42 = WignerSymbols::wigner3j_f(529, 992, 1243, 196, -901, 705);
std::cout << "C++ impl.: " << test41 << std::endl;
std::cout << "FOR impl.: " << test42 << std::endl;
std::cout << std::endl;

std::cout << std::endl << "test5:" << std::endl;
std::vector<double> test5 = WignerSymbols::wigner3j(727, 1202, 533, -663, 130);
double test51 = WignerSymbols::wigner3j(970, 727, 1202, 533, -663, 130);
double test52 = WignerSymbols::wigner3j_f(970, 727, 1202, 533, -663, 130);
std::cout << "C++ impl.: " << test51 << std::endl;
std::cout << "FOR impl.: " << test52 << std::endl;
std::cout << std::endl;

/*