diff --git a/include/wignerSymbols/wignerSymbols-fortran.h b/include/wignerSymbols/wignerSymbols-fortran.h index 4882605..d25ca3f 100644 --- a/include/wignerSymbols/wignerSymbols-fortran.h +++ b/include/wignerSymbols/wignerSymbols-fortran.h @@ -42,6 +42,9 @@ extern "C" extern void drc6j_wrap(double,double,double,double,double,double*,double*,double*,int,int*); } +/*! Compute a string of Wigner-3j symbols for given l2,l3,m1,m2,m3. */ +std::vector wigner3j_f(double l2, double l3, double m1, double m2, double m3); + /*! Computes the Wigner-3j symbol for given l1,l2,l3,m1,m2,m3. We * explicitly enforce the selection rules. */ double wigner3j_f(double l1, double l2, double l3, double m1, double m2, double m3); @@ -60,4 +63,7 @@ inline double clebschGordan_f(double l1, double l2, double l3, double m1, double double wigner6j_f(double l1, double l2, double l3, double l4, double l5, double l6); } +/*! Computes a string of Wigner-6j symbols for given l2, l3, l4, l5, l6. */ +std::vector wigner6j_f(double l2, double l3, double l4, double l5, double l6); + #endif // WIGNER_SYMBOLS_FORTRAN_H diff --git a/src/wignerSymbols-fortran.cpp b/src/wignerSymbols-fortran.cpp index 5aae75a..b8b8cb6 100644 --- a/src/wignerSymbols-fortran.cpp +++ b/src/wignerSymbols-fortran.cpp @@ -9,6 +9,28 @@ namespace WignerSymbols { + +/*! Computes a string of Wigner-3j symbols for given l2, l3, m1, m2, m3. */ +std::vector wigner3j_f(double l2, double l3, double m1, double m2, double m3) +{ + // We prepare the size of the resulting array. + int size = (int)std::ceil(l2+l3-std::max(std::fabs(l2-l3),std::fabs(m1)))+1; + + // We prepare the output values. + double l1min, l1max; + double thrcof [size]; + int ierr; + + // External function call. + drc3jj_wrap(l2,l3,m2,m3,&l1min,&l1max,thrcof,size,&ierr); + + // We copy the values of the array into a vector. + std::vector thrcof_v(size); + thrcof_v.assign(thrcof, thrcof + size); + + return thrcof_v; +} + /*! Computes the Wigner-3j symbol for given l1,l2,l3,m1,m2,m3. We * explicitly enforce the selection rules. */ double wigner3j_f(double l1, double l2, double l3, diff --git a/tests/gh-issue-2.cpp b/tests/gh-issue-2.cpp index 8bb11ce..18abc4b 100644 --- a/tests/gh-issue-2.cpp +++ b/tests/gh-issue-2.cpp @@ -60,6 +60,8 @@ int main (int argc, char* argv[]) std::cout << "FOR impl.: " << test34 << ", " << test35 << ", " << test36 << std::endl; std::vector test4 = WignerSymbols::wigner3j(992, 1243, 196, -901, 705); + std::vector test4_f = WignerSymbols::wigner3j_f(992, 1243, 196, -901, 705); + std::cout << test4[100] << ", " << test4_f[100] << std::endl; 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; @@ -74,6 +76,8 @@ int main (int argc, char* argv[]) std::cout << "FOR impl.: " << test52 << std::endl; std::cout << std::endl; + std::cout << test4[100] << ", " << test4_f[100] << std::endl; + /* [ 841 379 1011 -631 313 318] -2.44096504011e-41 -0.0 [ 570 1007 1392 327 -933 606] -1.74376347733e-98 0.0