diff --git a/.gitmodules b/.gitmodules index 43b841cdaecb3c4a1cfada8025743cef26ac47fc..a3208e025bcd6a8594c98a8507f580fbb449dd1c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "ThirdParty/quickcheck"] path = ThirdParty/quickcheck - url = http://software.legiasoft.com/git/quickcheck.git + url = https://github.com/ufz/quickcheck.git [submodule "ThirdParty/VtkFbxConverter"] path = ThirdParty/VtkFbxConverter url = https://github.com/bilke/VtkFbxConverter.git diff --git a/.travis.yml b/.travis.yml index d513f3b84f5abf90fd740dad6d8fc8c3ec4aff01..d875465629b6abc5a5bb9ef622ca0ed884b154ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ branches: only: - master before_install: - - sudo apt-get update; sudo apt-get install qt4-dev-tools libvtk5-dev libvtk5-qt4-dev libnetcdf-dev libshp-dev libgeotiff-dev -script: "mkdir build && cd build && cmake -DOGS_BUILD_GUI=ON -DOGS_DONT_USE_OPTIONAL_SUBMODULES=ON .. && cmake .. && make && make test" + - sudo apt-get update; sudo apt-get install qt4-dev-tools libvtk5-dev libvtk5-qt4-dev libnetcdf-dev libshp-dev libgeotiff-dev libboost-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev +script: "mkdir build && cd build && cmake -DOGS_BUILD_GUI=ON .. && cmake .. && make && make test" notifications: email: - lars.bilke@ufz.de diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 37220a3d1d8fcde181a662d64962495ae55ec492..0920e5e93d3d8f80f9d3517797c3dd67d209c90f 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -399,6 +399,7 @@ const std::string GEOObjects::getElementNameByID(const std::string &geometry_nam break; default: INFO("GEOObjects::getElementNameByID() - No valid GEOTYPE given."); + break; } return name; } diff --git a/GeoLib/PointVec.cpp b/GeoLib/PointVec.cpp index a9548aac5e44c7f35e1234c1b9704745f06bd236..c2cadc8812d5b4e67417204ebf33341238359f0f 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -74,30 +74,34 @@ void PointVec::push_back (Point* pnt, std::string const*const name) std::size_t PointVec::uniqueInsert (Point* pnt) { - std::size_t n (_data_vec->size()), k; const double eps (std::numeric_limits<double>::epsilon()); - for (k = 0; k < n; k++) - if (fabs((*((*_data_vec)[k]))[0] - (*pnt)[0]) < eps - && fabs( (*((*_data_vec)[k]))[1] - (*pnt)[1]) < eps - && fabs( (*((*_data_vec)[k]))[2] - (*pnt)[2]) < eps) - break; - - if(k == n) { - _data_vec->push_back (pnt); - // update bounding box - _aabb.update (*((*_data_vec)[n])); - // update shortest distance - for (std::size_t i(0); i < n; i++) { - double sqr_dist (MathLib::sqrDist((*_data_vec)[i], (*_data_vec)[n])); - if (sqr_dist < _sqr_shortest_dist) - _sqr_shortest_dist = sqr_dist; - } - return n; + auto const it = std::find_if(_data_vec->begin(), _data_vec->end(), + [&eps, &pnt](Point* const p) + { + return MathLib::maxNormDist(p, pnt) <= eps; + }); + + if (it != _data_vec->end()) + { + delete pnt; + pnt = NULL; + return std::distance(_data_vec->begin(), it); } - delete pnt; - pnt = NULL; - return k; + _data_vec->push_back(pnt); + + // update bounding box + _aabb.update (*(_data_vec->back())); + + // update shortest distance + std::for_each(_data_vec->begin(), _data_vec->end(), + [this](Point* const p) + { + _sqr_shortest_dist = std::min(_sqr_shortest_dist, + MathLib::sqrDist(p, _data_vec->back())); + }); + + return _data_vec->size()-1; } std::vector<Point*>* PointVec::filterStations(const std::vector<PropertyBounds> &bounds) const @@ -134,10 +138,10 @@ void PointVec::makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec, // determine intervals with identical points to resort for stability of sorting std::vector<std::size_t> identical_pnts_interval; bool identical(false); - for (std::size_t k = 0; k < n_pnts_in_file - 1; k++) { - if (fabs((*((*pnt_vec)[k + 1]))[0] - (*((*pnt_vec)[k]))[0]) < eps - && fabs((*((*pnt_vec)[k + 1]))[1] - (*((*pnt_vec)[k]))[1]) < eps - && fabs((*((*pnt_vec)[k + 1]))[2] - (*((*pnt_vec)[k]))[2]) < eps) { + for (std::size_t k = 0; k < n_pnts_in_file - 1; k++) + { + if (MathLib::maxNormDist((*pnt_vec)[k + 1], (*pnt_vec)[k]) <= eps) + { // points are identical, sort by id if (!identical) identical_pnts_interval.push_back(k); @@ -163,13 +167,9 @@ void PointVec::makePntsUnique (std::vector<GeoLib::Point*>* pnt_vec, } // check if there are identical points - for (std::size_t k = 0; k < n_pnts_in_file - 1; k++) { - if (fabs((*((*pnt_vec)[k + 1]))[0] - (*((*pnt_vec)[k]))[0]) < eps - && fabs((*((*pnt_vec)[k + 1]))[1] - (*((*pnt_vec)[k]))[1]) < eps - && fabs((*((*pnt_vec)[k + 1]))[2] - (*((*pnt_vec)[k]))[2]) < eps) { + for (std::size_t k = 0; k < n_pnts_in_file - 1; k++) + if (MathLib::maxNormDist((*pnt_vec)[k + 1], (*pnt_vec)[k]) <= eps) pnt_id_map[perm[k + 1]] = pnt_id_map[perm[k]]; - } - } // reverse permutation BaseLib::Quicksort<std::size_t, GeoLib::Point*>(perm, 0, n_pnts_in_file, *pnt_vec); diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp index 4099dda882f48a229cbc92349ff1ba570d0a62ae..9973b9470de9122d5a575e0d92276c56e7306318 100644 --- a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp +++ b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp @@ -58,26 +58,21 @@ double PiecewiseLinearInterpolation::getValue(double pnt_to_interpolate) const { // search interval that has the point inside std::size_t interval_idx(std::numeric_limits<std::size_t>::max()); - for (std::size_t k(1); k < _supp_pnts.size() - && interval_idx == std::numeric_limits<std::size_t>::max(); k++) - if (_supp_pnts[k - 1] <= pnt_to_interpolate - && pnt_to_interpolate <= _supp_pnts[k]) - interval_idx = k - 1; - - if (interval_idx == std::numeric_limits<std::size_t>::max()) { - const double dist_first(fabs(_supp_pnts[0] - pnt_to_interpolate)); - const double dist_last(fabs(_supp_pnts[_supp_pnts.size() - 1] - pnt_to_interpolate)); - if (dist_first < dist_last) - interval_idx = 0; - else + if (pnt_to_interpolate < _supp_pnts.front()) { + interval_idx = 0; + } else { + if (_supp_pnts.back() < pnt_to_interpolate) { interval_idx = _supp_pnts.size() - 2; + } else { + auto const& it(std::lower_bound(_supp_pnts.begin(), _supp_pnts.end(), pnt_to_interpolate)); + interval_idx = std::distance(_supp_pnts.begin(), it) - 1; + } } - // compute linear interpolation polynom: y = m * x + n - long double m((_values_at_supp_pnts[interval_idx + 1] - _values_at_supp_pnts[interval_idx]) - / (_supp_pnts[interval_idx + 1] - _supp_pnts[interval_idx])); - long double n(_values_at_supp_pnts[interval_idx] - m * _supp_pnts[interval_idx]); + // compute linear interpolation polynom: y = m * (x - support[i]) + value[i] + const long double m((_values_at_supp_pnts[interval_idx + 1] - _values_at_supp_pnts[interval_idx]) + / (_supp_pnts[interval_idx + 1] - _supp_pnts[interval_idx])); - return m * pnt_to_interpolate + n; + return m * (pnt_to_interpolate - _supp_pnts[interval_idx]) + _values_at_supp_pnts[interval_idx]; } } // end MathLib diff --git a/MathLib/LinAlg/Dense/Matrix.h b/MathLib/LinAlg/Dense/Matrix.h index 5fc2aa738122c58ab39bebd819f6e48cb4b2307c..4046701afd8a387e983d3be1a7eab4dde512cf57 100644 --- a/MathLib/LinAlg/Dense/Matrix.h +++ b/MathLib/LinAlg/Dense/Matrix.h @@ -20,12 +20,15 @@ #include <stdexcept> #include <iostream> +// MathLib/LinAlg +#include "../MatrixBase.h" + namespace MathLib { /** * Matrix represents a dense matrix for a numeric data type. */ -template <class T> class Matrix +template <class T> class Matrix : public MatrixBase { public: Matrix (std::size_t rows, std::size_t cols); @@ -34,8 +37,6 @@ public: ~Matrix (); - std::size_t getNRows () const { return nrows; } - std::size_t getNCols () const { return ncols; } /** * \f$ y = \alpha \cdot A x + \beta y\f$ */ @@ -92,60 +93,57 @@ public: */ void write (std::ostream& out) const; - T const* getCoords () { return data; } - private: // zero based addressing, but Fortran storage layout //inline std::size_t address(std::size_t i, std::size_t j) const { return j*rows+i; }; // zero based addressing, C storage layout - inline std::size_t address(std::size_t i, std::size_t j) const { return i*ncols+j; }; + inline std::size_t address(std::size_t i, std::size_t j) const { return i*_n_cols+j; }; - std::size_t nrows; - std::size_t ncols; - T *data; + T *_data; }; template<class T> Matrix<T>::Matrix (std::size_t rows, std::size_t cols) - : nrows (rows), ncols (cols), data (new T[nrows*ncols]) + : MatrixBase(rows, cols), _data (new T[_n_rows*_n_cols]) {} template<class T> Matrix<T>::Matrix (std::size_t rows, std::size_t cols, T const& initial_value) - : nrows (rows), ncols (cols), data (new T[nrows * ncols]) + : MatrixBase(rows, cols), _data (new T[_n_rows*_n_cols]) { - const std::size_t n(nrows*ncols); - for (std::size_t k(0); k<n; k++) data[k] = initial_value; + const std::size_t n(_n_rows*_n_cols); + for (std::size_t k(0); k<n; k++) + _data[k] = initial_value; } template<class T> Matrix<T>::Matrix (const Matrix& src) : - nrows (src.getNRows ()), ncols (src.getNCols ()), data (new T[nrows * ncols]) + MatrixBase(src.getNRows (), src.getNCols ()), _data (new T[_n_rows * _n_cols]) { - for (std::size_t i = 0; i < nrows; i++) - for (std::size_t j = 0; j < ncols; j++) - data[address(i,j)] = src (i, j); + for (std::size_t i = 0; i < _n_rows; i++) + for (std::size_t j = 0; j < _n_cols; j++) + _data[address(i,j)] = src (i, j); } template <class T> Matrix<T>::~Matrix () { - delete [] data; + delete [] _data; } template<class T> void Matrix<T>::axpy ( T alpha, const T* x, T beta, T* y) const { - for (std::size_t i(0); i<nrows; i++) { + for (std::size_t i(0); i<_n_rows; i++) { y[i] += beta * y[i]; - for (std::size_t j(0); j<ncols; j++) { - y[i] += alpha * data[address(i,j)] * x[j]; + for (std::size_t j(0); j<_n_cols; j++) { + y[i] += alpha * _data[address(i,j)] * x[j]; } } } template<class T> T* Matrix<T>::operator* (const T *x) const { - T *y (new T[nrows]); - for (std::size_t i(0); i < nrows; i++) { + T *y (new T[_n_rows]); + for (std::size_t i(0); i < _n_rows; i++) { y[i] = 0.0; - for (std::size_t j(0); j < ncols; j++) { - y[i] += data[address(i, j)] * x[j]; + for (std::size_t j(0); j < _n_cols; j++) { + y[i] += _data[address(i, j)] * x[j]; } } @@ -156,13 +154,13 @@ template<class T> T* Matrix<T>::operator* (const T *x) const template<class T> Matrix<T>* Matrix<T>::operator+ (const Matrix<T>& mat) const throw (std::range_error) { // make sure the two matrices have the same dimension. - if (nrows != mat.getNRows() || ncols != mat.getNCols()) + if (_n_rows != mat.getNRows() || _n_cols != mat.getNCols()) throw std::range_error("Matrix::operator+, illegal matrix size!"); - Matrix<T>* y(new Matrix<T> (nrows, ncols)); - for (std::size_t i = 0; i < nrows; i++) { - for (std::size_t j = 0; j < ncols; j++) { - (*y)(i, j) = data[address(i, j)] + mat(i, j); + Matrix<T>* y(new Matrix<T> (_n_rows, _n_cols)); + for (std::size_t i = 0; i < _n_rows; i++) { + for (std::size_t j = 0; j < _n_cols; j++) { + (*y)(i, j) = _data[address(i, j)] + mat(i, j); } } @@ -173,13 +171,13 @@ template<class T> Matrix<T>* Matrix<T>::operator+ (const Matrix<T>& mat) const t template<class T> Matrix<T>* Matrix<T>::operator- (const Matrix<T>& mat) const throw (std::range_error) { // make sure the two matrices have the same dimension. - if (nrows != mat.getNRows() || ncols != mat.getNCols()) + if (_n_rows != mat.getNRows() || _n_cols != mat.getNCols()) throw std::range_error("Matrix::operator-, illegal matrix size!"); - Matrix<T>* y(new Matrix<T> (nrows, ncols)); - for (std::size_t i = 0; i < nrows; i++) { - for (std::size_t j = 0; j < ncols; j++) { - (*y)(i, j) = data[address(i, j)] - mat(i, j); + Matrix<T>* y(new Matrix<T> (_n_rows, _n_cols)); + for (std::size_t i = 0; i < _n_rows; i++) { + for (std::size_t j = 0; j < _n_cols; j++) { + (*y)(i, j) = _data[address(i, j)] - mat(i, j); } } @@ -190,17 +188,17 @@ template<class T> Matrix<T>* Matrix<T>::operator- (const Matrix<T>& mat) const t template<class T> Matrix<T>* Matrix<T>::operator* (const Matrix<T>& mat) const throw (std::range_error) { // make sure the two matrices have the same dimension. - if (ncols != mat.getNRows()) + if (_n_cols != mat.getNRows()) throw std::range_error( "Matrix::operator*, number of rows and cols should be the same!"); std::size_t y_cols(mat.getNCols()); - Matrix<T>* y(new Matrix<T> (nrows, y_cols, T(0))); + Matrix<T>* y(new Matrix<T> (_n_rows, y_cols, T(0))); - for (std::size_t i = 0; i < nrows; i++) { + for (std::size_t i = 0; i < _n_rows; i++) { for (std::size_t j = 0; j < y_cols; j++) { - for (std::size_t k = 0; k < ncols; k++) - (*y)(i, j) += data[address(i, k)] * mat(k, j); + for (std::size_t k = 0; k < _n_cols; k++) + (*y)(i, j) += _data[address(i, k)] * mat(k, j); } } @@ -210,12 +208,12 @@ template<class T> Matrix<T>* Matrix<T>::operator* (const Matrix<T>& mat) const t // HS initial implementation template<class T> Matrix<T>* Matrix<T>::transpose() const { - Matrix<T>* y(new Matrix<T> (ncols, nrows)); + Matrix<T>* y(new Matrix<T> (_n_cols, _n_rows)); - for (std::size_t i = 0; i < nrows; i++) { - for (std::size_t j = 0; j < ncols; j++) { -// y->data[y->address(j, i)] = data[address(i, j)]; - (*y)(j,i) = data[address(i, j)]; + for (std::size_t i = 0; i < _n_rows; i++) { + for (std::size_t j = 0; j < _n_cols; j++) { +// y->_data[y->address(j, i)] = _data[address(i, j)]; + (*y)(j,i) = _data[address(i, j)]; } } return y; @@ -227,13 +225,13 @@ template<class T> Matrix<T>* Matrix<T>::getSubMatrix( { if (b_row >= e_row | b_col >= e_col) throw std::range_error ("Matrix::getSubMatrix() illegal sub matrix"); - if (e_row > nrows | e_col > ncols) + if (e_row > _n_rows | e_col > _n_cols) throw std::range_error ("Matrix::getSubMatrix() illegal sub matrix"); Matrix<T>* y(new Matrix<T> (e_row-b_row, e_col-b_col)); for (std::size_t i=b_row; i<e_row; i++) { for (std::size_t j=b_col; j<e_col; j++) { - (*y)(i-b_row, j-b_col) = data[address(i, j)]; + (*y)(i-b_row, j-b_col) = _data[address(i, j)]; } } return y; @@ -242,12 +240,12 @@ template<class T> Matrix<T>* Matrix<T>::getSubMatrix( template<class T> void Matrix<T>::setSubMatrix( std::size_t b_row, std::size_t b_col, const Matrix<T>& sub_mat) throw (std::range_error) { - if (b_row + sub_mat.getNRows() > nrows | b_col + sub_mat.getNCols() > ncols) + if (b_row + sub_mat.getNRows() > _n_rows | b_col + sub_mat.getNCols() > _n_cols) throw std::range_error ("Matrix::setSubMatrix() sub matrix to big"); for (std::size_t i=0; i<sub_mat.getNRows(); i++) { for (std::size_t j=0; j<sub_mat.getNCols(); j++) { - data[address(i+b_row, j+b_col)] = sub_mat(i,j); + _data[address(i+b_row, j+b_col)] = sub_mat(i,j); } } } @@ -255,25 +253,25 @@ template<class T> void Matrix<T>::setSubMatrix( template<class T> T& Matrix<T>::operator() (std::size_t row, std::size_t col) throw (std::range_error) { - if ( (row >= nrows) | ( col >= ncols) ) + if ( (row >= _n_rows) | ( col >= _n_cols) ) throw std::range_error ("Matrix: op() const range error"); - return data [address(row,col)]; + return _data [address(row,col)]; } template<class T> T& Matrix<T>::operator() (std::size_t row, std::size_t col) const throw (std::range_error) { - if ( (row >= nrows) | ( col >= ncols) ) + if ( (row >= _n_rows) | ( col >= _n_cols) ) throw std::range_error ("Matrix: op() const range error"); - return data [address(row,col)]; + return _data [address(row,col)]; } template <class T> void Matrix<T>::write (std::ostream &out) const { - for (std::size_t i = 0; i < nrows; i++) { - for (std::size_t j = 0; j < ncols; j++) { - out << data[address(i, j)] << "\t"; + for (std::size_t i = 0; i < _n_rows; i++) { + for (std::size_t j = 0; j < _n_cols; j++) { + out << _data[address(i, j)] << "\t"; } out << "\n"; } diff --git a/MathLib/LinAlg/MatrixBase.h b/MathLib/LinAlg/MatrixBase.h index d3baf9bde6e85d5399322c9becaef9df29a79176..03598386d4793286ef396e4c0496a527a587f41a 100644 --- a/MathLib/LinAlg/MatrixBase.h +++ b/MathLib/LinAlg/MatrixBase.h @@ -15,12 +15,14 @@ #ifndef MATRIXBASE_H_ #define MATRIXBASE_H_ -namespace MathLib { +namespace MathLib +{ /** * class MatrixBase is the basis for all matrix classes (dense and sparse) */ -class MatrixBase { +class MatrixBase +{ public: /** * Constructor for initialization of the number of rows and columns diff --git a/MathLib/LinAlg/Solvers/CGParallel.cpp b/MathLib/LinAlg/Solvers/CGParallel.cpp index 89d1a0b96c6ce013be2ba8df1e515008a1a9756e..b9d92cc1e0965a509840a7e426cfb4e07254eee9 100644 --- a/MathLib/LinAlg/Solvers/CGParallel.cpp +++ b/MathLib/LinAlg/Solvers/CGParallel.cpp @@ -42,6 +42,10 @@ namespace MathLib { unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const b, double* const x, double& eps, unsigned& nsteps) { +#ifdef WIN32 +#pragma warning ( push ) +#pragma warning ( disable: 4018 ) +#endif const unsigned N(mat->getNRows()); double * __restrict__ p(new double[N]); double * __restrict__ q(new double[N]); @@ -85,7 +89,7 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const // r^ = C r // rhat = r // blas::copy(N, r, rhat); - #pragma omp parallel for +#pragma omp parallel for for (k = 0; k < N; k++) { rhat[k] = r[k]; } @@ -97,7 +101,7 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const if (l > 1) { double beta = rho / rho1; // p = r^ + beta * p - #pragma omp parallel for +#pragma omp parallel for for (k = 0; k < N; k++) { p[k] = rhat[k] + beta * p[k]; } @@ -152,6 +156,9 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const delete[] r; delete[] rhat; return 1; +#ifdef WIN32 +#pragma warning ( pop ) +#endif } #endif diff --git a/MathLib/LinAlg/Solvers/blas.h b/MathLib/LinAlg/Solvers/blas.h index 81513665b20ac717de6ea18beea5cee3423339fd..d4ab83652140d2225bc973709f3827a1183a8294 100644 --- a/MathLib/LinAlg/Solvers/blas.h +++ b/MathLib/LinAlg/Solvers/blas.h @@ -5,33 +5,7 @@ #include <cstdlib> #include <cmath> -#define SIGN(a) ((a) >= 0 ? 1.0 : -1.0) -#define SQR(a) ((a)*(a)) // Quadrat von a -inline double abs2(double a) { - return SQR(a); -} -inline double abs2(float a) { - return SQR(a); -} -#ifndef WIN32 -inline double abs(double a) { - return fabs(a); -} -inline float abs(float a) { - return fabsf(a); -} -#endif -#define MIN(a,b) ((a) <= (b) ? (a) : (b)) -#define MAX(a,b) ((a) >= (b) ? (a) : (b)) -inline unsigned LTR(unsigned i, unsigned j, unsigned n) -{ - return ((2*n-j-1)*j)/2+i; -} -inline unsigned UTR(unsigned i, unsigned j) -{ - return (j*(j+1))/2+i; -} inline unsigned GE(unsigned i, unsigned j, unsigned n) { return i+j*n; @@ -50,88 +24,6 @@ const unsigned N_ONE = 1; const int N_MONE = -1; const char JOB_STR[] = "NTOSVULCRA"; -/* - #ifdef WIN32 - #define dcopy_ dcopy - #define dnrm2_ dnrm2 - #define dgemv_ dgemv - #define dspmv_ dspmv - #define dtpmv_ dtpmv - #define dgemm_ dgemm - #define daxpy_ daxpy - #define ddot_ ddot - #define dscal_ dscal - #define dgesvd_ dgesvd - #define dgeqrf_ dgeqrf - #define dormqr_ dormqr - #define dorgqr_ dorgqr - #define dgetri_ dgetri - #define dgetrf_ dgetrf - #define dsptri_ dsptri - #define dsptrf_ dsptrf - #define dtptrs_ dtptrs - #define dpptrf_ dpptrf - #define scopy_ scopy - #define snrm2_ snrm2 - #define sgemv_ sgemv - #define sspmv_ sspmv - #define stpmv_ stpmv - #define sgemm_ sgemm - #define saxpy_ saxpy - #define sdot_ sdot - #define sscal_ sscal - #define sgesvd_ sgesvd - #define sgeqrf_ sgeqrf - #define sormqr_ sormqr - #define sorgqr_ sorgqr - #define sgetri_ sgetri - #define sgetrf_ sgetrf - #define ssptri_ ssptri - #define ssptrf_ ssptrf - #define stptrs_ stptrs - #define spptrf_ spptrf - #define ccopy_ ccopy - #define scnrm2_ scnrm2 - #define cgemv_ cgemv - #define chpmv_ chpmv - #define ctpmv_ ctpmv - #define cgemm_ cgemm - #define caxpy_ caxpy - #define cdotc_ cdotc - #define cscal_ cscal - #define cgesvd_ cgesvd - #define cgeqrf_ cgeqrf - #define cunmqr_ cunmqr - #define cungqr_ cungqr - #define cgetri_ cgetri - #define cgetrf_ cgetrf - #define csptri_ csptri - #define csptrf_ csptrf - #define ctptrs_ ctptrs - #define cpptrf_ cpptrf - #define zcopy_ zcopy - #define dznrm2_ dznrm2 - #define zgemv_ zgemv - #define zhpmv_ zhpmv - #define ztpmv_ ztpmv - #define zgemm_ zgemm - #define zaxpy_ zaxpy - #define zdotc_ zdotc - #define zscal_ zscal - #define zgesvd_ zgesvd - #define zgeqrf_ zgeqrf - #define zunmqr_ zunmqr - #define zungqr_ zungqr - #define zgetri_ zgetri - #define zgetrf_ zgetrf - #define zsptri_ zsptri - #define zsptrf_ zsptrf - #define ztptrs_ ztptrs - #define zpptrf_ zpptrf - #endif -*/ - - extern "C" { /******************************************************************/ @@ -299,9 +191,6 @@ extern "C" namespace blas { -// inline void conj(unsigned n, double* v) {} -// inline void conj(unsigned n, float* v) {} - inline void swap(const unsigned n, double* x, const unsigned incx, double* y, const unsigned incy ) { @@ -369,18 +258,6 @@ namespace blas return snrm2_(&n, v, &N_ONE); } - inline double diff2(const unsigned n, double* x, double* y) - { - double s = 0.0; - for (unsigned i=0; i<n; ++i) s += SQR(x[i]-y[i]); - return sqrt(s); - } - inline float diff2(const unsigned n, float* x, float* y) - { - float s = 0.0; - for (unsigned i=0; i<n; ++i) s += SQR(x[i]-y[i]); - return sqrtf(s); - } inline void copy(const unsigned n, const double*const orig, double* dest) { dcopy_(&n, orig, &N_ONE, dest, &N_ONE); @@ -862,19 +739,7 @@ namespace blas wk, &nwk, &INF); return INF; } - inline int gesvd(unsigned m, unsigned n, float* A, double* S, - float* VT, unsigned ldVT, unsigned nwk, float* wk) - { - int INF; - // workaround (needs to be improved) - float* Sf = new float[MIN(m,n)]; - for(unsigned i=0;i<MIN(m,n);i++) - Sf[i] = (float)S[i]; - sgesvd_(JOB_STR+2, JOB_STR+3, &m, &n, A, &m, Sf, A, &m, VT, &ldVT, - wk, &nwk, &INF); - delete [] Sf; - return INF; - } + inline int gesvd(unsigned m, unsigned n, double* A, double* S, double* U, unsigned ldU, double* VT, unsigned ldVT, unsigned nwk, double* wk) @@ -884,20 +749,6 @@ namespace blas wk, &nwk, &INF); return INF; } - inline int gesvd(unsigned m, unsigned n, float* A, double* S, - float* U, unsigned ldU, float* VT, unsigned ldVT, - unsigned nwk, float* wk) - { - int INF; - // workaround (needs to be improved) - float* Sf = new float[MIN(m,n)]; - for(unsigned i=0;i<MIN(m,n);i++) - Sf[i] = (float)S[i]; - sgesvd_(JOB_STR+9, JOB_STR+9, &m, &n, A, &m, Sf, U, &ldU, VT, &ldVT, - wk, &nwk, &INF); - delete [] Sf; - return INF; - } // compute singular values inline int svals(unsigned m, unsigned n, double* A, double* S, @@ -1127,95 +978,6 @@ namespace blas for (unsigned i=0; i<m; ++i) scopy_(&n, A+i, &m, B+i*n, &N_ONE); } - // product of upper triangular and regular Matrix M = R A, R mxp, A nxp - inline void utrgemmh(const unsigned m, const unsigned p, const unsigned n, - const double* const R, const unsigned ldR, - const double* const A, const unsigned ldA, - double* const M, const unsigned ldM) - { - for (unsigned i=0; i<m; ++i) { - for (unsigned j=0; j<n; ++j) { - double d = D_ZERO; - for(unsigned l=i; l<p; ++l) - d += R[i+l*ldR]*A[j+l*ldA]; - M[i+j*ldM] = d; - } - } - } - inline void utrgemmh(const unsigned m, const unsigned p, const unsigned n, - const float* const R, const unsigned ldR, - const float* const A, const unsigned ldA, - float* const M, const unsigned ldM) - { - for (unsigned i=0; i<m; ++i) { - for (unsigned j=0; j<n; ++j) { - float d = S_ZERO; - for(unsigned l=i; l<p; ++l) - d += R[i+l*ldR]*A[j+l*ldA]; - M[i+j*ldM] = d; - } - } - } - - // product of two upper triangular matrices M = R1 R2^T, R1 mxp, R2 nxp - inline void utrmmh(const unsigned m, const unsigned p, const unsigned n, - const double* const R1, const unsigned ldR1, - const double* const R2, const unsigned ldR2, - double* const M) - { - for (unsigned j=0; j<n; ++j) { - for (unsigned i=0; i<m; ++i) { - double d = D_ZERO; - unsigned ij = MAX(i,j); - for (unsigned l=ij; l<p; ++l) - d += R1[i+l*ldR1]*R2[j+l*ldR2]; - M[i+j*m] = d; - } - } - } - inline void utrmmh(const unsigned m, const unsigned p, const unsigned n, - const float* const R1, const unsigned ldR1, - const float* const R2, const unsigned ldR2, - float* const M) - { - for (unsigned j=0; j<n; ++j) { - for (unsigned i=0; i<m; ++i) { - float d = S_ZERO; - unsigned ij = MAX(i,j); - for (unsigned l=ij; l<p; ++l) - d += R1[i+l*ldR1]*R2[j+l*ldR2]; - M[i+j*m] = d; - } - } - } - // product of two upper triangular matrices M += R1 R2^T, R1 mxp, R2 nxp - inline void utrmmha(const unsigned m, const unsigned p, const unsigned n, - const double* const R1, const unsigned ldR1, - const double* const R2, const unsigned ldR2, - double* const M) - { - for(unsigned l=0; l<p; l++){ - for(unsigned j=p; j<n; j++){ - for(unsigned i=p; i<m; i++){ - M[i+j*m] += R1[i+l*ldR1]*R2[j+l*ldR2]; - } - } - } - } - inline void utrmmha(const unsigned m, const unsigned p, const unsigned n, - const float* const R1, const unsigned ldR1, - const float* const R2, const unsigned ldR2, - float* const M) - { - for(unsigned l=0; l<p; l++){ - for(unsigned j=p; j<n; j++){ - for(unsigned i=p; i<m; i++){ - M[i+j*m] += R1[i+l*ldR1]*R2[j+l*ldR2]; - } - } - } - } - // product of an upper triangular matrix U and a matrix A, A:=U A inline void utrgemm(unsigned m, unsigned n, double* U, unsigned ldU, double* A, unsigned ldA) @@ -1224,131 +986,6 @@ namespace blas A, &ldA); } - // A:=A U^H - inline void geutrmm(unsigned m, unsigned n, double* A, unsigned ldA, - double* U, unsigned ldU) - { - dtrmm_(JOB_STR+8, JOB_STR+5, JOB_STR+1, JOB_STR, &m, &n, &D_ONE, U, &ldU, - A, &ldA); - } - - // C += d A U^T, U upper triangular matrix in packed storage - inline void geputrmmh(double d, unsigned m, unsigned n, double* A, - double* U, double* C) - { - for (unsigned j=0; j<n; ++j) - for (unsigned l=j; l<n; ++l) { - double e = d*U[j+l*(l+1)/2]; - for (unsigned i=0; i<m; ++i) C[i+j*m] += e*A[i+l*m]; - } - } - - inline void geputrmmh(float d, unsigned m, unsigned n, float* A, - float* U, float* C) - { - for (unsigned j=0; j<n; ++j) - for (unsigned l=j; l<n; ++l) { - float e = d*U[j+l*(l+1)/2]; - for (unsigned i=0; i<m; ++i) C[i+j*m] += e*A[i+l*m]; - } - } - - // C += A U^T, U upper triangular matrix - inline void geutrTmm(unsigned m, unsigned n, double* U, unsigned ldU, - double* A, unsigned ldA) - { - dtrmm_(JOB_STR+8, JOB_STR+5, JOB_STR+1, JOB_STR, &m, &n, &D_ONE, U, &ldU, - A, &ldA); - } - - // product of two upper triangular matrices M = R1 R2^T, R1 mxp, R2 nxp - inline void utrmmh(unsigned m, unsigned p, unsigned n, double* R1, - unsigned ldR1, double* R2, unsigned ldR2, double* M) - { - for (unsigned j=0; j<n; ++j) { - for (unsigned i=0; i<m; ++i) { - double d = D_ZERO; - for (unsigned l=MAX(i,j); l<p; ++l) d += R1[i+l*ldR1] * R2[j+l*ldR2]; - M[i+j*m] = d; - } - } - } - inline void utrmmh(unsigned m, unsigned p, unsigned n, float* R1, - unsigned ldR1, float* R2, unsigned ldR2, float* M) - { - for (unsigned j=0; j<n; ++j) { - for (unsigned i=0; i<m; ++i) { - float d = S_ZERO; - for (unsigned l=MAX(i,j); l<p; ++l) d += R1[i+l*ldR1] * R2[j+l*ldR2]; - M[i+j*m] = d; - } - } - } - - // C += d U A, where U is upper triangular in packed storage - template<class T> - inline void putrgemm(T d, unsigned n, T* U, unsigned p, T* A, T* C) - { - for (unsigned j=0; j<p; ++j) { - for (unsigned l=0; l<n; ++l) { - T e = d * A[l+j*n]; - unsigned idl = l*(l+1)/2; - for (unsigned i=0; i<=l; ++i) C[i+j*n] += e * U[i+idl]; - } - } - } - - // A += d U L, where U is upper triangular in packed storage - // and L is lower triangular in packed storage - inline void putrltrmm(double d, unsigned n, double* U, double* L, - double* A) - { - unsigned* ip = new unsigned[n]; - for(unsigned i=0;i<n;i++) - ip[i]=L[((2*n-i+1)*i)/2]; - - for(unsigned j=0;j<n;j++){ - const unsigned ipj = ip[j]; - const unsigned idUj = (ipj*(ipj+1))/2; - unsigned idL = ((2*n-j+1)*j)/2; - for(unsigned i=0;i<=ipj;i++) - A[i]+=d*U[idUj+i]; - for(unsigned k=j+1;k<n;k++){ - const unsigned ipk = ip[k]; - const double t = d*L[++idL]; - const unsigned idUk = (ipk*(ipk+1))/2; - for(unsigned i=0;i<=ipk;i++) - A[i]+=U[idUk+i]*t; - } - A+=n; - } - delete [] ip; - } - - inline void putrltrmm(float d, unsigned n, float* U, float* L, - float* A) - { - unsigned* ip = new unsigned[n]; - for(unsigned i=0;i<n;i++) - ip[i]=L[((2*n-i+1)*i)/2]; - - for(unsigned j=0;j<n;j++){ - const unsigned ipj = ip[j]; - const unsigned idUj = (ipj*(ipj+1))/2; - unsigned idL = ((2*n-j+1)*j)/2; - for(unsigned i=0;i<=ipj;i++) - A[i]+=d*U[idUj+i]; - for(unsigned k=j+1;k<n;k++){ - const unsigned ipk = ip[k]; - const float t = d*L[++idL]; - const unsigned idUk = (ipk*(ipk+1))/2; - for(unsigned i=0;i<=ipk;i++) - A[i]+=U[idUk+i]*t; - } - A+=n; - } - delete [] ip; - } // A += d U U^H, where U is upper triangular in packed storage // only the upper triangular part of A is computed diff --git a/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h b/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h index 7fa2cf0ec399e71fde91f204068c74861a8f91a8..83da6ea682a0f50212568fc36155a0e2fd2f5544 100644 --- a/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h +++ b/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h @@ -71,12 +71,8 @@ public: void precondApply(double* x) const { - { - OPENMP_LOOP_TYPE k; -// #pragma omp parallel for - for (k=0; k<_n_rows; ++k) { - x[k] = _inv_diag[k]*x[k]; - } + for (unsigned k=0; k<_n_rows; ++k) { + x[k] = _inv_diag[k]*x[k]; } } diff --git a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReorderedOpenMP.h b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReorderedOpenMP.h index 02d743eda09edf9789d0d7edc14f52d4564711a1..dfe918483ab6c34364fd6755d536a5ab0a9c5bde 100644 --- a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReorderedOpenMP.h +++ b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReorderedOpenMP.h @@ -25,7 +25,7 @@ public: CRSMatrixReorderedOpenMP(unsigned n, unsigned *iA, unsigned *jA, double* A); virtual ~CRSMatrixReorderedOpenMP(); - virtual void amux(double d, double const * const x, double *y) const; + virtual void amux(double d, double const * const __restrict__ x, double *__restrict__ y) const; }; } diff --git a/MathLib/LinAlg/Sparse/amuxCRS.h b/MathLib/LinAlg/Sparse/amuxCRS.h index 0178b61f91eef26ed1bab448de48a410ef8a4c10..1e109e5f74065c3b5dccbf0fd298046c1d4b67d2 100644 --- a/MathLib/LinAlg/Sparse/amuxCRS.h +++ b/MathLib/LinAlg/Sparse/amuxCRS.h @@ -53,6 +53,10 @@ void amuxCRSParallelOpenMP (FP_TYPE a, unsigned n, FP_TYPE t; { #pragma omp parallel for private(i, j, t) +#ifdef WIN32 +#pragma warning ( push ) +#pragma warning ( disable: 4018 ) +#endif for (i = 0; i < n; i++) { const IDX_TYPE end(iA[i + 1]); t = A[iA[i]] * x[jA[iA[i]]]; @@ -62,6 +66,9 @@ void amuxCRSParallelOpenMP (FP_TYPE a, unsigned n, y[i] = t * a; } } +#ifdef WIN32 +#pragma warning ( pop ) +#endif } #endif diff --git a/MathLib/MathTools.h b/MathLib/MathTools.h index 6962364c684684da07460644d487a9c638dfe348..15adac659646e539415fbf1e7fa65142db2984a7 100644 --- a/MathLib/MathTools.h +++ b/MathLib/MathTools.h @@ -67,9 +67,16 @@ T scpr(T const * const v0, T const * const v1, unsigned n) OPENMP_LOOP_TYPE k; #pragma omp parallel for reduction (+:res) +#ifdef WIN32 +#pragma warning ( push ) +#pragma warning ( disable: 4018 ) +#endif for (k = 1; k<n; k++) { res += v0[k] * v1[k]; } +#ifdef WIN32 +#pragma warning ( pop ) +#endif #else for (std::size_t k(1); k < n; k++) res += v0[k] * v1[k]; @@ -111,6 +118,17 @@ T sqrDist(const MathLib::TemplatePoint<T>* p0, const MathLib::TemplatePoint<T>* /** squared dist between double arrays p0 and p1 (size of arrays is 3) */ double sqrDist(const double* p0, const double* p1); +/** Distance between points p0 and p1 in the maximum norm. */ +template <typename T> +T maxNormDist(const MathLib::TemplatePoint<T>* p0, const MathLib::TemplatePoint<T>* p1) +{ + const T x = fabs((*p1)[0] - (*p0)[0]); + const T y = fabs((*p1)[1] - (*p0)[1]); + const T z = fabs((*p1)[2] - (*p0)[2]); + + return std::max(x, std::max(y, z)); +} + /** linear normalisation of val from [min, max] into [0,1] */ float normalize(float min, float max, float val); diff --git a/Tests/GeoLib/TestAABB.cpp b/Tests/GeoLib/TestAABB.cpp index 894e3582a6598621873fb45bec60520ffc4fb10e..aba72762250f58e0058514b4c7751b9b8e259c9d 100644 --- a/Tests/GeoLib/TestAABB.cpp +++ b/Tests/GeoLib/TestAABB.cpp @@ -27,7 +27,7 @@ TEST(GeoLibAABB, RandomNumberOfPointersToRandomPoints) { /* initialize random seed: */ - srand ( time(NULL) ); + srand ( static_cast<unsigned>(time(NULL)) ); int n (rand() % 100000); int box_size (rand()); int half_box_size(box_size/2); @@ -60,7 +60,7 @@ TEST(GeoLibAABB, RandomNumberOfPointersToRandomPoints) TEST(GeoLibAABB, RandomNumberOfPointsRandomPointInAList) { /* initialize random seed: */ - srand ( time(NULL) ); + srand ( static_cast<unsigned>(time(NULL)) ); int n (rand() % 1000000); int box_size (rand()); int half_box_size(box_size/2); @@ -89,7 +89,7 @@ TEST(GeoLibAABB, RandomNumberOfPointsRandomPointInAList) TEST(GeoLibAABB, RandomNumberOfPointersToRandomPointsInAVector) { /* initialize random seed: */ - srand ( time(NULL) ); + srand ( static_cast<unsigned>(time(NULL)) ); int n (rand() % 100000); int box_size (rand()); int half_box_size(box_size/2); @@ -122,7 +122,7 @@ TEST(GeoLibAABB, RandomNumberOfPointersToRandomPointsInAVector) TEST(GeoLibAABB, RandomNumberOfPointsRandomPointInAVector) { /* initialize random seed: */ - srand ( time(NULL) ); + srand ( static_cast<unsigned>(time(NULL)) ); int n (rand() % 1000000); int box_size (rand()); int half_box_size(box_size/2); @@ -151,7 +151,7 @@ TEST(GeoLibAABB, RandomNumberOfPointsRandomPointInAVector) TEST(GeoLibAABB, RandomNumberOfPointsRandomBox) { /* initialize random seed: */ - srand (time(NULL)); + srand (static_cast<unsigned>(time(NULL))); int n (rand() % 1000000); int box_size_x (rand()); int box_size_y (rand()); diff --git a/Tests/GeoLib/TestPoint.cpp b/Tests/GeoLib/TestPoint.cpp index 6917083993508d382884fd46b5fb0a9140f4f8d1..a90bfc73f6336171d810d28df90f766f288df1f1 100644 --- a/Tests/GeoLib/TestPoint.cpp +++ b/Tests/GeoLib/TestPoint.cpp @@ -120,7 +120,7 @@ TEST(GeoLib, PointComparisonOperatorLessEq) ASSERT_FALSE(Point(1.0,1.0,1.0) <= Point(1.0,1.0,1.0-my_eps)); std::size_t n(10000); - srand ( time(NULL) ); + srand ( static_cast<unsigned>(time(NULL)) ); for (std::size_t k(0); k<n; ++k) { double random_val_x(((double)(rand()) / RAND_MAX - 0.5)); //real_dist(rng)); double random_val_y(((double)(rand()) / RAND_MAX - 0.5)); //real_dist(rng)); diff --git a/Tests/GeoLib/TestPointVec.cpp b/Tests/GeoLib/TestPointVec.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ae15d0e8993fd526ac9cfc75b2753cb49e85b7be --- /dev/null +++ b/Tests/GeoLib/TestPointVec.cpp @@ -0,0 +1,132 @@ +/** + * \copyright + * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/LICENSE.txt + */ + +#include "gtest/gtest.h" +#include <ctime> +#include <random> + +#include "GeoLib/PointVec.h" + +class PointVecTest : public testing::Test +{ +public: + typedef std::vector<GeoLib::Point*> VectorOfPoints; + + PointVecTest() + : gen(std::random_device() ()), name("JustAName") + { + ps_ptr = new VectorOfPoints; + } + +protected: + // Generates n new points according to given random number distribution, + // which is uniform distribution in [-1, 1]^3. + template <typename RandomDistribution = std::uniform_real_distribution<double>> + void + generateRandomPoints(std::size_t const n = 1000, + RandomDistribution rnd = std::uniform_real_distribution<double>(-1, 1)) + { + std::generate_n(std::back_inserter(*ps_ptr), n, + [&]() { return new GeoLib::Point(rnd(gen), rnd(gen), rnd(gen)); }); + } + +protected: + std::mt19937 gen; + const std::string name; + + VectorOfPoints* ps_ptr; +}; + +// Testing nullptr input vector. +TEST_F(PointVecTest, TestPointVecCtorNullptr) +{ + ASSERT_ANY_THROW(GeoLib::PointVec(name, nullptr)); + delete ps_ptr; +} + +// Testing empty input vector. +TEST_F(PointVecTest, TestPointVecCtorEmpty) +{ + ASSERT_ANY_THROW(GeoLib::PointVec(name, ps_ptr)); +} + +// Testing input vector with single point. +TEST_F(PointVecTest, TestPointVecCtorSinglePoint) +{ + ps_ptr->push_back(new GeoLib::Point(0,0,0)); + GeoLib::PointVec* point_vec = nullptr; + ASSERT_NO_THROW(point_vec = new GeoLib::PointVec(name, ps_ptr)); + ASSERT_EQ(std::size_t(1), point_vec->size()); + + delete point_vec; +} + +// Testing input vector with two different points. +TEST_F(PointVecTest, TestPointVecCtorTwoDiffPoints) +{ + ps_ptr->push_back(new GeoLib::Point(0,0,0)); + ps_ptr->push_back(new GeoLib::Point(1,0,0)); + + GeoLib::PointVec* point_vec = nullptr; + ASSERT_NO_THROW(point_vec = new GeoLib::PointVec(name, ps_ptr)); + ASSERT_EQ(std::size_t(2), point_vec->size()); + + delete point_vec; +} + +// Testing input vector with two equal points. +TEST_F(PointVecTest, TestPointVecCtorTwoEqualPoints) +{ + ps_ptr->push_back(new GeoLib::Point(0,0,0)); + ps_ptr->push_back(new GeoLib::Point(0,0,0)); + + GeoLib::PointVec* point_vec = nullptr; + ASSERT_NO_THROW(point_vec = new GeoLib::PointVec(name, ps_ptr)); + ASSERT_EQ(std::size_t(1), point_vec->size()); + + delete point_vec; +} + +// Testing input vector with single point. +TEST_F(PointVecTest, TestPointVecPushBack) +{ + ps_ptr->push_back(new GeoLib::Point(0,0,0)); + ps_ptr->push_back(new GeoLib::Point(1,0,0)); + ps_ptr->push_back(new GeoLib::Point(0,1,0)); + ps_ptr->push_back(new GeoLib::Point(0,0,1)); + GeoLib::PointVec point_vec(name, ps_ptr); + + // Adding a new point with same coordinates changes nothing. + point_vec.push_back(new GeoLib::Point(0,0,0)); + point_vec.push_back(new GeoLib::Point(1,0,0)); + point_vec.push_back(new GeoLib::Point(0,1,0)); + point_vec.push_back(new GeoLib::Point(0,0,1)); + + ASSERT_EQ(std::size_t(4), point_vec.size()); +} + +// Testing random input points. +TEST_F(PointVecTest, TestPointVecCtorRandomPoints) +{ + generateRandomPoints(10000); + + GeoLib::PointVec* point_vec = nullptr; + ASSERT_NO_THROW(point_vec = new GeoLib::PointVec(name, ps_ptr)); + + delete point_vec; +} +TEST_F(PointVecTest, TestPointVecCtorRandomPointsLargeEps) +{ + generateRandomPoints(10000); + + GeoLib::PointVec* point_vec = nullptr; + ASSERT_NO_THROW(point_vec = new GeoLib::PointVec(name, ps_ptr, + nullptr, GeoLib::PointVec::POINT, 1e-2)); + + delete point_vec; +} diff --git a/Tests/GeoLib/TestPolyline.cpp b/Tests/GeoLib/TestPolyline.cpp index 91ac9d87b994896a5802d5d007e3d34db7f37728..0bd45ddbdffc0a44657945e24103a438887b2296 100644 --- a/Tests/GeoLib/TestPolyline.cpp +++ b/Tests/GeoLib/TestPolyline.cpp @@ -23,7 +23,7 @@ TEST(GeoLib, PolylineTest) Polyline ply(ply_pnts); // checking properties of empty polyline - ASSERT_EQ(ply.getNumberOfPoints(), 0); + ASSERT_EQ(std::size_t(0), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_FALSE(ply.isPointIDInPolyline(0)); ASSERT_EQ(ply.getLength(0), 0.0); @@ -31,7 +31,7 @@ TEST(GeoLib, PolylineTest) ply_pnts.push_back(new Point(0.0, 0.0, 0.0)); ply.addPoint(0); // checking properties of polyline with one point - ASSERT_EQ(ply.getNumberOfPoints(), 1); + ASSERT_EQ(std::size_t(1), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_TRUE(ply.isPointIDInPolyline(0)); ASSERT_EQ(ply.getLength(0), 0.0); @@ -39,7 +39,7 @@ TEST(GeoLib, PolylineTest) ply_pnts.push_back(new Point(1.0, 0.0, 0.0)); ply.addPoint(1); // checking properties of polyline with two points - ASSERT_EQ(ply.getNumberOfPoints(), 2); + ASSERT_EQ(std::size_t(2), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_TRUE(ply.isPointIDInPolyline(1)); ASSERT_EQ(ply.getLength(1), 1); @@ -47,21 +47,21 @@ TEST(GeoLib, PolylineTest) // checking properties of polyline with two points ply_pnts.push_back(new Point(0.5, 0.5, 0.0)); ply.addPoint(2); - ASSERT_EQ(ply.getNumberOfPoints(), 3); + ASSERT_EQ(std::size_t(3), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_TRUE(ply.isPointIDInPolyline(2)); ASSERT_TRUE(fabs(ply.getLength(2) - (1.0 + sqrt(0.5))) < std::numeric_limits<double>::min()); // checking remove ply.removePoint(1); - ASSERT_EQ(ply.getNumberOfPoints(), 2); + ASSERT_EQ(std::size_t(2), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_FALSE(ply.isPointIDInPolyline(1)); ASSERT_TRUE(fabs(ply.getLength(1) - sqrt(0.5)) < std::numeric_limits<double>::min()); // inserting point in the middle ply.insertPoint(1,1); - ASSERT_EQ(ply.getNumberOfPoints(), 3); + ASSERT_EQ(std::size_t(3), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_TRUE(ply.isPointIDInPolyline(2)); ASSERT_TRUE(fabs(ply.getLength(2) - (1.0 + sqrt(0.5))) < std::numeric_limits<double>::epsilon()); @@ -69,7 +69,7 @@ TEST(GeoLib, PolylineTest) // inserting point at the end ply_pnts.push_back(new GeoLib::Point(1.0, 0.5, 0.0)); ply.insertPoint(3,3); - ASSERT_EQ(ply.getNumberOfPoints(), 4); + ASSERT_EQ(std::size_t(4), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_TRUE(ply.isPointIDInPolyline(3)); ASSERT_TRUE(fabs(ply.getLength(3) - (1.0 + sqrt(0.5) + 0.5)) < std::numeric_limits<double>::epsilon()); @@ -77,7 +77,7 @@ TEST(GeoLib, PolylineTest) // inserting point at the beginning ply_pnts.push_back(new GeoLib::Point(-1.0, 0.0, 0.0)); ply.insertPoint(0,4); - ASSERT_EQ(ply.getNumberOfPoints(), 5); + ASSERT_EQ(std::size_t(5), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_TRUE(ply.isPointIDInPolyline(4)); ASSERT_TRUE(fabs(ply.getLength(4) - (1.0 + 1.0 + sqrt(0.5) + 0.5)) < @@ -86,19 +86,19 @@ TEST(GeoLib, PolylineTest) // inserting point in the middle ply_pnts.push_back(new GeoLib::Point(0.0, 0.5, 0.0)); ply.insertPoint(2,5); - ASSERT_EQ(ply.getNumberOfPoints(), 6); + ASSERT_EQ(std::size_t(6), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ASSERT_TRUE(ply.isPointIDInPolyline(5)); ASSERT_TRUE(fabs(ply.getLength(5) - (1.0 + 0.5 + sqrt(1.25) + sqrt(0.5) + 0.5)) < std::numeric_limits<double>::epsilon()); // close polyline ply.closePolyline(); - ASSERT_EQ(ply.getNumberOfPoints(), 7); + ASSERT_EQ(std::size_t(7), ply.getNumberOfPoints()); ASSERT_TRUE(ply.isClosed()); // remove last point -> polyline is not closed! ply.removePoint(6); - ASSERT_EQ(ply.getNumberOfPoints(), 6); + ASSERT_EQ(std::size_t(6), ply.getNumberOfPoints()); ASSERT_FALSE(ply.isClosed()); ply.closePolyline(); ASSERT_TRUE(ply.isClosed()); diff --git a/scripts/cmake/ExternalProjectBoost.cmake b/scripts/cmake/ExternalProjectBoost.cmake index ef60e82f6d852e186bfcec822d378776c2cf1eb4..40e1b3b8f299eb61637e66ff77a4fc36965dcfad 100644 --- a/scripts/cmake/ExternalProjectBoost.cmake +++ b/scripts/cmake/ExternalProjectBoost.cmake @@ -35,7 +35,7 @@ IF(NOT Boost_INCLUDE_DIRS) IF(IS_DIRECTORY /opt/boxen) SET(BOOST_ROOT /opt/boxen/homebrew) ENDIF() - FIND_PACKAGE(Boost 1.48.0 COMPONENTS ${BOOST_LIBS_TO_BUILD}) + FIND_PACKAGE(Boost 1.46.0 COMPONENTS ${BOOST_LIBS_TO_BUILD}) IF(Boost_FOUND) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) RETURN() diff --git a/scripts/docs/Doxyfile.in b/scripts/docs/Doxyfile.in index cc8644da3376dad3e2d5c2f0b435b048012df916..2133d9432b05184ecab9a584ca2b3c64a452e561 100644 --- a/scripts/docs/Doxyfile.in +++ b/scripts/docs/Doxyfile.in @@ -679,7 +679,8 @@ INPUT = ${CMAKE_SOURCE_DIR}/BaseLib \ ${CMAKE_SOURCE_DIR}/MeshLib \ ${CMAKE_SOURCE_DIR}/Gui \ ${CMAKE_SOURCE_DIR}/README.md \ - ${CMAKE_SOURCE_DIR}/SimpleTests + ${CMAKE_SOURCE_DIR}/SimpleTests \ + ${CMAKE_SOURCE_DIR}/Utils # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is