Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/matrix-transposition.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / matrix-transposition.wiki` 106 lines ยท 1866 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text minus "-" 9 text tt "transposed:\n" 10 global ma long 15 11 global mt long 15 12 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 13 fn emit a view uchar * to void 14 o = ulong 0 15 while lt o len a bound 4096 16 k = write 1 a o sub len a o 17 if le k 0 18 exit 1 19 end 20 o = add o ulong k 21 end 22 end 23 note emitu writes n in decimal; 20 digits hold every ulong 24 fn emitu n ulong to void 25 d = new uchar 20 0 26 i = ulong 20 27 v = n 28 while true bound 20 29 i = sub i 1 30 put d i uchar add rem v 10 48 31 v = div v 10 32 if eq v 0 33 break 34 end 35 end 36 emit part d i sub 20 i 37 end 38 note emitwi writes a signed n right-aligned in w columns (w at most 20) 39 fn emitwi n long w ulong to void 40 d = new uchar 21 32 41 i = ulong 21 42 v = n 43 if lt n 0 44 v = neg n 45 end 46 while true bound 20 47 i = sub i 1 48 put d i uchar add long 48 rem v 10 49 v = div v 10 50 if eq v 0 51 break 52 end 53 end 54 if lt n 0 55 i = sub i 1 56 put d i 45 57 end 58 if gt w sub 21 i 59 i = sub 21 w 60 end 61 emit part d i sub 21 i 62 end 63 note ma is a 3 x 5 matrix stored row by row; its transpose mt is 5 x 3, mt[j][i] = ma[i][j] 64 fn showt r ulong c ulong to void 65 for i ulong r 66 for j ulong c 67 emitwi get mt add mul i c j 4 68 end 69 emit nl 70 end 71 end 72 fn showa r ulong c ulong to void 73 for i ulong r 74 for j ulong c 75 emitwi get ma add mul i c j 4 76 end 77 emit nl 78 end 79 end 80 fn main to int 81 for i ulong 15 82 put ma i sub long mul i i 50 83 end 84 showa 3 5 85 for i ulong 3 86 for j ulong 5 87 put mt add mul j 3 i get ma add mul i 5 j 88 end 89 end 90 emit tt 91 showt 5 3 92 ret 0 93 end 94 95 {{out}} 96

97 -50 -49 -46 -41 -34

98 -25 -14 -1 14 31

99 50 71 94 119 146

100 transposed:

101 -50 -25 50

102 -49 -14 71

103 -46 -1 94

104 -41 14 119

105 -34 31 146

106