### updated build instructions

parent d000dfd7
 ... ... @@ -25,9 +25,7 @@ int main() { std::cout << "ttA ranks: " << ttA.ranks() << std::endl; // the right hand side of the equation both as Tensor and in (Q)TT format xerus::Tensor b({512}, []() { return 1.0; }); auto b = xerus::Tensor::ones({512}); b.reinterpret_dimensions(std::vector(9, 2)); xerus::TTTensor ttb(b); ... ... @@ -51,8 +49,5 @@ int main() { x(j^9) = b(i^9) / A(i^9, j^9); // and calculate the Frobenius norm of the difference // here i&0 denotes a multiindex large enough to fully index the respective tensors // the subtraction of different formats will default to Tensor subtraction such that // the TTTensor ttx will be evaluated to a Tensor prior to subtraction. std::cout << "error: " << frob_norm(x(i&0) - ttx(i&0)) << std::endl; std::cout << "error: " << frob_norm(x - xerus::Tensor(ttx)) << std::endl; }
 ... ... @@ -3,13 +3,13 @@ import xerus as xe # construct the stiffness matrix A using a fill function def A_fill(idx): if idx == idx : return 2 return 2.0 elif idx == idx+1 or idx+1 == idx : return -1 else return 0 return -1.0 else: return 0.0 A = xe.Tensor([512,512], A_fill) A = xe.Tensor.from_function([512,512], A_fill) # and dividing it by h^2 = multiplying it with N^2 A *= 512*512 ... ... @@ -17,13 +17,13 @@ A *= 512*512 # reinterpret the 512x512 tensor as a 2^18 tensor # and create (Q)TT decomposition of it A.reinterpret_dimensions([2,]*18) ttA = xe.TTTensor(A) ttA = xe.TTOperator(A) # and verify its rank print("ttA ranks:", ttA.ranks()) # the right hand side of the equation both as Tensor and in (Q)TT format b = xe.Tensor(, lambda: 1) b = xe.Tensor.ones() b.reinterpret_dimensions([2,]*9) ttb = xe.TTTensor(b) ... ... @@ -43,11 +43,8 @@ print("residual:", residual) # as an comparison solve the system exactly using the Tensor / operator x = xe.Tensor() x(j^9) = b(i^9) / A(i^9, j^9) x(j^9) << b(i^9) / A(i^9, j^9) # and calculate the Frobenius norm of the difference # here i&0 denotes a multiindex large enough to fully index the respective tensors # the subtraction of different formats will default to Tensor subtraction such that # the TTTensor ttx will be evaluated to a Tensor prior to subtraction. print("error:", xe.frob_norm(x(i&0) - ttx(i&0))) print("error:", xe.frob_norm(x - xe.Tensor(ttx)))
 ... ... @@ -42,7 +42,7 @@ def A_fill(idx): return 2 elif idx == idx+1 or idx+1 == idx : return -1 else else : return 0 A = xerus.Tensor([512,512], A_fill) ... ... @@ -72,7 +72,7 @@ xerus::TTOperator ttA(A); __tabsMid ~~~ python A.reinterpret_dimensions([2,]*18) ttA = xerus.TTTensor(A) ttA = xerus.TTOperator(A) ~~~ __tabsEnd ... ... @@ -95,16 +95,14 @@ As the generating function needs no index information, we create a `[]()->double __tabsStart ~~~ cpp xerus::Tensor b({512}, []() { return 1.0; }); auto b = xerus::Tensor::ones({512}); b.reinterpret_dimensions(std::vector(9, 2)); xerus::TTTensor ttb(b); ~~~ __tabsMid ~~~ python b = xerus.Tensor(, lambda: 1) b = xerus.Tensor.ones() b.reinterpret_dimensions([2,]*9) ttb = xerus.TTTensor(b) ... ... @@ -178,21 +176,20 @@ x(j^9) = b(i^9) / A(i^9, j^9); __tabsMid ~~~ python x = xerus.Tensor() x(j^9) = b(i^9) / A(i^9, j^9) x(j^9) << b(i^9) / A(i^9, j^9) ~~~ __tabsEnd In the comparison of this exact solution `x` and the ALS solution `ttx` the TTTensor will automatically be cast to a Tensor object to allow the subtraction. Here we can use another index shorthand: `i&0` which denotes a multiindex of large enough dimension to fully index the respective tensor object. In the comparison of this exact solution `x` and the ALS solution `ttx`, we have to decide whether we want to cast the TTTensor to a Tensor or vice versa to be able to subtract them. __tabsStart ~~~ cpp std::cout << "error: " << frob_norm(x(i&0) - ttx(i&0)) << std::endl; std::cout << "error: " << frob_norm(x - xerus::Tensor(ttx)) << std::endl; ~~~ __tabsMid ~~~ python print("error:", xerus.frob_norm(x(i&0) - ttx(i&0))) print("error:", xerus.frob_norm(x - xerus.Tensor(ttx))) ~~~ __tabsEnd ... ...