Fixed Eigen include in CMake and moved num_rows and num_cols to placate gcc

This commit is contained in:
Ian Bell
2014-07-06 11:31:19 +02:00
parent 9202fbce4d
commit 7d9c0bffdf
2 changed files with 38 additions and 36 deletions

View File

@@ -66,7 +66,7 @@ list(REMOVE_ITEM APP_SOURCES "${CMAKE_SOURCE_DIR}/src/Tests/Tests.cpp")
## You can exclude this file as well, in case you want to run your own tests
#list(REMOVE_ITEM APP_SOURCES "${CMAKE_SOURCE_DIR}/src/Tests/test_main.cpp")
set (APP_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/externals/eigen")
set (APP_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/externals/Eigen")
foreach (_headerFile ${APP_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND APP_INCLUDE_DIRS ${_dir})

View File

@@ -28,6 +28,43 @@ template<typename T> struct VectorNd<0,T> {
namespace CoolProp{
/// Some shortcuts and regularly needed operations
template<class T> std::size_t num_rows ( std::vector<T> const& in){ return in.size(); }
template<class T> std::size_t num_rows (std::vector<std::vector<T> > const& in){ return in.size(); }
template<class T> std::size_t max_cols (std::vector<std::vector<T> > const& in){
std::size_t cols = 0;
std::size_t col = 0;
for (std::size_t i = 0; i < in.size(); i++) {
col = in[i].size();
if (cols<col) {cols = col;}
}
return cols;
};
template<class T> bool is_squared(std::vector<std::vector<T> > const& in){
std::size_t cols = max_cols(in);
if (cols!=num_rows(in)) { return false;}
else {
for (std::size_t i = 0; i < in.size(); i++) {
if (cols!=in[i].size()) {return false; }
}
}
return true;
};
template<class T> std::size_t num_cols ( std::vector<T> const& in){ return 1; }
template<class T> std::size_t num_cols (std::vector<std::vector<T> > const& in){
if (num_rows(in)>0) {
if (is_squared(in)) {
return in[0].size();
} else {
return max_cols(in);
}
} else {
return 0;
}
};
/// Convert vectors and matrices
/** Conversion functions for the different kinds of object-like
@@ -364,42 +401,7 @@ template <class T> std::string mat_to_string(const Eigen::Matrix<T,Eigen::Dynami
//template<class T> std::string vec_to_string(std::vector<std::vector<T> > const& A, const char *fmt);
/// Some shortcuts and regularly needed operations
template<class T> std::size_t num_rows ( std::vector<T> const& in){ return in.size(); }
template<class T> std::size_t num_rows (std::vector<std::vector<T> > const& in){ return in.size(); }
template<class T> std::size_t max_cols (std::vector<std::vector<T> > const& in){
std::size_t cols = 0;
std::size_t col = 0;
for (std::size_t i = 0; i < in.size(); i++) {
col = in[i].size();
if (cols<col) {cols = col;}
}
return cols;
};
template<class T> bool is_squared(std::vector<std::vector<T> > const& in){
std::size_t cols = max_cols(in);
if (cols!=num_rows(in)) { return false;}
else {
for (std::size_t i = 0; i < in.size(); i++) {
if (cols!=in[i].size()) {return false; }
}
}
return true;
};
template<class T> std::size_t num_cols ( std::vector<T> const& in){ return 1; }
template<class T> std::size_t num_cols (std::vector<std::vector<T> > const& in){
if (num_rows(in)>0) {
if (is_squared(in)) {
return in[0].size();
} else {
return max_cols(in);
}
} else {
return 0;
}
};
/*