change dim of matrix without altering data
Is there an optimal way to do this? Say for example I have a "char 5 5" matrix and I want to change it to a "char 1 25" matrix. Where the underlying data doesn’t change and isn’t copied, just the way its dimmed is changed. Hoping there was something like jit.coerce for changing the dimension…
Here’s one way.
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 697.3oc2W00jaBBE8Y8WAiOmlQPMQ6Sa+czoSFzPRHiAbDxGa2Y+uWAzMtYa RIzD6l9fvv2m6g68v0W78Bx4GHh.vWAeG348hummtKUGdss8B1fOTThE5oEv H644qCFYFRRNH0culJGufVVBdZCVVSOLig2P.bFImtrfWtcCC7TUIlQ.gcqk scCkURj58E11YEVVrhxVNqlTHM3JJZx3vQ.XbrpBkfzUgiCA+33Nw2J61JTa uz4Zj0f1uDA6NzEblTAM8PeqlhK6FwrCxmqHliMHXTy2amgZgB5O0CBaffp2 W88UEirj5TbT0dJaNee2gVUSDDlDKobVOSNAoM4nTcUXaQe68pXtLMkACM72 0wbn+D+3.QbAeHi2y6cbffhU35lJThq9NSRMDwTG7chbv2owTlYLkatWzEHO YMlIp3BhizTltbZhCjT3CCIIpzxTkTQCbXKkq54VclvwIgZomrzaRzHJzTEc 8zLJ6SpNl0b.pW3nVJxnKYOE.+WJHUy22oFgR.PGsdyCYvoNHFAgOLwYmKa. EG5bp.ndQPnHGxDH9AO.BMEcTo1D+bcOnO8ND9juUJ4LGuLeKJ3hWkvOZIIm 0Rxwrk2bg.FmJHcQ+IfD2L2XnQxK0g2XeXB8a0LWP2QxeVU9WSaSRLua3PpI n+KxL45nqrINmhwc8OkzyInjxN8eN0Vhp+2ybB915htSoKOSvQqYNQHoLc5Z 8ljJKodSZEc9bhd7vtkQE37Rh1n+82g1hGjEv4DL+Q3rgNuhSYxVNoQhHYDH MS+GfwIcMNdJ2NzmYC7gCFadxQcF7DMb3IxF7fFL7DaAbfC20EzlqK3vQO1. m3ACMI136Lbtx1na9oR1bp6plnT38T0zFudGoRyCj3ppcjZQ6VpARSRDq40p lSFoaRYll5cLnlri1M+Te0t8p+u.QW0EI. -----------end_max5_patcher-----------
Thanks Chistopher. I actually am using the jit.spill and jit.fill technique now but its slow – even slower since I have 4 plane matrices and got to split apart the planes and rejoin them after. The thing that grabs me is that data is exactly the same before and after: in the "4 char 5 5" to "4 char 1 25" conversion example both matrices have the same 25 RGB values in the same order (I think). Can’t I leave the data intact and un-copied and just "header munge" (disclaimer: I’m not really sure what that means) the matrix dimensions. This would all happen in a billionth of a millisecond with one object, as opposed to the slow rube goldberg contraption I am using now ;)
Sure, the data is the same, and in fact I think (I haven’t looked at the Jitter SDK in a long time) that the internal storage method is extremely similar, so it would probably not be too tough to make a single Jitter object that does what you’re suggesting (just changes the matrix dimensions while holding the same data). But I’m not aware of any object that does that, and as you can see there’s more than one way to "flatten" a 2D matrix into a 1D matrix (by rows top to bottom, or by columns left to right, or by rows bottom to top, or by columns right to left, or by some other algorithm), not to mention trying to figure out a generalizable way to convert any matrix dimension to any other matrix dimension while still retaining the data in a knowable order.
So you might ask yourself why you need to do this conversion. Is it possible that you can just change your ideas about how to access the data in its original form? That is, what can you do with data in a 25×1 matrix that you can’t do with it in a 5×5 matrix?
hey, you can use jit.scanwrap:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 428.3ocwTkraCBCD8L7UX4yzJLak1a86nJJx.tMNhXircVZix+dwC3rzkTZR S5ALZFOLukwl09d3B4JlFid.8DxyasumGjxlvqO1COitprlpgxvEyMFo.Gzs UC0TNgKdYrhUZ5ZCIkbaX.hPxruhBcqnQ8eCuBZjrX5MYt9HlOiKpYF.Cxtj x4lOlsKk40FVGd3Bp3ELZjc2M991kfApkobysMK4hJ4xeVPQ2maecGoSQwes hR9EJJxgohoYBC0vkh8vMgDaQJNGLxv9ksf9Ie.Gz9bA8gnzHXvlC9PNPnru YvFeB1venfDrksrvwACakYqN0kTwREsAkfJmPUspBQbE9rTXDzY.93GUbZ8. NVjk.tR7cG6fdz9Pn4uAPPr944aSspZ7LpQwWcQLLgjqYN2JEkdNlEIENRSB yOlYQ9mLKfK3Zt3i+QDDjM+gNnVNWU5ZbOwQ6TTESa3B3V8d0DcPMS3UULXa m3p3ZZQMCbivubRNT1DM.1jb0XS1.XC4pwlgLohOQ1zcLh1zrfoz8sDHR6Ut oRkMLK.B4htPniXEaA2Uetusaa7eG3cfCuA -----------end_max5_patcher-----------
There ya go! Thanks, Tobias. I forgot about that one.
Thats the ticket! Thank Tobias – and I thought I searched through all those those jit objects that I’ve never used and understood poorly, but there it is.
Forums > Jitter