Skip to content

Commit

Permalink
Aesthetic changes to the source code.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydumont committed Oct 29, 2015
1 parent afc22bc commit de452d5
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 127 deletions.
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# Name of project
project(wignerSymbols)
set (wignerSymbols_VERSION_MAJOR 0)
set (wignerSymbols_VERSION_MINOR 1)
set (wignerSymbols_VERSION_RELEASE 3)
set (wignerSymbols_VERSION_MINOR 2)
set (wignerSymbols_VERSION_RELEASE 0)

# CMake config
cmake_minimum_required(VERSION 2.8)
set (CMAKE_INSTALL_PREFIX /usr/)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX /usr)
endif()

# Compiler config
enable_language (Fortran)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -march=native")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -march=native")

# Included files
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include INC_LIST)

# Source files
aux_source_directory(./src SRC_LIST)

# Build a shared library
add_library(${PROJECT_NAME} SHARED
${SRC_LIST}
add_library(${PROJECT_NAME} SHARED
${SRC_LIST}
"./src/wignerSymbols-fortran.f"
"./src/machine.for"
"./src/fdump.f"
Expand Down
2 changes: 1 addition & 1 deletion include/wignerSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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. -/
********************************************************/
********************************************************/

#ifndef WIGNER_SYMBOLS_H
#define WIGNER_SYMBOLS_H
Expand Down
16 changes: 9 additions & 7 deletions include/wignerSymbols/commonFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,31 @@
* 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 commonFunctions.h
/** \file commonFunctions.h
*
* \author Joey Dumont <[email protected]>
*
* \since 2014-07-10
*
* \brief Defines some common functions to the C++ and Fortran code.
* \brief Defines some common functions to the C++ and Fortran code.
*
* We define some functions that will be of use in both the C++ and Fortran
* parts of this library.
* parts of this library.
*
*/

namespace WignerSymbols {
template <typename T>
double sgn(T val)

template <typename T>
double sgn(T val)
{
int sgn = (T(0) < val) - (val < T(0));
if (sgn == 0)
return 1.0;
else
return (double)sgn;
}
}

} // namespace WignerSymbols
20 changes: 10 additions & 10 deletions include/wignerSymbols/wignerSymbols-cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
* 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. -/
********************************************************/
********************************************************/

#ifndef WIGNER_SYMBOLS_CPP_H
#define WIGNER_SYMBOLS_CPP_H

/** \file wignerSymbols-cpp.h
/** \file wignerSymbols-cpp.h
*
* \author Joey Dumont <[email protected]>
*
* \since 2013-08-16
*
* \brief Defines utility functions for the evaluation of Wigner-3j and -6j symbols.
* \brief Defines utility functions for the evaluation of Wigner-3j and -6j symbols.
*
* We compute the Wigner-3j and -6j symbols
* We compute the Wigner-3j and -6j symbols
* f(L1) = ( L1 L2 L3)
* (-M2-M3 M2 M3)
* for all allowed values of L1, the other parameters
* being held fixed. The algorithm is based on the work
* being held fixed. The algorithm is based on the work
* by Schulten and Gordon.
* K. Schulten, "Exact recursive evaluation of 3j- and 6j-coefficients for quantum-mechanical coupling of angular momenta,"
* J. Math. Phys. 16, 1961 (1975).
* K. Schulten and R. G. Gordon, "Recursive evaluation of 3j and 6j coefficients,"
* K. Schulten and R. G. Gordon, "Recursive evaluation of 3j and 6j coefficients,"
* Comput. Phys. Commun. 11, 269–278 (1976).
*/

Expand All @@ -36,8 +36,8 @@

namespace WignerSymbols {

/*! @name Evaluation of Wigner-3j and -6j symbols.
* We implement Schulten's algorithm in C++.
/*! @name Evaluation of Wigner-3j and -6j symbols.
* We implement Schulten's algorithm in C++.
*/
///@{
std::vector<double> wigner3j(double l2, double l3,
Expand All @@ -64,12 +64,12 @@ double wigner6j_auxB(double l1, double l2, double l3,
double l4, double l5, double l6);

/*! Computes the Clebsch-Gordan coefficient by relating it to the
* Wigner 3j symbol. It sometimes eases the notation to use the
* Wigner 3j symbol. It sometimes eases the notation to use the
* Clebsch-Gordan coefficients directly. */
inline double clebschGordan(double l1, double l2, double l3,
double m1, double m2, double m3)
{
// We simply compute it via the 3j symbol.
// We simply compute it via the 3j symbol.
return (pow(-1.0,l1-l2+m3)*sqrt(2.0*l3+1.0)*wigner3j(l1,l2,l3,m1,m2,-m3));
}
}
Expand Down
20 changes: 10 additions & 10 deletions include/wignerSymbols/wignerSymbols-fortran.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
* 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. -/
********************************************************/
********************************************************/

#ifndef WIGNER_SYMBOLS_FORTRAN_H
#define WIGNER_SYMBOLS_FORTRAN_H

/** \file wignerSymbols-fortran.h
/** \file wignerSymbols-fortran.h
*
* \author Joey Dumont <[email protected]>
*
* \since 2013-08-16
*
* \brief Defines utility functions for the evaluation of Wigner-3j and -6j symbols.
* \brief Defines utility functions for the evaluation of Wigner-3j and -6j symbols.
*
* We use modified SLATEC (http:https://netlib.org/slatec) Fortran subroutines to compute
* Wigner-3j and -6j symbols. We modified the subroutines so that they do not depend
* d1mach, r1mach or i1mach as these are obsolete routines. They have been replaced
* We use modified SLATEC (http:https://netlib.org/slatec) Fortran subroutines to compute
* Wigner-3j and -6j symbols. We modified the subroutines so that they do not depend
* d1mach, r1mach or i1mach as these are obsolete routines. They have been replaced
* by intrinsics such as huge(), tiny(), epsilon() and spacing(), which are guaranteed
* to work. The file wignerSymbols.f contain the subroutines and their
* dependencies.
* dependencies.
*
* We rely on the ISO C Binding to bind the Fortran subroutines to C++. This method
* of working insures that proper type casts are performed, among other things. We
* then use the same method as we did before (extern "C").
*
*
*/

#include <cmath>
Expand All @@ -50,11 +50,11 @@ std::vector<double> wigner3j_f(double l2, double l3, double m1, double m2, doubl
double wigner3j_f(double l1, double l2, double l3, double m1, double m2, double m3);

/*! Computes the Clebsch-Gordan coefficient by relating it to the
* Wigner 3j symbol. It sometimes eases the notation to use the
* Wigner 3j symbol. It sometimes eases the notation to use the
* Clebsch-Gordan coefficients directly. */
inline double clebschGordan_f(double l1, double l2, double l3, double m1, double m2, double m3)
{
// We simply compute it via the 3j symbol.
// We simply compute it via the 3j symbol.
return (pow(-1.0,l1-l2+m3)*sqrt(2.0*l3+1.0)*wigner3j_f(l1,l2,l3,m1,m2,-m3));
}

Expand Down

0 comments on commit de452d5

Please sign in to comment.