Skip to content

Commit 4f39638

Browse files
HaoZekeamritagos
andcommitted
ENH: Kill GSL
Co-authored-by: Amrita Goswami <[email protected]>
1 parent f304629 commit 4f39638

File tree

8 files changed

+16
-34
lines changed

8 files changed

+16
-34
lines changed

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dependencies:
1515
- liblapack
1616
- libblas
1717
- boost-cpp
18-
- gsl
1918
- cmake
2019
- lua-luafilesystem
2120
# Pinned

nix/yodaStruct.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
, blas
2222
, lib
2323
, boost
24-
, gsl
2524
, cmake }:
2625
clangStdenv.mkDerivation {
2726
name = "yodaStruct";
@@ -38,7 +37,6 @@
3837
eigen
3938
catch2
4039
boost
41-
gsl
4240
liblapack
4341
blas
4442
lua

src/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
1717
include(FindBLAS)
1818
include(FindLAPACK)
1919
include(FindBoost)
20-
include(FindGSL)
2120
add_compile_options(
2221
# "-Wall" "-Wpedantic" "-Wextra" "-fexceptions"
2322
"$<$<CONFIG:Debug>:-O0;-g3;-ggdb>"
@@ -34,12 +33,10 @@ include_directories(
3433
${LUA_INCLUDE_DIR}
3534
${Boost_INCLUDE_DIRS}
3635
${Eigen3_INCLUDE_DIRS}
37-
${GSL_INCLUDE_DIRS}
3836
)
3937
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
4038
find_package(
4139
"Lua" REQUIRED
42-
"GSL" REQUIRED
4340
"Boost" REQUIRED COMPONENTS system filesystem
4441
"Eigen3 3.3" REQUIRED
4542
"yaml-cpp"
@@ -52,8 +49,6 @@ target_link_libraries(
5249
${Boost_LIBRARIES}
5350
${Eigen3_LIBRARIES}
5451
${LUA_LIBRARIES}
55-
${GSL_LIBRARIES}
56-
stdc++fs
5752
fmt
5853
yaml-cpp
5954
yodaLib

src/bond.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ bond::populateHbonds(std::string filename,
292292
} // end of applying PBCs to the O-H and O--O vectors
293293
//
294294
// Get the angle between the O--O and O-H vectors
295-
double gslAngle = gen::gslVecAngle(ooVec, ohVec);
296-
double gslAngleDeg = gen::radDeg(gslAngle);
295+
double eigenAngle = gen::eigenVecAngle(ooVec, ohVec);
296+
double eigenAngleDeg = gen::radDeg(eigenAngle);
297297

298298
//
299299
// A hydrogen bond is formed if the angle is less than 30 degrees
300-
if (gslAngleDeg > angleCutoff) {
300+
if (eigenAngleDeg > angleCutoff) {
301301
continue;
302302
} // not a hydrogen bond
303303

src/generic.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,18 @@ int gen::unwrappedCoordShift(
140140

141141
/**
142142
* @details Function for obtaining the angle between two input vectors
143-
* (std::vector). Internally, the vectors are converted to GSL vectors. The dot
144-
* product between the input vectors is used to calculate the angle between
143+
* (std::vector). Internally, the vectors are converted to Eigen vectors. The
144+
* dot product between the input vectors is used to calculate the angle between
145145
* them.
146146
* @param[in] OO The O--O vector (but can be any vector, in general).
147147
* @param[in] OH The O-H vector (but can be any vector, in general).
148148
* @return The output angle between the input vectors, in radians
149149
*/
150-
double gen::gslVecAngle(std::vector<double> OO, std::vector<double> OH) {
151-
gsl_vector *gOO = gsl_vector_alloc(3);
152-
gsl_vector *gOH = gsl_vector_alloc(3);
153-
double norm_gOO, norm_gOH, xDummy, angle;
154-
for (int i = 0; i < 3; i++) {
155-
gsl_vector_set(gOO, i, OO[i]);
156-
gsl_vector_set(gOH, i, OH[i]);
157-
}
158-
norm_gOO = gsl_blas_dnrm2(gOO);
159-
norm_gOH = gsl_blas_dnrm2(gOH);
160-
gsl_blas_ddot(gOO, gOH, &xDummy);
161-
angle = acos(xDummy / (norm_gOO * norm_gOH));
162-
gsl_vector_free(gOO);
163-
gsl_vector_free(gOH);
150+
double gen::eigenVecAngle(std::vector<double> OO, std::vector<double> OH) {
151+
Eigen::Vector3d eigOO = Eigen::Map<Eigen::Vector3d>(OO.data(), OO.size());
152+
Eigen::Vector3d eigOH = Eigen::Map<Eigen::Vector3d>(OH.data(), OH.size());
153+
double angle;
154+
angle = acos(eigOO.dot(eigOH) / (eigOO.norm() * eigOH.norm()));
164155
return angle;
165156
}
166157

src/include/internal/generic.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
// Boost
2020
#include <boost/math/constants/constants.hpp>
21-
#include <gsl/gsl_blas.h>
21+
// Eigen
22+
#include <eigen3/Eigen/Core>
23+
#include <eigen3/Eigen/Dense>
2224

2325
/** @file generic.hpp
2426
* @brief File for containing generic or common functions.
@@ -54,8 +56,8 @@ const double pi = boost::math::constants::pi<double>();
5456
*/
5557
inline double radDeg(double angle) { return (angle * 180) / gen::pi; }
5658

57-
//! GSL for getting the angle (in radians) between the O--O and O-H vectors
58-
double gslVecAngle(std::vector<double> OO, std::vector<double> OH);
59+
//! Eigen function for getting the angle (in radians) between the O--O and O-H vectors
60+
double eigenVecAngle(std::vector<double> OO, std::vector<double> OH);
5961

6062
//! Get the average, after excluding the outliers, using quartiles
6163
double getAverageWithoutOutliers(std::vector<double> inpVec);

src/include/internal/mol_sys.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <string>
2121
#include <sys/stat.h>
2222
#include <vector>
23+
#include<unordered_map>
2324

2425
// For debugging, instantiate the unordered map [consider removal for
2526
// production]

tests/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ add_executable(yodaStruct_test
3131
# include(FindBLAS)
3232
# include(FindLAPACK)
3333
# include(FindBoost)
34-
include(FindGSL)
3534

3635
# Find packages
3736
find_package(
3837
"Lua" REQUIRED
3938
"Boost" REQUIRED
4039
"Eigen3 3.3" REQUIRED
4140
"Catch2" REQUIRED
42-
"GSL" REQUIRED
4341
"yaml-cpp"
4442
"fmt"
4543
)
@@ -49,7 +47,6 @@ target_link_libraries(yodaStruct_test
4947
${Boost_LIBRARIES}
5048
${Eigen3_LIBRARIES}
5149
${LUA_LIBRARIES}
52-
${GSL_LIBRARIES}
5350
fmt
5451
yaml-cpp
5552
yodaLib
@@ -60,7 +57,6 @@ target_link_libraries(yodaStruct_test
6057
include_directories(
6158
${PROJECT_SOURCE_DIR}/src/include/internal
6259
${PROJECT_SOURCE_DIR}/src/include/external
63-
${GSL_INCLUDE_DIRS}
6460
${Eigen3_INCLUDE_DIRS}
6561
)
6662
# Run unit tests

0 commit comments

Comments
 (0)