Matrices Built from Shifted Elements - 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: Matrices Built from Shifted Elements (/thread-12569.html) |
Matrices Built from Shifted Elements - Eddie W. Shore - 03-06-2019 01:26 PM The programs LSM (left-shift matrix) and RSM (right-shift matrx) create a n x n matrix based on the elements of a given list. Each row has each of the elements rotated one element. For LSM, each row has the elements shifted to the left one element. For RSM, each row has the elements shifted to the right one element. HP Prime Program: LSM Code:
HP Prime Program: RSM Code:
Note: The program RSM creates a circulant matrix. Example: list = {1, 7, 8, -2, 0} LSM({1, 7, 8, -2, 0} returns: [ [ 1, 7, 8, -2, 0 ] [ 7, 8, -2, 0, 1 ] [ 8, -2, 0, 1, 7 ] [ -2, 0, 1, 7, 8 ] [ 0, 1, 7, 8, -2 ] ] RSM({1,7,8,-2,0}) returns: [ [ 1, 7, 8, -2, 0 ] [ 0, 1, 7, 8, -2 ] [ -2, 0, 1, 7, 8 ] [ 8, -2, 0, 1, 7 ] [ 7, 8, -2, 0, 1 ] ] Blog post: https://edspi31415.blogspot.com/2019/03/hp-prime-matrices-built-from-shifted.html RE: Matrices Built from Shifted Elements - Didier Lachieze - 03-06-2019 04:32 PM Interesting topic, another way to do it would be to use MAKEMAT like this: Code: EXPORT LSM(L0) RE: Matrices Built from Shifted Elements - John Keith - 03-06-2019 05:41 PM Interesting, thanks for posting. As an aside, your left-shifted matrix is a Hankel matrix, useful in linear algebra and integer transforms. |