Commit f27bc637 authored by Sebastian Wolf's avatar Sebastian Wolf

Rewrite of MeasurementSet

parent 49c753f2
Pipeline #1096 failed with stages
in 2 minutes and 8 seconds
......@@ -7,6 +7,9 @@ Potentially breaking changes are marked with an exclamation point '!' at the beg
* ! Changed the truncated SVD, TensorNetwork::round_edge and TT:round with epsilon to limit their respective relative errors to epsilon.
* ! Removed support for the replacement allocator.
* ! Changed some Makefile configs for more flexibility. See the new config.mk.default file and update your own config.
* ! Major rewrite of MeasurmentSets.
* Fixed minor rank reduction bug in TensorNetwork soft thresholding.
* 2017-05-31 v3.0.1
* Added TTNetwork::use_dense_representations() to convert all components to dense representation.
......
......@@ -71,8 +71,8 @@ XERUS_DEPS = $(XERUS_SOURCES:%.cpp=build/.libObjects/%.d)
MISC_OBJECTS = $(MISC_SOURCES:%.cpp=build/.miscObjects/%.o)
MISC_DEPS = $(MISC_SOURCES:%.cpp=build/.miscObjects/%.d)
PYTHON_OBJECTS = $(PYTHON_SOURCES:%.cpp=build/.pythonObjects/%.o)
PYTHON_DEPS = $(PYTHON_SOURCES:%.cpp=build/.pyhtonObjects/%.d)
# PYTHON_OBJECTS = $(PYTHON_SOURCES:%.cpp=build/.pythonObjects/%.o)
# PYTHON_DEPS = $(PYTHON_SOURCES:%.cpp=build/.pyhtonObjects/%.d)
TEST_OBJECTS = $(TEST_SOURCES:%.cpp=build/.testObjects/%.o)
TEST_DEPS = $(TEST_SOURCES:%.cpp=build/.testObjects/%.d)
......
......@@ -224,7 +224,7 @@ namespace xerus {
{
_x.require_correct_format();
XERUS_REQUIRE(numMeasurments > 0, "Need at very least one measurment.");
XERUS_REQUIRE(measurments.degree() == degree, "Measurment degree must coincide with x degree.");
XERUS_REQUIRE(measurments.order() == degree, "Measurment degree must coincide with x degree.");
}
};
......
This diff is collapsed.
......@@ -24,10 +24,12 @@
#include <xerus/algorithms/adf.h>
#include <xerus/indexedTensorMoveable.h>
#include <xerus/misc/math.h>
#include <xerus/misc/basicArraySupport.h>
#include <xerus/misc/internal.h>
#include <xerus/indexedTensorMoveable.h>
#ifdef _OPENMP
#include <omp.h>
#endif
......@@ -61,7 +63,7 @@ namespace xerus {
};
template<>
MeasurmentComparator<SinglePointMeasurementSet>::MeasurmentComparator(const SinglePointMeasurementSet& _measurments, const bool _forward) : forward(_forward), degree(_measurments.degree()), measurments(_measurments) { }
MeasurmentComparator<SinglePointMeasurementSet>::MeasurmentComparator(const SinglePointMeasurementSet& _measurments, const bool _forward) : forward(_forward), degree(_measurments.order()), measurments(_measurments) { }
template<>
bool MeasurmentComparator<SinglePointMeasurementSet>::operator()(const size_t _a, const size_t _b) const {
......@@ -82,19 +84,19 @@ namespace xerus {
template<>
MeasurmentComparator<RankOneMeasurementSet>::MeasurmentComparator(const RankOneMeasurementSet& _measurments, const bool _forward) : forward(_forward), degree(_measurments.degree()), measurments(_measurments) { }
MeasurmentComparator<RankOneMeasurementSet>::MeasurmentComparator(const RankOneMeasurementSet& _measurments, const bool _forward) : forward(_forward), degree(_measurments.order()), measurments(_measurments) { }
template<>
bool MeasurmentComparator<RankOneMeasurementSet>::operator()(const size_t _a, const size_t _b) const {
if(forward) {
for (size_t j = 0; j < degree; ++j) {
const int res = internal::comp(measurments.positions[_a][j], measurments.positions[_b][j]);
const int res = internal::compare(measurments.positions[_a][j], measurments.positions[_b][j]);
if(res == -1) { return true; }
if(res == 1) { return false; }
}
} else {
for (size_t j = degree; j > 0; --j) {
const int res = internal::comp(measurments.positions[_a][j-1], measurments.positions[_b][j-1]);
const int res = internal::compare(measurments.positions[_a][j-1], measurments.positions[_b][j-1]);
if(res == -1) { return true; }
if(res == 1) { return false; }
}
......@@ -578,7 +580,7 @@ namespace xerus {
inline void calc_measurment_norm<RankOneMeasurementSet>(double* _norms, const RankOneMeasurementSet& _measurments) {
for(size_t i = 0; i < _measurments.size(); ++i) {
_norms[i] = 1.0;
for(size_t j = 0; j < _measurments.degree(); ++j) {
for(size_t j = 0; j < _measurments.order(); ++j) {
_norms[i] *= _measurments.positions[i][j].frob_norm();
}
}
......
......@@ -23,11 +23,14 @@
*/
#include <xerus/algorithms/asd.h>
#include <xerus/blockTT.h>
#include <boost/circular_buffer.hpp>
#include <xerus/misc/math.h>
#include <xerus/misc/basicArraySupport.h>
#include <xerus/misc/internal.h>
#include <boost/circular_buffer.hpp>
#include <xerus/blockTT.h>
#ifdef _OPENMP
#include <omp.h>
......@@ -183,7 +186,7 @@ namespace xerus { namespace impl_TrASD {
{
_x.require_correct_format();
XERUS_REQUIRE(numMeasurments > 0, "Need at very least one measurment.");
XERUS_REQUIRE(measurments.degree() == degree, "Measurment degree must coincide with x degree.");
XERUS_REQUIRE(measurments.order() == degree, "Measurment degree must coincide with x degree.");
// Create test set
std::uniform_real_distribution<double> stochDist(0.0, 1.0);
......
......@@ -23,6 +23,9 @@
*/
#include <xerus/examples/tensorCompletion.h>
#include <xerus/misc/math.h>
#include <xerus/measurments.h>
namespace xerus {
......
This diff is collapsed.
......@@ -44,10 +44,16 @@ void expose_recoveryAlgorithms() {
.def("set_measuredValue", +[](SinglePointMeasurementSet &_this, size_t _i, value_t _val){
_this.measuredValues[_i] = _val;
})
.def("add", &SinglePointMeasurementSet::add)
// .def("add", &SinglePointMeasurementSet::add)
.def("add", +[](SinglePointMeasurementSet& _self, const std::vector<size_t>& _position, const value_t _measuredValue) {
_self.add(_position, _measuredValue);
})
.def("add", +[](SinglePointMeasurementSet& _self, const std::vector<size_t>& _position, const value_t _measuredValue, const value_t _weight) {
_self.add(_position, _measuredValue, _weight);
})
.def("size", &SinglePointMeasurementSet::size)
.def("degree", &SinglePointMeasurementSet::degree)
.def("frob_norm", &SinglePointMeasurementSet::frob_norm)
.def("order", &SinglePointMeasurementSet::order)
.def("norm_2", &SinglePointMeasurementSet::norm_2)
.def("sort", &SinglePointMeasurementSet::sort, arg("positionsOnly")=false)
.def("measure", static_cast<void (SinglePointMeasurementSet::*)(const Tensor &)>(&SinglePointMeasurementSet::measure), arg("solution"))
.def("measure", static_cast<void (SinglePointMeasurementSet::*)(const TensorNetwork &)>(&SinglePointMeasurementSet::measure), arg("solution"))
......@@ -97,17 +103,15 @@ void expose_recoveryAlgorithms() {
.def("set_measuredValue", +[](RankOneMeasurementSet &_this, size_t _i, value_t _val){
_this.measuredValues[_i] = _val;
})
/* void add(const std::vector<Tensor>& _position, const value_t _measuredValue); */
.def("add", +[](RankOneMeasurementSet& _self, const std::vector<Tensor>& _position, const value_t _measuredValue) {
_self.add(_position, _measuredValue);
})
/* void add(const std::vector<Tensor>& _position, const value_t _measuredValue, const value_t _weight); */
.def("add", +[](RankOneMeasurementSet& _self, const std::vector<Tensor>& _position, const value_t _measuredValue, const value_t _weight) {
_self.add(_position, _measuredValue, _weight);
})
.def("size", &RankOneMeasurementSet::size)
.def("degree", &RankOneMeasurementSet::degree)
.def("frob_norm", &RankOneMeasurementSet::frob_norm)
.def("order", &RankOneMeasurementSet::order)
.def("norm_2", &RankOneMeasurementSet::norm_2)
.def("sort", &RankOneMeasurementSet::sort, arg("positionsOnly")=false)
.def("normalize", &RankOneMeasurementSet::normalize)
.def("measure", static_cast<void (RankOneMeasurementSet::*)(const Tensor &)>(&RankOneMeasurementSet::measure), arg("solution"))
......
......@@ -67,11 +67,11 @@ void expose_ttnetwork() {
)
.def("round", static_cast<void (TTTensor::*)(double)>(&TTTensor::round))
.def("round", static_cast<void (TTTensor::*)(size_t)>(&TTTensor::round))
.def("soft_threshold", static_cast<void (TTTensor::*)(const double, const bool)>(&TTTensor::soft_threshold),
(arg("tau"), arg("preventZero")=false)
.def("soft_threshold", static_cast<void (TTTensor::*)(const double)>(&TTTensor::soft_threshold),
(arg("tau"))
)
.def("soft_threshold", static_cast<void (TTTensor::*)(const std::vector<double>&, const bool)>(&TTTensor::soft_threshold),
(arg("tau"), arg("preventZero")=false)
.def("soft_threshold", static_cast<void (TTTensor::*)(const std::vector<double>&)>(&TTTensor::soft_threshold),
(arg("tau"))
)
.def("move_core", &TTTensor::move_core,
......@@ -131,11 +131,11 @@ void expose_ttnetwork() {
)
.def("round", static_cast<void (TTOperator::*)(double)>(&TTOperator::round))
.def("round", static_cast<void (TTOperator::*)(size_t)>(&TTOperator::round))
.def("soft_threshold", static_cast<void (TTOperator::*)(const double, const bool)>(&TTOperator::soft_threshold),
(arg("tau"), arg("preventZero")=false)
.def("soft_threshold", static_cast<void (TTOperator::*)(const double)>(&TTOperator::soft_threshold),
(arg("tau"))
)
.def("soft_threshold", static_cast<void (TTOperator::*)(const std::vector<double>&, const bool)>(&TTOperator::soft_threshold),
(arg("tau"), arg("preventZero")=false)
.def("soft_threshold", static_cast<void (TTOperator::*)(const std::vector<double>&)>(&TTOperator::soft_threshold),
(arg("tau"))
)
.def("move_core", &TTOperator::move_core,
......
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