### How do I copy one matrix to another?

Hi.

I’m just having a first stab into using Jitter as a way of buffering output to a Launchpad. That is I have two 2D 8×8 matrices.

I ‘render’ the state of the button matrix into one Jitter matrix then compare each cell with a second ‘stored’ matrix outputting updates to the Launchpad for cells that are different in the rendered matrix.

At the end of the process I need to copy the ‘rendered’ matrix into the ‘stored’ matrix for use next time around.

I went looking for an object that would copy a matrix but couldn’t find anything. Is there such a thing? Or do I need to iterate & copy by hand?

In the same vain my method for finding updated buttons is to jit.iter the rendered matrix and compare with the equivalent cell in the stored matrix. Is there an easier path to this that outputs the differences between two matrices? I saw jit.change but that seems just about the degree of change, not the actual differences.

Any help would be much appreciated.

Thanks.

Matt

Looks like a combination of jit.spill & jit.fill can do the job more easily than manually iterating.

But maybe there’s an easier way still?

M

Hi Matt,

Could you post what you have so far? Maybe that will give me a better idea of what you are up to.

-Ben

you could use [jit.op @op -] —that should tell you the difference on a cell-by-cell basis. maybe you’ll need an absolute value there too, not sure.

For copying, I’m not sure… could you do a workaround with [jit.submatrix] but just use the whole thing? seems weird though.

Maybe a message to a matrix: copymatrix @sourcematrix

would copy the source matrix to the one you’re sending the message to. feature request? probably I’m missing something though.

To set matrix B to have the contents of matrix A, you simply send A to B. (More specifically, you cause matrix A to send a ‘jit_matrix’ message to matrix B.) The trick, though, is to suppress thruput on matrix B by setting its @thru attribute to 0 (it’s 1 by default), so that you can set and recall its contents independently.

So if matrix A is the one that has the most recent Launchpad settings, and matrix B is the one that has the previous Launchpad settings, you can bang matrix B to get it to send out the previous settings, compare those to the settings of matrix A, and then set the contents of matrix B to be those of matrix A. Something like this (note that matrix B has @thru 0):

-- Pasted Max Patch, click to expand. --Copyallof the following text. Then, in Max, selectNew From Clipboard.----------begin_max5_patcher---------- 895.3oc2X10aaBCEF95jeEdbSuIKyewWSZSs6uwTUEI3z3JvNBLsYqp+2mwF RSZoTHgPqlpHHa.62yCu93S4woSbVH2xxc.eG7avjIONcxDSWkcLop8Dmzns KShxM2lyRYZJSnblYulhsUY5+W08HJR4hDlxb6nm6TVnp6EV06JoPIhRYlA3 pLdTR8frIRsbMWb6MYrkJq7b88lCmAvPX4ITnswbH35pmgGaFG4h69pK1Yuo Hm+WyTfvygk89zzok+L6Di3qN2QLMzDwHhWGhX3.Fw2wUy27.WDKenGwHtNR xX4ZdEo3Rw9u+nHS.DFTdBV8ytXYgLKlkYF840zxN3p+rgYGBGmY5icORCHy CSMSB0LIdz5eaBY3PmOYrAQNqrgZW430A1Pfe1XCkPOmrAZfBA2E1fbFvrHp 0LvRVRRNPsNRAVGcut85Hwsr3iH+xavPpmkgPbiLreYkrIfw9lwB452VZIxP lHVvdPOluhfkttzHUFeK.UhtLP.HX37eDZ3wwtW4B0B8FqPeW+HIvlGKv3GQ HbqPlLNPVtAbo93K+nQ3hOA3R7C9.fKwP0.RqrkNBURTlCHUlq.ZMpuNnNNF rk+glXDA8Frk+Hb0oVqJg3MRz6BcjeOWVjewfCu55Vdi8e5G7r0kfrFPDxqU 34OpKq+I3x6iRziu+.t7NvvNe53u5tZ6o2weFLJ9SdNXSDOCHWAzypVo4.VZ QRjhkCh.5WMfblxbUw2jqVAxUkWpdfR3B1RYgvLZjgyWCMnwEd51ZW69SUla DrtQiHO776pUfD8eK5QN.R+sjFin9XgtVstXHqp61E0lgjNj+abKJTJonGT. 0oUynlcLuBPcELA0.oErbTkb2RNOgjmyNOkKZgTuWVM.o7pV+ACZEk+GTQds Oza7Yb8Gio8JxojOHHCtTsNq..OBXedvFEcvWsyscuYWJ117flMEew2szL6k 8eHKykEYKqUd8r.dd9iY4Jtv3w16lvgGbSq4wwLw96plxi2H4BUkHnX24t5H ydxiP10Bbciuy6rZgcPsDZ+T6PnIz6nIZO0DUWOha4m4zVKgEjlVmpZockfn i88M00ePeeiGX1dpZhzAB9Bi5YWSntnI73pIbWbZAipldwz8FbhLtZpSqHIe 973jd5wIgl8APdHytBzvcsNUB1I0hNJ0Rza3VpVj+tVGnVciml9OJrWiw. -----------end_max5_patcher-----------

what I do for comparing long lists or matrices is simply add them together and then modulo. That gives you a "toggle" function that can be set up for any number of stages. Quite handy.

@wetterberg can you elaborate a bit with the modulo? wondering how you’re doing that and what you get from it. always interesting to hear new tactics…

Forums > Jitter