关于Taco符号含义及克罗内克积实现的技术咨询
Hey there! Let's unpack what's happening here and get your Kronecker product calculation working correctly.
First: What do those index letters mean?
In Taco's index notation, each unique letter represents a separate dimension index. When you use the same letter for both row and column (like B(j,j)), you're not referring to the entire matrix—you're only selecting the diagonal elements of B. This is likely what triggered the transposition-related error message, since the tool interprets repeated indices in this context as an operation that relies on transposition logic (which isn't supported yet).
Why your original expression isn't computing the Kronecker product
Your current expression A(i,i) = B(j,j) * C(k,k) only multiplies the diagonal elements of B and C, then assigns those values to the diagonal of A. That's nothing close to a Kronecker product, which requires taking every element of B and scaling the entire matrix C by that element, then tiling those scaled matrices into the final 12×12 result.
The correct index expression for your Kronecker product
To compute the 4×4 matrix B and 3×3 matrix C's Kronecker product (resulting in a 12×12 matrix A), you need to map the indices of B and C to the larger indices of A properly. Here's the right expression:
A(j1*3 + k1, j2*3 + k2) = B(j1,j2) * C(k1,k2)
j1andj2iterate over the 4 rows and columns of Bk1andk2iterate over the 3 rows and columns of C- The calculation
j1*3 + k1maps the combined indices of B and C to the row index of A, andj2*3 + k2does the same for the column index—this correctly tiles the scaled C matrices into the final 12×12 structure.
Quick check to avoid future errors
Always use distinct indices for different dimensions unless you explicitly want to select diagonal elements or perform a reduction operation. Repeating indices where they shouldn't be will often trigger unintended behavior or unsupported operation errors in Taco's current demo.
内容的提问来源于stack exchange,提问作者user1305541

