Commit 74770307 authored by Sebastian Wolf's avatar Sebastian Wolf

Merge branch 'development' of git:xerus/xerus into development

parents 04bf4652 92d59051
Pipeline #912 passed with stages
in 8 minutes and 58 seconds
......@@ -11,7 +11,7 @@ help:
\t\ttest \t\t -- Build and run the xerus unit tests.\n \
\t\tclean \t\t -- Remove all object, library and executable files.\n"
# ------------------------------------------------------------------------------------------------------
# Set the names of the resulting binary codes
# ------------------------------------------------------------------------------------------------------
......@@ -42,7 +42,7 @@ DEBUG += -DXERUS_VERSION_COMMIT=$(XERUS_COMMIT_V)
# ------------------------------------------------------------------------------------------------------
# Register source files for the xerus library
# Register source files for the xerus library
# ------------------------------------------------------------------------------------------------------
# Register the source files
......@@ -77,7 +77,7 @@ TEST_DEPS = $(TEST_SOURCES:%.cpp=build/.testObjects/%.d)
UNIT_TEST_OBJECTS = $(UNIT_TEST_SOURCES:%.cxx=build/.unitTestObjects/%.o)
UNIT_TEST_DEPS = $(UNIT_TEST_SOURCES:%.cxx=build/.unitTestObjects/%.d)
TUTORIALS = $(TUTORIAL_SOURCES:%.cpp=build/.tutorialObjects/%)
TUTORIALS = $(TUTORIAL_SOURCES:%.cpp=build/.tutorialObjects/%)
TUTORIAL_DEPS = $(TUTORIAL_SOURCES:%.cpp=build/.tutorialObjects/%.d)
......@@ -92,14 +92,14 @@ include makeIncludes/optimization.mk
# ------------------------------------------------------------------------------------------------------
# Set additional compiler options
# Set additional compiler options
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
# Convinience variables
# Convinience variables
# ------------------------------------------------------------------------------------------------------
# Small hack to get newlines...
......@@ -126,7 +126,7 @@ MINIMAL_DEPS = Makefile config.mk makeIncludes/general.mk makeIncludes/warnings.
# ------------------------------------------------------------------------------------------------------
# Make Rules
# Make Rules
# ------------------------------------------------------------------------------------------------------
opt:
......@@ -138,12 +138,12 @@ warn:
# Fake rule to create arbitary headers, to prevent errors if files are moved/renamed
%.h:
%.h:
ifdef BUILD_PYTHON_BINDINGS
shared: build/libxerus_misc.so build/libxerus.so build/xerus.so
else
shared: build/libxerus_misc.so build/libxerus.so
shared: build/libxerus_misc.so build/libxerus.so
endif
build/libxerus_misc.so: $(MINIMAL_DEPS) $(MISC_SOURCES)
......@@ -214,6 +214,11 @@ endif
$(TEST_NAME): $(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) $(BLAS_LIBRARIES) $(CALLSTACK_LIBS) -o $(TEST_NAME)
build/print_boost_version: src/print_boost_version.cpp
@$(CXX) -o $@ $<
printBoostVersion: build/print_boost_version
@build/print_boost_version
test: $(TEST_NAME)
./$(TEST_NAME) all
......@@ -242,13 +247,13 @@ benchmark: $(MINIMAL_DEPS) $(LOCAL_HEADERS) benchmark.cxx $(LIB_NAME_STATIC)
# Build rule for normal misc objects
build/.miscObjects/%.o: %.cpp $(MINIMAL_DEPS)
mkdir -p $(dir $@)
mkdir -p $(dir $@)
$(CXX) -I include $< -c $(FLAGS) -MMD -o $@
# Build rule for normal lib objects
build/.libObjects/%.o: %.cpp $(MINIMAL_DEPS)
mkdir -p $(dir $@)
mkdir -p $(dir $@)
$(CXX) -I include $< -c $(FLAGS) -MMD -o $@
......@@ -281,7 +286,7 @@ build/.tutorialObjects/%: %.cpp $(MINIMAL_DEPS) build/libxerus.a build/libxerus_
mkdir -p $(dir $@)
$(CXX) -I include $< build/libxerus.a build/libxerus_misc.a $(SUITESPARSE) $(LAPACK_LIBRARIES) $(BLAS_LIBRARIES) $(CALLSTACK_LIBS) $(FLAGS) -MMD -o $@
# Build rule for the preCompileHeader
build/.preCompileHeaders/xerus.h.gch: include/xerus.h $(MINIMAL_DEPS) .git/ORIG_HEAD
mkdir -p $(dir $@)
......
......@@ -5,18 +5,18 @@ subtitle: "a general purpose tensor library"
---
# Xerus
**master:** <a href="https://git.hemio.de/xerus/xerus/commits/master"><img alt="build status" src="https://git.hemio.de/xerus/xerus/badges/master/build.svg" /></a>
<a href="https://git.hemio.de/xerus/xerus/commits/master"><img alt="coverage report" src="https://git.hemio.de/xerus/xerus/badges/master/coverage.svg" /></a>
**master:** <a href="https://git.hemio.de/xerus/xerus/commits/master"><img alt="build status" src="https://git.hemio.de/xerus/xerus/badges/master/build.svg" /></a>
<a href="https://git.hemio.de/xerus/xerus/commits/master"><img alt="coverage report" src="https://git.hemio.de/xerus/xerus/badges/master/coverage.svg" /></a>
<a href="https://git.hemio.de/xerus/xerus/commits/master">
__breakFix1
{% include version.svp %}
__breakFix2
**development:** <a href="https://git.hemio.de/xerus/xerus/commits/development"><img alt="build status" src="https://git.hemio.de/xerus/xerus/badges/development/build.svg" /></a>
**development:** <a href="https://git.hemio.de/xerus/xerus/commits/development"><img alt="build status" src="https://git.hemio.de/xerus/xerus/badges/development/build.svg" /></a>
<a href="https://git.hemio.de/xerus/xerus/commits/development"><img alt="coverage report" src="https://git.hemio.de/xerus/xerus/badges/development/coverage.svg" /></a>
The `xerus` library is a general purpose library for numerical calculations with higher order tensors, Tensor-Train Decompositions / Matrix Product States and general Tensor Networks.
The focus of development was the simple usability and adaptibility to any setting that requires higher order tensors or decompositions thereof.
The focus of development was the simple usability and adaptibility to any setting that requires higher order tensors or decompositions thereof.
The key features include:
* Modern code and concepts incorporating many features of the `C++11` standard.
......@@ -31,7 +31,7 @@ The key features include:
## Getting Started
`xerus` can be obtained via [git](https://git.hemio.de/xerus/xerus) or as an archived download via the same link.
`xerus` can be obtained via [git](https://git.hemio.de/xerus/xerus) or as an archived download via the same link.
To build and install the library you might want to check our the [Building xerus](/building_xerus) guide.
Where to go from there depends on what you want to do with `xerus` and how you learn. You can quickly get a feeling for the library
......@@ -50,13 +50,13 @@ Should you have any problems with the library do not hesitate to contact us at [
The `xerus` library is published under the AGPL v3.0. With proper attribution you are thus allowed to freely use and modify the source code but if you distribute your software including the `xerus`
library (or you provide a service based on this library) you have to provide the full source code under a compatible licence. For more information see the [AGPL](http://www.gnu.org/licenses/agpl-3.0.html).
If this library proved useful in your scientific research we would be grateful for any contributions to the source code and citations. As there is no related article yet, a corresponding bibtex
If this library proved useful in your scientific research we would be grateful for any contributions to the source code and citations. As there is no related article yet, a corresponding bibtex
entry might look as follows
~~~
@Misc{xerus,
author = {Huber, Benjamin and Wolf, Sebastian},
title = {Xerus - A General Purpose Tensor Library},
howpublished = {\url{https://libxerus.org/}},
year = {2014--2017}
year = {2014--2018}
}
~~~
// Xerus - A General Purpose Tensor Library
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Xerus is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
//
// Xerus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with Xerus. If not, see <http://www.gnu.org/licenses/>.
//
// For further information on Xerus visit https://libXerus.org
// For further information on Xerus visit https://libXerus.org
// or contact us at contact@libXerus.org.
/**
......@@ -22,8 +22,9 @@
* @brief Header file for the call-stack functionality.
*/
#pragma once
#pragma once
#include <cstdint>
#include <string>
#include <utility>
......@@ -33,10 +34,10 @@ namespace xerus {
* @brief Returns a string representation of the current call-stack (excluding the function itself).
* @details Per default this uses the binutils library to get the following information:
* [address .section] filename:line (function)
* if all of these are available.
* if all of these are available.
*/
std::string get_call_stack();
/**
* @brief Returns the address range of the elf-section names @a _name as part of the executable / so file that contained @a _addr.
*/
......
# Sets: CXX, CALLSTACK_LIBS, LOCAL_HEADERS, LOCAL_HPP, TEST_HXX
# Uses: USE_CLANG,
# Modifies: DEBUG
# Uses: USE_CLANG
# Set Compiler used
ifneq (,$(findstring clang, $(CXX)))
......@@ -26,7 +27,7 @@ ifdef XERUS_NO_FANCY_CALLSTACK
CALLSTACK_LIBS =
DEBUG += -D XERUS_NO_FANCY_CALLSTACK
else
CALLSTACK_LIBS = -lbfd -liberty -lz -ldl
CALLSTACK_LIBS = -lbfd -liberty -lz -ldl
endif
......
#include <iostream>
#include <boost/version.hpp>
int main() {
std::cout << "Boost "
<< BOOST_VERSION / 100000 << "." // major version
<< BOOST_VERSION / 100 % 1000 << "." // minor version
<< BOOST_VERSION % 100 // patch level
<< std::endl;
return 0;
}
// Xerus - A General Purpose Tensor Library
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Xerus is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
//
// Xerus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with Xerus. If not, see <http://www.gnu.org/licenses/>.
//
// For further information on Xerus visit https://libXerus.org
// For further information on Xerus visit https://libXerus.org
// or contact us at contact@libXerus.org.
/**
* @file
* @brief Implementation of the ADF variants.
* @brief Implementation of the ADF variants.
*/
#include <xerus/applications/uqAdf.h>
......@@ -32,7 +32,7 @@
#include <boost/circular_buffer.hpp>
#ifdef _OPENMP
#include <omp.h>
#include <omp.h>
#endif
namespace xerus { namespace uq { namespace impl_uqRaAdf {
......@@ -201,7 +201,7 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
contract(tmp, positions[_position][j], shuffledX, 1);
contract(rightStack[_position][j], tmp, rightStack[_position+1][j], 1);
}
} else { // _corePosition == d-1
} else { // _position == d-1
shuffledX.reinterpret_dimensions({shuffledX.dimensions[0], shuffledX.dimensions[1]}); // Remove dangling 1-mode
#pragma omp parallel for
for(size_t j = 0; j < N; ++j) {
......@@ -464,61 +464,60 @@ namespace xerus { namespace uq { namespace impl_uqRaAdf {
finish(maxIterations);
}
};
}
void uq_adf(TTTensor& _x, const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const double _targetEps, const size_t _maxItr) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_x.dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
void uq_adf(TTTensor& _x, const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const double _targetEps, const size_t _maxItr) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_x.dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
impl_uqRaAdf::InternalSolver<1> solver(_x, _measurments, _basisType, _maxItr, _targetEps, 0.0);
solver.solve();
}
TTTensor uq_adf(const UQMeasurementSet& _initalMeasurments, const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const std::vector<size_t>& _dimensions, const double _targetEps, const size_t _maxItr) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
TTTensor x = initial_guess(sample_mean(_measurments.solutions), _initalMeasurments, _basisType, _dimensions);
impl_uqRaAdf::InternalSolver<1> solver(x, _measurments, _basisType, _maxItr, _targetEps, 0.0);
solver.solve();
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
TTTensor x = initial_guess(sample_mean(_measurments.solutions), _initalMeasurments, _basisType, _dimensions);
impl_uqRaAdf::InternalSolver<1> solver(x, _measurments, _basisType, _maxItr, _targetEps, 0.0);
solver.solve();
return x;
}
void uq_ra_adf(TTTensor& _x, const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const double _targetEps, const size_t _maxItr, const double _initalRankEps) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_x.dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
impl_uqRaAdf::InternalSolver<2> solver(_x, _measurments, _basisType, _maxItr, _targetEps, _initalRankEps);
solver.solve();
}
TTTensor uq_ra_adf(const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const std::vector<size_t>& _dimensions, const double _targetEps, const size_t _maxItr) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
LOG(UQ, "Calculating Average as start.");
}
void uq_ra_adf(TTTensor& _x, const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const double _targetEps, const size_t _maxItr, const double _initalRankEps) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_x.dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
impl_uqRaAdf::InternalSolver<2> solver(_x, _measurments, _basisType, _maxItr, _targetEps, _initalRankEps);
solver.solve();
}
TTTensor uq_ra_adf(const UQMeasurementSet& _measurments, const PolynomBasis _basisType, const std::vector<size_t>& _dimensions, const double _targetEps, const size_t _maxItr) {
REQUIRE(_measurments.parameterVectors.size() == _measurments.solutions.size(), "Invalid measurments");
REQUIRE(_dimensions.front() == _measurments.solutions.front().size, "Inconsitent spacial dimension");
LOG(UQ, "Calculating Average as start.");
TTTensor x(_dimensions);
Tensor mean = sample_mean(_measurments.solutions);
// Set mean
mean.reinterpret_dimensions({1, x.dimensions[0], 1});
x.set_component(0, mean);
for(size_t k = 1; k < x.degree(); ++k) {
x.set_component(k, Tensor::dirac({1, x.dimensions[k], 1}, 0));
}
x.assume_core_position(0);
impl_uqRaAdf::InternalSolver<2> solver(x, _measurments, _basisType, _maxItr, _targetEps, 1e-1);
solver.solve();
return x;
}
TTTensor x(_dimensions);
Tensor mean = sample_mean(_measurments.solutions);
// Set mean
mean.reinterpret_dimensions({1, x.dimensions[0], 1});
x.set_component(0, mean);
for(size_t k = 1; k < x.degree(); ++k) {
x.set_component(k, Tensor::dirac({1, x.dimensions[k], 1}, 0));
}
x.assume_core_position(0);
impl_uqRaAdf::InternalSolver<2> solver(x, _measurments, _basisType, _maxItr, _targetEps, 1e-1);
solver.solve();
return x;
}
}} // namespace uq | xerus
// Xerus - A General Purpose Tensor Library
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Copyright (C) 2014-2018 Benjamin Huber and Sebastian Wolf.
//
// Xerus is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
//
// Xerus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with Xerus. If not, see <http://www.gnu.org/licenses/>.
//
// For further information on Xerus visit https://libXerus.org
// For further information on Xerus visit https://libXerus.org
// or contact us at contact@libXerus.org.
/**
......@@ -24,34 +24,33 @@
#include "misc.h"
// TODO get_copy() wrapper in python correct manner
BOOST_PYTHON_MODULE(xerus) {
using namespace xerus;
import_array(); // for numpy
bool show_user_defined = true;
bool show_signatures = false;
docstring_options doc_options(show_user_defined, show_signatures);
// xerus version
scope().attr("VERSION_MAJOR") = VERSION_MAJOR;
scope().attr("VERSION_MINOR") = VERSION_MINOR;
scope().attr("VERSION_REVISION") = VERSION_REVISION;
scope().attr("VERSION_COMMIT") = VERSION_COMMIT;
VECTOR_TO_PY(size_t, "IntegerVector");
VECTOR_TO_PY(double, "DoubleVector");
expose_indexedTensors();
expose_factorizations();
expose_tensor();
expose_tensorNetwork();
expose_ttnetwork();
expose_leastSquaresAlgorithms();
// expose_recoveryAlgorithms();
expose_misc();
using namespace xerus;
import_array(); // for numpy
bool show_user_defined = true;
bool show_signatures = false;
docstring_options doc_options(show_user_defined, show_signatures);
// xerus version
scope().attr("VERSION_MAJOR") = VERSION_MAJOR;
scope().attr("VERSION_MINOR") = VERSION_MINOR;
scope().attr("VERSION_REVISION") = VERSION_REVISION;
scope().attr("VERSION_COMMIT") = VERSION_COMMIT;
VECTOR_TO_PY(size_t, "IntegerVector");
VECTOR_TO_PY(double, "DoubleVector");
expose_indexedTensors();
expose_factorizations();
expose_tensor();
expose_tensorNetwork();
expose_ttnetwork();
expose_leastSquaresAlgorithms();
expose_recoveryAlgorithms();
expose_misc();
}
This diff is collapsed.
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