Commit cc193bfa authored by Sebastian Wolf's avatar Sebastian Wolf

Work on UQ adf

parent 080e222b
Pipeline #675 failed with stages
in 4 minutes and 42 seconds
......@@ -47,31 +47,54 @@ namespace xerus {
}
void uq_adf(TTTensor& _x, const std::vector<std::vector<double>>& _randomVariables, const std::vector<Tensor>& _solutions, const size_t _polyDegree) {
REQUIRE(_randomVariables.size() == _solutions.size(), "ERROR");
const size_t N = _randomVariables.size();
const size_t d = _x.degree();
Tensor one = Tensor::ones({1});
std::vector<std::vector<Tensor>> leftStack(d, std::vector<Tensor>(N));
std::vector<std::vector<Tensor>> rightStack(d, std::vector<Tensor>(N));
std::vector<std::vector<Tensor>> leftStack(d, std::vector<Tensor>(N)); // From corePosition 1 to d-2
std::vector<std::vector<Tensor>> rightStack(d, std::vector<Tensor>(N)); // From corePosition 1 to d-1
std::vector<Tensor> Ax;
// Rebuild right Stack
for(size_t corePosition = _x.degree()-1; corePosition > 2; --corePosition) {
LOG(bug, "Rebuild right stack");
for(size_t corePosition = _x.degree()-1; corePosition > 1; --corePosition) {
LOG(bug, "corePosition: " << corePosition);
Tensor tmp;
const Tensor shuffledX = reshuffle(_x.get_component(corePosition), {1, 0, 2});
for(size_t j = 0; j < N; ++j) {
contract(tmp, randVar_to_position(_randomVariables[j][corePosition] ,_polyDegree), _x.get_component(corePosition-1), 1);
contract(rightStack[corePosition-1][j], rightStack[corePosition-2][j], tmp, 1);
// LOG(bug, randVar_to_position(_randomVariables[j][corePosition] ,_polyDegree).dimensions << " vs " << shuffledX.dimensions);
contract(tmp, randVar_to_position(_randomVariables[j][corePosition] ,_polyDegree), shuffledX, 1);
if(corePosition < d-1) {
// LOG(bug, rightStack[corePosition+1][j].dimensions << " vs " << tmp.dimensions);
contract(rightStack[corePosition][j], tmp, rightStack[corePosition+1][j], 1);
} else {
// LOG(bug, one.dimensions << " vs " << tmp.dimensions);
contract(rightStack[corePosition][j], tmp, one, 1);
}
}
}
for(size_t corePosition = 1; corePosition < _x.degree(); ++corePosition) {
LOG(bug, "Rebuild left stack @ " << corePosition);
Tensor tmp;
const Tensor shuffledX = reshuffle(_x.get_component(corePosition), {1, 0, 2});
for(size_t j = 0; j < N; ++j) {
contract(tmp, _x.get_component(corePosition-1), randVar_to_position(_randomVariables[j][corePosition] ,_polyDegree), 1);
contract(leftStack[corePosition-1][j], leftStack[corePosition-2][j], tmp, 1);
contract(tmp, randVar_to_position(_randomVariables[j][corePosition], _polyDegree), shuffledX, 1);
if(corePosition > 1) {
contract(leftStack[corePosition][j], leftStack[corePosition-1][j], tmp, 1);
} else if(corePosition==1) {
leftStack[corePosition][j] = tmp;
}
}
}
......
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