Commit c05c4992 authored by Sebastian Wolf's avatar Sebastian Wolf

Work on UQ ADF

parent 3cfb503f
Pipeline #683 failed with stages
in 3 minutes and 45 seconds
......@@ -49,24 +49,12 @@ namespace xerus {
void add_initial(const std::vector<double>& _rndvec, const Tensor& _solution);
};
class UQAvgSet {
public:
std::vector<std::vector<double>> randomVectors;
UQAvgSet() = default;
UQAvgSet(const UQAvgSet& _other) = default;
UQAvgSet( UQAvgSet&& _other) = default;
void add(const std::vector<double>& _rndvec);
Tensor avg(const TTTensor& _x) const;
};
void uq_adf(TTTensor& _x, const std::vector<std::vector<double>>& _randomVariables, const std::vector<Tensor>& _solutions);
void uq_adf(TTTensor& _x, const UQMeasurementSet& _measurments);
Tensor uq_avg(const TTTensor& _x, const size_t _N);
}
......@@ -414,12 +414,9 @@ namespace xerus {
initialSolutions.push_back(_solution);
}
void UQAvgSet::add(const std::vector<double>& _rndvec) {
randomVectors.push_back(_rndvec);
}
Tensor UQAvgSet::avg(const TTTensor& _x) const {
const size_t N = 10000;
Tensor uq_avg(const TTTensor& _x, const size_t _N) {
Tensor realAvg({_x.dimensions[0]});
#pragma omp parallel
......@@ -429,7 +426,7 @@ namespace xerus {
Tensor avg({_x.dimensions[0]});
#pragma omp parallel for
for(size_t i = 0; i < N; ++i) {
for(size_t i = 0; i < _N; ++i) {
Tensor p = Tensor::ones({1});
for(size_t k = _x.degree()-1; k > 0; --k) {
contract(p, _x.get_component(k), p, 1);
......@@ -444,7 +441,7 @@ namespace xerus {
{ realAvg += avg; }
}
return realAvg/double(N);
return realAvg/double(_N);
}
} // namespace xerus
......@@ -533,7 +533,8 @@ BOOST_PYTHON_MODULE(xerus) {
} // closes TN_scope
variable_argument_member_to_tuple_wrapper("TensorNetwork.__call__", "TensorNetworkCallOperator");
// ------------------------------------------------------------- TTNetwork
// ------------------------------------------------------------- TTNetwork
VECTOR_TO_PY(TTTensor, "TTTensorVector");
class_<TTTensor, bases<TensorNetwork>>("TTTensor")
.def(init<const Tensor&, optional<value_t, size_t>>())
.def(init<const Tensor&, value_t, TensorNetwork::RankTuple>())
......@@ -995,11 +996,8 @@ BOOST_PYTHON_MODULE(xerus) {
.def("add_initial", &UQMeasurementSet::add_initial)
;
class_<UQAvgSet>("UQAvgSet")
.def(init<const UQAvgSet&>())
.def("add", &UQAvgSet::add)
.def("avg", &UQAvgSet::avg)
;
def("uq_avg", &uq_avg);
def("uq_adf", +[](TTTensor& _x, const UQMeasurementSet& _measurments) {
......
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