Hello,I have a rather large number of expressions, which I must normalize. To increase performance I wanted to implement this on multiple threads. However, this always segfaults and I am having trouble to find out where my error is. Consider the following code:
```c++
// H is a 9x9 matrix
void norm_matrix(GiNaC::matrix& H) {
thread_pool tp = thread_pool();
auto n = 9;
std::vector<std::future<GiNaC::ex>> futures(n*n);
for(int r = 0; r < n; ++r) {
for(int c = 0; c < n; ++c) {
futures[r*n+c] = tp.submit(
[&h = H(r,c)] () -> GiNaC::ex {
return h.normal();
});
}
}
for(int r = 0; r < n; ++r) {
for(int c = 0; c < n; ++c) {
H(r,c) = futures[r*n+c].get();
}
}
}
```
At the second iterations on the call of h.normal(), this crashes with a segfault, both with a reference as well as with a copy. Has GiNaC been used in a multithreaded environment previously and has this error occured?
Kind regards
Spooky Ghost