Direct Sum and Tensor Product (Outer Product) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Direct Sum and Tensor Product (Outer Product) (/thread-19904.html) Direct Sum and Tensor Product (Outer Product) - Eddie W. Shore - 05-04-2023 07:56 PM DIRSUM: Direct Sum DIRSUM is the direct sum of two tensors, specifically column vectors. The direct sum, symbolized by ⊕ (circle with a plus symbol in it), stacks column vectors on top of each other. The order of the two vectors matters. Example: V1 = [ [ 2 ] [ 3 ] ] V2 = [ [ 5 ] [ 6 ] [ 8 ] ] V1 ⊕ V2 = [ [ 2 ] [ 3 ] [ 5 ] [ 6 ] [ 8 ] ] V2 ⊕ V1 = [ [ 5 ] [ 6 ] [ 8 ] [ 2 ] [ 3 ] ] The dimension of the direct sum is the sum of the dimensions of the vectors. TENSOR: Tensor Product The tensor product, also known as the outer product multiplies the numbers from V1 to each element V2 in order. The tensor product can be represented in a column vector or a matrix. If V1 and V2 are matrices, the outer product is calculated as: V1 ⊗ V2 = V1 × V2ᵀ = V1 × transpose(V2) Example: V1 = [ [ 2 ] [ 3 ] ] V2 = [ [ 5 ] [ 6 ] [ 8 ] ] V1 ⊕ V2 = [ [ 10, 12, 16 ] [ 15, 18, 24 ] ] V2 ⊕ V1 = [ [ 10, 15 ] [ 12, 18 ] [ 16, 24 ] ] The tensor product is not commutative, order matters. Code: ```EXPORT DIRSUM(v,w) BEGIN // direct sum of 2 vectors // 2023-04-30 EWS LOCAL lv,lw,lc; lv:=mat2list(v);  lw:=mat2list(w); lc:=CONCAT(lv,lw); RETURN list2mat(lc,1); END;``` Code: ```EXPORT TENSOR(v,w) BEGIN // tensor product of 2 vectors or matrices // 2023-04-23 EWS RETURN v*TRN(w); END;``` Source: Bradley, Tai-Danae. "The Tensor Products, Demystified" math3ma.com November 18, 2018. https://www.math3ma.com/blog/the-tensor-product-demystified Accessed April 24, 2023.