Kronecker Product? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Kronecker Product? (/thread-12450.html) |
Kronecker Product? - DrD - 02-17-2019 02:39 PM How could a Kronecker Product be found with the hp prime? (This would be like Matlab's kron() command, or Wolfram's KroneckerProduct() command). https://en.wikipedia.org/wiki/Kronecker_product I'm no expert on this subject matter, but have recently encountered a need for this in connection with an energy flow problem. Here is an example of a 4x4 identity matrix, with a 2x2 matrix, resulting in an 8x8 Kronecker product: Example (using wxmaxima here): (%i3) a:ident(4); b:matrix ([1,-1],[-1,1]); kronecker_product(a,b); (a) matrix( [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ) (b) matrix( [1, -1], [-1, 1] ) 0 errors, 0 warnings (%o3) matrix( [1, -1, 0, 0, 0, 0, 0, 0], [-1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, -1, 0, 0, 0, 0], [0, 0, -1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, -1, 0, 0], [0, 0, 0, 0, -1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, -1], [0, 0, 0, 0, 0, 0, -1, 1] ) RE: Kronecker Product? - informach - 02-17-2019 03:47 PM Hi!, DrD : You can use, for calculate matrices, with Hadamard, as … Syntax : Hadamard bound of a sub-matrix or element by element multiplication of 2 matrices. hadamard(Matrix,[Matrix]) Examples: hadamard([[1,2],[3,4]]) returns 5√5 hadamard([[1,2],[3,4]],[[3,4],[5,6]]) returns [[3,8],[15,24]] From … User_Guide_EN_2018_01_12_1.pdf (page 475). Too, you can see, from Namir Shammas http://h20331.www2.hp.com/hpsub/downloads/Sep13/s07_myfavoritehpprimtfunctionsv3.pdf RE: Kronecker Product? - DrD - 02-17-2019 05:48 PM (02-17-2019 03:47 PM)informach Wrote: Hi!, DrD : The hadamard() command fails. Please note that the matricies in the example I provided are of differing sizes: a(4x4) and b(2x2), and produce an 8x8 Kronecker product. I'm not seeing any in-built commands that produce the Kronecker product. It may have to be created as an external command, or function. [attachment=6953] RE: Kronecker Product? - Didier Lachieze - 02-17-2019 07:52 PM Here is a CAS program to calculate the Kronecker product of two matrices: Code: #cas RE: Kronecker Product? - DrD - 02-17-2019 08:06 PM (02-17-2019 07:52 PM)Didier Lachieze Wrote: Here is a CAS program to calculate the Kronecker product of two matrices: Thank you, kind sir! Excellent, as always. I was a bit surprised not to find this in the suite of similar commands, but I'll add this into my collection! RE: Kronecker Product? - Didier Lachieze - 02-18-2019 08:58 AM Here is a slightly updated version, replacing the Home MOD function by the CAS irem function to be more consistent: Code: #cas RE: Kronecker Product? - DrD - 02-18-2019 10:26 AM Thanks for the update. I was studying your makelist construction, and thinking to myself how nicely crafted, made even better, now, by using only CAS commands. There is a lot, in just your short program, to be learned about the hp prime, CAS/HOME, and programming; embedded in it. This would make a great example for the user guide, to introduce CAS programming structures, and techniques. Short, efficient, and to the point! Very well done! -Dale- |