Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: Drak on February 07, 2009, 03:17:53 am
-
anyone know the fastest way to shift everything in a matrix around? like, moving rows up and down, and columns left and right? TI84+Basic [or asm.]
need it to play around with matricies
-
Well, there is the 'rowSwap()' command.
As for column sorting, rowSwap([A]T.
Syntax:
rowSwap([A],<number of first row you wanna swap>,<second one>
rowSwap([A]T,<number of first column you wanna swap>,<second one>
(P.S. Both rowSwap( and T are found under Matrix -> Math.)
-
Well, there is the 'rowSwap()' command.
As for column sorting, rowSwap([A]T.
Syntax:
rowSwap([A],<number of first row you wanna swap>,<second one>
rowSwap([A]T,<number of first column you wanna swap>,<second one>
(P.S. Both rowSwap( and T are found under Matrix -> Math.)
alright. what is "t" though? (it works, i just don't know what the name of it is... never seen it before)
-
It's 'transpose'.
It swaps the rows and columns.
(e.g. Column 1 is now row 1, column 2 is row 2, etc.)
Visual Example:
[1,1]
[2,2]
becomes
[1,2]
[1,2]
Another:
[1,2,3]
[1,2,3]
[1,2,3]
becomes
[1,1,1]
[2,2,2]
[3,3,3]
Uneven:
[1,2]
[1,2]
[1,2]
becomes
[1,1,1]
[2,2,2]
{EDIT: The reason that it doesn't flip the whole matrix permanently is that is outputs into Ans. If you want it to stay transposed it'll be [A]T→[A]}
{EDIT2: To swap columns and save it it'll be
:rowSwap([A]T,x,y)T→[A]
}
-
alrighty! thanks :D
-
No problem, man.
If you ever have any other questions, feel free to ask. =D
-
Mmm i wonder if this could be used for a rotating tilemap...
-
Wow... something I knew that Omni didn't?
I'm impressed with myself now. =D
Though that's actually a cool idea, omni.
If it wasn't for the fact that I'm not using ASCII for the map or more constant tiles, I'd try and implement it.
-
I'm trying to think of a good puzzle for dungeons that uses this. Can't think of anything though :/
-
Wow... something I knew that Omni didn't?
I'm impressed with myself now. =D
Keep in mind that my peak of activity in calc programming was around late 2002 until late 2004, though ;)
-
Wow... something I knew that Omni didn't?
I'm impressed with myself now. =D
Keep in mind that my peak of activity in calc programming was around late 2002 until late 2004, though ;)
Even so... I've looked up to you for a good deal of time now. ^_~
-
Yeah, I use that in my compression program (CIB). I think you still remember it kevin, transpose is quick too.
-
stumped. it's incredibly slow to do a fornext to shift the entire thing down or up or left or right. anyone got any solutions?
-
Contact a Asm programmer, in asm this will move so quickly..But in basic you are not going to get much faster.
-
I'm going to try and figure out a hacky way to do this in pure Basic. I have an idea of how it's going to work.
Edit: Never mind, it turned out even slower than just switching the rows, and hogs way more memory as well. I tried to use the exchange matrix method.
Edit2: Are you kidding? The rowswap method seems pretty fast to me. It took less than a second for every case I tried...
-
needs to be split second. like, no time at all. what way did yo ugo about doing it? (code pls kthnx ps im not a spie i no ninja ur koad.)
-
Maybe he got a lot of stuff going on in his game besides the row swapping. I might experiment with that feature someday though, to see if it couldnt be useful for certain games
-
DJ you didn't know matrix commands? When I discovered I was an ignorant about them, I rushed reading TI-BD...
Anyway, those commands seem nicely fast for me. the "t" stands for transpose iirc.
-
For future reference...
[A]T
[A][sup]T[/sup]
→
Alt+26 (on the numpad with Num Lock on)
Hold Alt, press 2 then 6, then let go of Alt.
-
DJ you didn't know matrix commands? When I discovered I was an ignorant about them, I rushed reading TI-BD...
Anyway, those commands seem nicely fast for me. the "t" stands for transpose iirc.
I know how to use matrices, but I never used the other commands except for Fill(, Dim( and T, because they weren't of any use for me in any of the old games I made. Same for IS</DS>. I only learned about it when I had no choice to use it (TI-81 Illusiat)