Commit 8b1c1fe7 authored by Philipp  Trunschke's avatar Philipp Trunschke

Merge branch 'development' of git.hemio.de:xerus/xerus into development

parents e9843bd7 3c95be50
Pipeline #1336 passed with stages
in 17 minutes and 21 seconds
......@@ -5,14 +5,15 @@
# ------------------------------------------------------------------------------------------------------
help:
@printf "Possible make targets are:\n \
\t\tshared \t\t -- Build xerus as a shared library.\n \
\t\tstatic \t\t -- Build xerus as a static library.\n \
\t\tpython2 \t\t -- Build the xerus python2 wrappers.\n \
\t\tpython3 \t\t -- Build the xerus python3 wrappers.\n \
\t\tdoc \t\t -- Build the html documentation for the xerus library.\n \
\t\tversion \t -- Print the version of xerus.\n \
\t\tshared \t -- Build xerus as a shared library.\n \
\t\tstatic \t -- Build xerus as a static library.\n \
\t\tpython2 \t -- Build the xerus python2 wrappers.\n \
\t\tpython3 \t -- Build the xerus python3 wrappers.\n \
\t\tdoc \t -- Build the html documentation for the xerus library.\n \
\t\tinstall \t -- Install the shared library and header files (may require root).\n \
\t\ttest \t\t -- Build and run the xerus unit tests.\n \
\t\tclean \t\t -- Remove all object, library and executable files.\n"
\t\ttest \t -- Build and run the xerus unit tests.\n \
\t\tclean \t -- Remove all object, library and executable files.\n"
# ------------------------------------------------------------------------------------------------------
......@@ -162,7 +163,7 @@ check_declared = \
__check_declared = \
$(if $(filter undefined,$(origin $1)), \
$(error Undeclared $1$(if $2, ($2))$(if $(value @), \
required by target `$@' (variable may be empty but must be defined))))
required by target '$@' (variable may be empty but must be defined))))
# Check that a variable specified through the stem is defined and has
# a non-empty value, die with an error otherwise.
......@@ -282,8 +283,7 @@ install:
@printf "Cannot install xerus: INSTALL_LIB_PATH not set. Please set the path in config file.\n"
endif
$(TEST_NAME): $(MINIMAL_DEPS) $(UNIT_TEST_OBJECTS) $(TEST_OBJECTS) build/libxerus.a build/libxerus_misc.a
$(TEST_NAME): libxerus_misc_dependencies libxerus_dependencies $(MINIMAL_DEPS) $(UNIT_TEST_OBJECTS) $(TEST_OBJECTS) build/libxerus.a build/libxerus_misc.a
$(CXX) -D XERUS_UNITTEST $(FLAGS) $(UNIT_TEST_OBJECTS) $(TEST_OBJECTS) build/libxerus.a build/libxerus_misc.a $(SUITESPARSE) $(LAPACK_LIBRARIES) $(ARPACK_LIBRARIES) $(BLAS_LIBRARIES) $(BOOST_LIBS) $(CALLSTACK_LIBS) -o $(TEST_NAME)
build/print_boost_version: src/print_boost_version.cpp
......@@ -316,13 +316,16 @@ test: $(TEST_NAME)
endif
test_python2: build/libxerus.so build/python2/xerus.so
.PHONY: test_python2_dependencies
test_python2_dependencies:
@:$(call check_defined, PYTEST2, pytest executable)
test_python2: test_python2_dependencies build/libxerus.so build/python2/xerus.so
@PYTHONPATH=build/python2:${PYTHONPATH} LD_LIBRARY_PATH=build:${LD_LIBRARY_PATH} $(PYTEST2) src/pyTests
test_python3: build/libxerus.so build/python3/xerus.so
.PHONY: test_python3_dependencies
test_python3_dependencies:
@:$(call check_defined, PYTEST3, pytest executable)
test_python3: test_python3_dependencies build/libxerus.so build/python3/xerus.so
@PYTHONPATH=build/python3:${PYTHONPATH} LD_LIBRARY_PATH=build:${LD_LIBRARY_PATH} $(PYTEST3) src/pyTests
......@@ -342,7 +345,7 @@ clean:
make -C doc clean
version:
@echo $(VERSION)
@echo $(XERUS_MAJOR_V).$(XERUS_MINOR_V).$(XERUS_REVISION_V)
......
......@@ -27,6 +27,42 @@ E.g. to install all dependencies on a fedora system execute
dnf install gcc-c++ openblas-devel suitesparse-devel lapack-devel boost-devel binutils-devel
~~~
Or to install all dependencies for Ubuntu (tested for 18.04) execute:
~~~ bash
apt-get update
apt install make g++ libboost-all-dev binutils-dev libsuitesparse-dev libz-dev libiberty-dev libopenblas-dev liblapack-dev liblapacke-dev gfortran
~~~
To build the optional ARPACK extension, you need to install ARPACK and the c++ headers by hand. First clone the git project to an appropriate place, enter the project directory, configure the sources and make the library:
~~~ bash
git clone https://github.com/opencollab/arpack-ng.git
cd arpack-ng
apt-get install autoconf
sh bootstrap
./configure F77=gfortran --enable-icb
make
make check
~~~
You can add your own installation path with --prefix=<installation-path> for the configure command.
Unfortunately, the C wrapper is broken. You need to modify the file_exists arpack.hpp:
~~~ bash
cd ICB/
vi arpack.hpp
~~~
In arpack.hpp comment out all 4 instances of the function neupd.
After that, to install the packages type:
~~~ bash
make install
~~~
Once ARPACK is installed you need to modify the xerus config file. Just remove the hashtags in front of ARPACK_LIBRARIES and the addtional flag below:
~~~ bash
# (optional) Uncomment if needed, iterative eigenvalue solver ARPACK-ng, see https://github.com/opencollab/arpack-ng
ARPACK_LIBRARIES = -larpack
OTHER += -DARPACK_LIBRARIES
~~~
To build the python bindings you will furthermore need the python development headers, `numpy` as well as `boost-python` or
`boost-python3` depending on the python version you wish to use. E.g. for a fedora system and if you want to use python 2 simply execute
~~~ bash
......
......@@ -27,7 +27,16 @@
#include "../basic.h"
#include "../forwardDeclarations.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/circular_buffer.hpp>
#pragma GCC diagnostic pop
......
......@@ -56,26 +56,89 @@ namespace xerus {
* a seriously low level implementation of a critical part of an algorithm is required.
*/
namespace arpackWrapper {
///@brief: Solves Ax = lambda*x for x, this calls the Arpack Routine dsaupd
/**
* @brief: Solves Ax = lambda*x for x, this calls the Arpack Routine dsaupd, executes the Lanczos method
* @param _x on input can be start value for iterative scheme on output it is the eigenvector
* @param _A operator data as double array
* @param _ev on output contains the requested eigenvalue
* @param _k number of eigenvalues wanted
* @param _n dimension of the operator
* @param _resid work array for the algorithm,
* @param _maxiter number of maximal iterations, when reached will exit with error!
* @param _eps accuracy of the eigenvalue, highly influeces the number of iterations needed
* @param _ritzoption specifies if the smallest or largest eigenvalue is needed, values can be arpack::which::smallest_algebraic and arpack::which::largest_algebraic
* @param _info value which specifies if _x should be used as start vector or if the algorithm should be initialized randomly by the routine
*/
void solve_ev(double* const _x, const double* const _A, double* const _ev, const size_t _k, const size_t _n, double* const _resid, const size_t _maxiter, const double _eps, arpack::which const _ritz_option, int _info);
///@brief: Solves Ax = lambda*x for x, for the smallest _k eigenvalues
/**
* @brief: Solves Ax = lambda*x for x, for the smallest _k eigenvalues
* @param _x on input can be start value for iterative scheme on output it is the eigenvector
* @param _A operator data as double array
* @param _ev on output contains the requested eigenvalue
* @param _k number of eigenvalues wanted
* @param _n dimension of the operator
* @param _resid work array for the algorithm,
* @param _maxiter number of maximal iterations, when reached will exit with error!
* @param _eps accuracy of the eigenvalue, highly influeces the number of iterations needed
* @param _info value which specifies if _x should be used as start vector or if the algorithm should be initialized randomly by the routine
*/
void solve_ev_smallest(double* const _x, const double* const _A, double* const _ev, const size_t _k, const size_t _n, double* const _resid, const size_t _maxiter, const double _eps, int _info);
///@brief: Solves Ax = lambda*x for x, for the largest _k eigenvalues
/**
* @brief: Solves Ax = lambda*x for x, for the largest _k eigenvalues
* @param _x on input can be start value for iterative scheme on output it is the eigenvector
* @param _A operator data as double array
* @param _ev on output contains the requested eigenvalue
* @param _k number of eigenvalues wanted
* @param _n dimension of the operator
* @param _resid work array for the algorithm,
* @param _maxiter number of maximal iterations, when reached will exit with error!
* @param _eps accuracy of the eigenvalue, highly influeces the number of iterations needed
* @param _info value which specifies if _x should be used as start vector or if the algorithm should be initialized randomly by the routine
*/
void solve_ev_largest(double* const _x, const double* const _A, double* const _ev, const size_t _k, const size_t _n, double* const _resid, const size_t _maxiter, const double _eps, int _info);
//TODO check if this can be simplified!!
///@brief: Solves Ax = lambda*x for x, this calls the Arpack Routine dsaupd
/**
* @brief: Solves Ax = lambda*x for x, this calls the Arpack Routine dsaupd, executes the Lanczos method
* @param _x on input can be start value for iterative scheme on output it is the eigenvector
* @param _op operator data as a Tensor network
* @param _ev on output contains the requested eigenvalue
* @param _k number of eigenvalues wanted
* @param _n dimension of the operator
* @param _resid work array for the algorithm,
* @param _maxiter number of maximal iterations, when reached will exit with error!
* @param _eps accuracy of the eigenvalue, highly influeces the number of iterations needed
* @param _ritzoption specifies if the smallest or largest eigenvalue is needed, values can be arpack::which::smallest_algebraic and arpack::which::largest_algebraic
* @param _info value which specifies if _x should be used as start vector or if the algorithm should be initialized randomly by the routine
*/
void solve_ev_special(double* const _x, const TensorNetwork& _op, double* const _ev, const size_t _k, const size_t _n, double* const _resid, const size_t _maxiter, const double _eps, arpack::which const _ritz_option, int _info);
///@brief: Solves Ax = lambda*x for x, for the smallest _k eigenvalues, takes Tensor Network as Operator
/**
* @brief: Solves Ax = lambda*x for x, for the smallest _k eigenvalues
* @param _x on input can be start value for iterative scheme on output it is the eigenvector
* @param _op operator data as a Tensor network
* @param _ev on output contains the requested eigenvalue
* @param _k number of eigenvalues wanted
* @param _n dimension of the operator
* @param _resid work array for the algorithm,
* @param _maxiter number of maximal iterations, when reached will exit with error!
* @param _eps accuracy of the eigenvalue, highly influeces the number of iterations needed
* @param _info value which specifies if _x should be used as start vector or if the algorithm should be initialized randomly by the routine
*/
void solve_ev_smallest_special(double* const _x, const TensorNetwork& _op, double* const _ev, const size_t _k, const size_t _n, double* const _resid, const size_t _maxiter, const double _eps, int _info);
//@brief: Solves Ax = lambda*x for x, for the largest _k eigenvalues, takes Tensor Network as Operator
/**
* @brief: Solves Ax = lambda*x for x, for the largest _k eigenvalues
* @param _x on input can be start value for iterative scheme on output it is the eigenvector
* @param _op operator data as a Tensor network
* @param _ev on output contains the requested eigenvalue
* @param _k number of eigenvalues wanted
* @param _n dimension of the operator
* @param _resid work array for the algorithm,
* @param _maxiter number of maximal iterations, when reached will exit with error!
* @param _eps accuracy of the eigenvalue, highly influeces the number of iterations needed
* @param _info value which specifies if _x should be used as start vector or if the algorithm should be initialized randomly by the routine
*/
void solve_ev_largest_special(double* const _x, const TensorNetwork& _op, double* const _ev, const size_t _k, const size_t _n, double* const _resid, const size_t _maxiter, const double _eps, int _info);
}
}
#endif
......
......@@ -27,6 +27,7 @@
#include <set>
#include <string>
#include <fstream>
#include <vector>
// #include "standard.h"
......@@ -35,18 +36,27 @@ namespace xerus { namespace misc {
///@brief Creates all directories in the @a _path of the file, if needed.
void create_directories_for_file(const std::string& _path);
///@brief Returns a set containing all regular files at the given @a _path.
///@brief Returns a set containing all regular files present at the given @a _path.
std::set<std::string> get_files(const std::string& _path);
///@brief Returns a set containing all directories present at the given @a _path.
std::set<std::string> get_directories(const std::string& _path);
///@brief Checks whether a file at the given @a _path exists.
bool file_exists(const std::string& _path);
///@brief Checks whether a directory at the given @a _path exists.
bool directory_exists(const std::string& _path);
///@brief Checks whether a file at the given @a _path is empty.
bool file_is_empty(const std::string& _path);
///@brief Reads the complete content of the file at the given @a _path into a string.
std::string read_file(const std::string& _path);
///@brief Reads all lines of the file at the given @a _path into a vector of strings.
std::vector<std::string> read_file_lines(const std::string& _path);
/// @brief Resolves 'folder/..' occurences in pathnames.
std::string /*XERUS_warn_unused*/ normalize_pathname(const std::string& _name);
......
......@@ -37,6 +37,12 @@ namespace xerus {
return (T(0) < _value) - (_value < T(0));
}
///@brief: Calculates the absolute value of _value.
template<class T>
constexpr T abs(const T _value) noexcept {
return (_value < 0 ) ? -_value : _value;
}
///@brief: Calculates _a*_a.
template<class T>
......
......@@ -57,14 +57,14 @@ namespace xerus {
// If the LOG_BUFFER is active there is the additional option only to print the log if an error occurs.
#ifdef XERUS_LOG_BUFFER
enum {
enum LogLvl {
NOT_LOGGING = 0,
LOGGING_ON_ERROR = 1,
LOGGING_FULL = 2,
LOGGING_EXCEPTION = 3
};
#else
enum {
enum LogLvl {
NOT_LOGGING = 0,
LOGGING_FULL = 2,
LOGGING_EXCEPTION = 3
......
......@@ -30,7 +30,16 @@
#include <limits>
#include <functional>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/math/tools/polynomial.hpp>
#pragma GCC diagnostic pop
namespace xerus { namespace misc {
......
......@@ -37,7 +37,7 @@ endif
ifdef DEBUG_OPTIMIZATION
DEBUG += -D DEBUG_OPTIMIZATION
ifndef USE_CLANG
OPTIMIZE += -Og
OPTIMIZE += -Og -fno-inline -ggdb
endif
else ifdef HIGH_OPTIMIZATION
DEBUG += -D HIGH_OPTIMIZATION
......
......@@ -24,7 +24,16 @@
#include <xerus/algorithms/asd.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/circular_buffer.hpp>
#pragma GCC diagnostic pop
#include <xerus/misc/math.h>
#include <xerus/misc/basicArraySupport.h>
......
......@@ -28,8 +28,17 @@
#include <xerus/misc/basicArraySupport.h>
#include <xerus/misc/internal.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/math/special_functions/hermite.hpp>
#include <boost/math/special_functions/legendre.hpp>
#pragma GCC diagnostic pop
#ifdef _OPENMP
#include <omp.h>
......
......@@ -29,7 +29,16 @@
#include <xerus/misc/math.h>
#include <xerus/misc/internal.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/circular_buffer.hpp>
#pragma GCC diagnostic pop
#ifdef _OPENMP
#include <omp.h>
......
......@@ -644,10 +644,10 @@ namespace xerus {
lapackAnswer = LAPACKE_dpotrf2(
LAPACK_ROW_MAJOR,
'U', // Upper triangle of A is read
static_cast<int>(_n), // dimensions of A
tmpA.get(), // input: A, output: cholesky factorisation
static_cast<int>(_n) // LDA
'U', // Upper triangle of A is read
static_cast<int>(_n), // dimensions of A
tmpA.get(), // input: A, output: cholesky factorisation
static_cast<int>(_n) // LDA
);
XERUS_PA_END("Dense LAPACK", "Cholesky decomposition", misc::to_string(_n)+"x"+misc::to_string(_n));
......@@ -661,13 +661,13 @@ namespace xerus {
lapackAnswer = LAPACKE_dpotrs(
LAPACK_ROW_MAJOR,
'U', // upper triangle of cholesky decomp is stored in tmpA
static_cast<int>(_n), // dimensions of A
static_cast<int>(_nrhs),// number of rhs
tmpA.get(), // input: cholesky decomp
static_cast<int>(_n), // lda
_x, // input: rhs b, output: solution x
static_cast<int>(_nrhs) // ldb
'U', // upper triangle of cholesky decomp is stored in tmpA
static_cast<int>(_n), // dimensions of A
static_cast<int>(_nrhs), // number of rhs
tmpA.get(), // input: cholesky decomp
static_cast<int>(_n), // lda
_x, // input: rhs b, output: solution x
static_cast<int>(_nrhs) // ldb
);
CHECK(lapackAnswer == 0, error, "Unable to solve Ax = b (cholesky solver). Lapacke says: " << lapackAnswer);
......
......@@ -168,6 +168,7 @@ namespace xerus {
}
dimensions = _tensor.dimensions;
Tensor remains;
auto epsPerSite = numComp < 2 ? _eps : misc::hard_equal(_eps, 0.0) ? EPSILON : _eps / std::sqrt(double(2*numComp-3));
......@@ -213,7 +214,8 @@ namespace xerus {
xerus::reshuffle(remains, remains, ithmode);
calculate_svd(newNode, singularValues, remains, remains, N, _maxRanks[pos - 1], _eps);
calculate_svd(newNode, singularValues, remains, remains, N, _maxRanks[pos - 1], epsPerSite);
if (isOperator){
xerus::reshuffle(newNode, newNode, {1,2,0});
} else {
......@@ -247,7 +249,7 @@ namespace xerus {
}
xerus::reshuffle(remains, remains, ithmode);
calculate_svd(newNode, singularValues, remains, remains, 2, _maxRanks[numCompOnLvl + pos - 2], _eps); // TODO fix maxRanks
calculate_svd(newNode, singularValues, remains, remains, 2, _maxRanks[numCompOnLvl + pos - 2], epsPerSite); // TODO fix maxRanks
xerus::reshuffle(newNode, newNode, {1,2,0}); // first parent then children
set_component(numCompOnLvl + pos - 1, std::move(newNode));
newNode.reset();
......@@ -727,8 +729,12 @@ namespace xerus {
canonicalize_root();
for (size_t n = numComponents - 1; n > 0; --n) {
round_edge(n, (n + 1) / 2 - 1, _maxRanks[n - 1], _eps, 0.0);
if(numComponents > 1) {
auto epsPerSite = misc::hard_equal(_eps, 0.0) ? EPSILON : _eps / std::sqrt(double(2*numComponents-3)); // Taken from HIERARCHICAL SINGULAR VALUE DECOMPOSITION OF TENSORS
// from Lars Grasedyck
for (size_t n = numComponents - 1; n > 0; --n) {
round_edge(n, (n + 1) / 2 - 1, _maxRanks[n - 1], epsPerSite, 0.0);
}
}
assume_core_position(0);
......
......@@ -27,7 +27,16 @@
#include <xerus/misc/stringUtilities.h>
#include <fstream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#include <boost/filesystem.hpp>
#pragma GCC diagnostic pop
namespace xerus { namespace misc {
......@@ -38,6 +47,7 @@ namespace xerus { namespace misc {
}
}
std::set<std::string> get_files(const std::string& _path) {
REQUIRE(boost::filesystem::exists(_path) && boost::filesystem::is_directory(_path), "Invalid path " << _path << " (not an existing directory).");
std::set<std::string> files;
......@@ -51,7 +61,28 @@ namespace xerus { namespace misc {
return files;
}
std::set<std::string> get_directories(const std::string& _path) {
REQUIRE(boost::filesystem::exists(_path) && boost::filesystem::is_directory(_path), "Invalid path " << _path << " (not an existing directory).");
std::set<std::string> files;
for (boost::filesystem::directory_iterator itr(_path), end; itr != end; ++itr) {
if(!boost::filesystem::is_directory(itr->path())) { continue;}
const auto file = itr->path().filename().string();
files.emplace(file);
}
return files;
}
bool file_exists(const std::string& _path) {
REQUIRE(!boost::filesystem::exists(_path) || boost::filesystem::is_regular_file(_path), "Path '" << _path << "' exists but is not a regular file.");
return boost::filesystem::exists(_path);
}
bool directory_exists(const std::string& _path) {
REQUIRE(!boost::filesystem::exists(_path) || boost::filesystem::is_directory(_path), "Path '" << _path << "' exists but is not a directory.");
return boost::filesystem::exists(_path);
}
......@@ -63,7 +94,7 @@ namespace xerus { namespace misc {
std::string read_file(const std::string& _path) {
REQUIRE(boost::filesystem::exists(_path), "File " << _path << " does not exist.");
REQUIRE(file_exists(_path), "File " << _path << " does not exist.");
std::ifstream fileStream(_path, std::ifstream::in);
CHECK(fileStream.is_open() && !fileStream.fail(), error, "Could not properly (read) open the file " << _path);
......@@ -76,6 +107,22 @@ namespace xerus { namespace misc {
}
std::vector<std::string> read_file_lines(const std::string& _path) {
REQUIRE(file_exists(_path), "File " << _path << " does not exist.");
std::ifstream fileStream(_path, std::ifstream::in);
CHECK(fileStream.is_open() && !fileStream.fail(), error, "Could not properly (read) open the file " << _path);
std::vector<std::string> lines(1);
while(getline(fileStream, lines.back())) {
lines.emplace_back();
}
lines.pop_back();
return lines;
}
std::string normalize_pathname(const std::string &_name) {
std::vector<std::string> oldpath = explode(_name,'/');
std::vector<std::string *> newpath;
......
......@@ -44,14 +44,22 @@ namespace xerus {
std::vector<std::string> explode(const std::string& _string, const char _delim) {
std::vector<std::string> result;
std::istringstream iss(_string);
const std::string::size_type length = _string.length();
std::string::size_type pos, lastPos = 0;
std::string token;
while(std::getline(iss, token, _delim)) {
result.push_back(std::move(token));
}
while(lastPos < length + 1) {
pos = _string.find(_delim, lastPos);
if(pos == std::string::npos) { pos = length; }
if(pos != lastPos) {
result.emplace_back(_string, lastPos, pos-lastPos);
}
return result;
lastPos = pos + 1;
}
return result;
}
......
......@@ -22,10 +22,25 @@
* @brief Definition of common functions for the python bindings.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wundef"
#pragma GCC diagnostic ignored "-Wcast-qual"
#pragma GCC diagnostic ignored "-Wswitch-default"
#include <boost/function.hpp>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <boost/python/call.hpp>
#pragma GCC diagnostic pop
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuseless-cast"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment