Post Reply 
(42S) Matrix Integer Powers
02-15-2015, 07:35 AM (This post was last modified: 06-15-2017 01:48 PM by Gene.)
Post: #1
(42S) Matrix Integer Powers
A surprising omission on the 42S is the lack of a matrix powering function.

These two programmes supply the lack.

IDN for positive integer input returns the identity matrix of input dimension.

0. { 26-Byte Prgm }
1. LBL “IDN”
2. ENTER
3. NEWMAT
4. EDIT
5. LBL 00
6. SIGN
7. →
8. FC? 76
9. ↓
10. FC? 76
11. GTO 00
12. EXITALL
13. END

For stack

Y: Matrix

X: Integer

MAT↑ returns the input matrix to input power.

0. { 61-Byte Prgm }
1. LBL “MAT↑”
2. X>0?
3. GTO 03
4. X<>Y
5. INVRT
6. X<>Y
7. ABS
8. LBL 03
9. STO 02
10. X<>Y
11. ENTER
12. DIM?
13. R↓
14. XEQ “IDN”
15. GTO 00
16. LBL 01
17. 2
18. MOD
19. X≠0?
20. GTO 02
21. LASTX
22. STO/ 02
23. R↑
24. RCL* ST X
25. R↑
26. RCL 02
27. GTO 01
28. LBL 02
29. STO- 02
30. R↓
31. RCL* ST Y
32. LBL 00
33. RCL 02
34. X≠0?
35. GTO 01
36. R↓
37. END
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)