Skip to content

Commit

Permalink
Merge pull request #6 from hmenke/travis
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
joeydumont committed Jan 4, 2018
2 parents 6500a83 + c6d9e9f commit 337dd7e
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 22 deletions.
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
dist: trusty
sudo: false

language: cpp

os: linux

addons:
apt:
packages:
- gfortran
- libarmadillo-dev

compiler:
- clang
- gcc

script:
- mkdir build
- cd build
- cmake -DWITH_COVERAGE=On ..
- make -j 2
- make test
- curl -s https://codecov.io/bash | bash -
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Name of project
project(wignerSymbols)
enable_testing()

set (wignerSymbols_VERSION_MAJOR 0)
set (wignerSymbols_VERSION_MINOR 2)
set (wignerSymbols_VERSION_RELEASE 0)
Expand All @@ -12,10 +14,18 @@ endif()

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

# Coverage report
option(WITH_COVERAGE "Generate code coverage report" OFF)
if(WITH_COVERAGE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the build type" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
link_libraries(gcov)
endif()

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

# Source files
aux_source_directory(./src SRC_LIST)
Expand All @@ -40,6 +50,8 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME}
VERSION ${wignerSymbols_VERSION_MAJOR}.${wignerSymbols_VERSION_MINOR}.${wignerSymbols_VERSION_RELEASE}
SOVERSION ${wignerSymbols_VERSION_MAJOR}.${wignerSymbols_VERSION_MINOR}.${wignerSymbols_VERSION_RELEASE})

add_subdirectory(tests)

# Install directories
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)
4 changes: 2 additions & 2 deletions src/wignerSymbols-cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ double wigner6j(double l1, double l2, double l3,
}

double wigner3j_auxA(double l1, double l2, double l3,
double m1, double m2, double m3)
double m1, double /*m2*/, double /*m3*/)
{
double T1 = l1*l1-pow(l2-l3,2.0);
double T2 = pow(l2+l3+1.0,2.0)-l1*l1;
Expand All @@ -475,7 +475,7 @@ double wigner3j_auxB(double l1, double l2, double l3,
}

double wigner6j_auxA(double l1, double l2, double l3,
double l4, double l5, double l6)
double /*l4*/, double l5, double l6)
{
double T1 = l1*l1-pow(l2-l3,2.0);
double T2 = pow(l2+l3+1.0,2.0)-l1*l1;
Expand Down
18 changes: 7 additions & 11 deletions src/wignerSymbols-fortran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ std::vector<double> wigner3j_f(double l2, double l3, double m1, double m2, doubl

// We prepare the output values.
double l1min, l1max;
double thrcof [size];
std::vector<double> thrcof(size);
int ierr;

// External function call.
drc3jj_wrap(l2,l3,m2,m3,&l1min,&l1max,thrcof,size,&ierr);
drc3jj_wrap(l2,l3,m2,m3,&l1min,&l1max,thrcof.data(),size,&ierr);

// We copy the values of the array into a vector.
std::vector<double> thrcof_v(size);
thrcof_v.assign(thrcof, thrcof + size);

return thrcof_v;
return thrcof;
}

/*! Computes the Wigner-3j symbol for given l1,l2,l3,m1,m2,m3. We
Expand All @@ -55,11 +51,11 @@ double wigner3j_f(double l1, double l2, double l3,

// We prepare the output values.
double l1min, l1max;
double thrcof [size];
std::vector<double> thrcof(size);
int ierr;

// External function call.
drc3jj_wrap(l2,l3,m2,m3,&l1min,&l1max,thrcof,size,&ierr);
drc3jj_wrap(l2,l3,m2,m3,&l1min,&l1max,thrcof.data(),size,&ierr);

// We fetch and return the value with the proper l1 value.
int index = (int)(l1-l1min);
Expand Down Expand Up @@ -95,11 +91,11 @@ double wigner6j_f(double l1, double l2, double l3,

// We prepare the output values
double l1min, l1max;
double sixcof [size];
std::vector<double> sixcof(size);
int ierr;

// External function call
drc6j_wrap(l2,l3,l4,l5,l6,&l1min,&l1max,sixcof,size,&ierr);
drc6j_wrap(l2,l3,l4,l5,l6,&l1min,&l1max,sixcof.data(),size,&ierr);

// We fetch and return the coefficient with the proper l1 value.
int index = (int)(l1-l1min);
Expand Down
13 changes: 13 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_executable(gh-issue-1 gh-issue-1.cpp)
target_link_libraries(gh-issue-1 ${PROJECT_NAME})
add_test(NAME gh-issue-1 COMMAND gh-issue-1)

add_executable(gh-issue-2 gh-issue-2.cpp)
target_link_libraries(gh-issue-2 ${PROJECT_NAME})
add_test(NAME gh-issue-2 COMMAND gh-issue-2)

find_package(Armadillo)
include_directories(${ARMADILLO_INCLUDE_DIRS})
add_executable(testWigner testWigner.cpp)
target_link_libraries(testWigner ${PROJECT_NAME} ${ARMADILLO_LIBRARIES})
add_test(NAME testWigner COMMAND testWigner 10)
11 changes: 7 additions & 4 deletions tests/gh-issue-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <wignerSymbols.h>

int main (int argc, char* argv[])
int main ()
{
double test11 = WignerSymbols::wigner3j(325, 999, 1221, 280, 899, -1179);
double test12 = WignerSymbols::wigner3j(999, 1221, 325, 899, -1179, 280);
Expand Down Expand Up @@ -66,9 +66,12 @@ 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);
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);
std::cout << "C++ impl.: " << test51 << std::endl;
std::cout << "FOR impl.: " << test52 << std::endl;
std::cout << std::endl;

/*
[ 841 379 1011 -631 313 318] -2.44096504011e-41 -0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/gh-issue-2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <wignerSymbols.h>

int main (int argc, char* argv[])
int main ()
{
double test11 = WignerSymbols::wigner3j(325, 999, 1221, 280, 899, -1179);
double test12 = WignerSymbols::wigner3j(999, 1221, 325, 899, -1179, 280);
Expand Down
8 changes: 6 additions & 2 deletions tests/testWigner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ int main(int argc, char* argv[])
timesF.save("timesF.dat",raw_ascii);

// Generate values for l1, l2 and derive the rest of the allowed values.
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <lMax>\n";
return 1;
}
double lMax = atof(argv[1]);
colvec lVec = linspace(0,lMax,lMax+1);

Expand Down Expand Up @@ -204,7 +208,7 @@ double seconSumOverL3(double l1, double l2, double l6)

double value = (l6==0.0 ? sqrt((2.*l1+1.)*(2.*l2+1.)) : 0.0) ;

double diff = std::fabs(value-sum);
//double diff = std::fabs(value-sum);

return std::fabs(value-sum);

Expand All @@ -229,7 +233,7 @@ double timingWignerSymbolsF(double l2, double l3, double m1, double m2, double m
clock_t start = clock();

// We call the subroutine.
double test = WignerSymbols::wigner3j(l2+l3,l2,l3,m1,m2,m3);
WignerSymbols::wigner3j(l2+l3,l2,l3,m1,m2,m3);

clock_t end = clock();

Expand Down

0 comments on commit 337dd7e

Please sign in to comment.