Closed temaltba closed 3 years ago
When the first argument to amen_cross is a cell array of tt_tensors, the function in the second argument is passed a matrix, where each column contains samples from the corresponding tt_tensor from the cell. So if we call something like tt = amen_cross({x,y,z},fun,1e-10,'y0',x,'nswp',20); the handle fun is still passed exactly one argument, which is a matrix S = [x(J), y(J), z(J)]. (Where J are some indices.) To assemble zexp(x/z) + y the handle should look like fun = @(S) S(:,3) . exp( S(:,1) ./ S(:,3) ) + S(:,2); % note that all products and divisions are elementwise!
Since TT-Toolbox works on discrete tensors, there is no such things as "coarse" or "refined" grids. If course, you can associate those to particular tensors in your particular problem, but general interfaces to TT-Toolbox functions should be the same.
There are helper functions to construct tensors of grid points though, you may look at the Matlab's own function meshgrid and the TT-Toolbox function tt_meshgrid_vert. The latter returns a cell array of tt_tensors compatible with amen_cross.
Great, this is very helpful. Thanks!
Could you provide an example or two of using amen_cross() for multivariate/high-dimensional function evaluation. I'm new to the toolbox (and Matlab) and I can't quite figure out the right syntax.
I was able to replicate the 1D function example from the quick_start guide, i.e. evaluating f(x) = sqrt(x) on a refined grid:
I also was able to calculate the sum of two tensors via
However, I'm having issues/errors when things are multivariate and nonlinear and/or multiplied. For example, could you provide the syntax for computing the function f(x,y,z) = z*exp(x/z) + y using amen_cross(), possibly on both coarse and refined grids? I just made this function up and chose it since it has nonlinear composition, addition, multiplication, and division.