35. Tensor utilities
The namespace rise.engine.numerics.kronecker contains products and shifted
solves that avoid constructing the full Kronecker matrix. Their numerical
values agree with the corresponding small explicit products; a sparse result
need not have the same storage representation as a dense reference.
A_times_B_kron_C(A,B,C)evaluatesA*kron(B,C).A_times_k_kron_B(A,B,k)uses exactlykcopies ofB. The positive integerk=1givesA*B.kp_shift_solve({A1,A2},lambda,b)solves(kron(A1,A2)-lambda*I)*x=b. Complex factors, shifts and right-hand sides retain their complex solution. Its real-Schur flag changes the factorization, not the equation.qtkp_shift_solve(T,[],b,lambda)uses quasi-triangular factors directly, including two-by-two real Schur blocks. An optional scalar or two-by-twoalphais the leading product factor.
35.1. Known tensor orders
korder_matrix_vector(x,T,G,G0p[,k]) reshapes the input into regime blocks
U and returns the stacked vectors of
sum_stp(G(:,:,st,stp)*U(:,:,stp))*kron(T_st,...,T_st)+G0p(:,:,st)*U(:,:,st).
For non-scalar square transitions the four-argument form infers k from
n^k columns and checks that equality. A scalar transition has the same
dimension at every order: supply k explicitly rather than infer it.
engine=@rise.engine.numerics.kronecker.korder_matrix_vector;
first=engine(2,.4,3,5,1); % (3*.4+5)*2
second=engine(2,.4,3,5,2); % (3*.4^2+5)*2
A_times_reordered_kron_Q1_Qk_times_B sums the specified left and right
reshuffles of A*kron(Q1,...,Qk)*B. Effective matsizes include the final
width after multiplication by B; rectangular right-hand sides keep that
output width. Empty orders retain the leading product, and skip_first
excludes it on the alternate route.
The default route takes siz.n.v, siz.n.z and siz.order. For scalar
dimensions, supply siz.derivs=[number_of_Q_factors,degree_Q1,...,degree_Qk].
Every width and the total order are checked. Non-scalar dimensions retain the
checked inference. Missing scalar-order metadata is an input error.