multi dimension array in max

Jan 14, 2014 at 5:15am

multi dimension array in max

say I want a 2d array in max e.g.X[3][4]=12
what are my options?

(I’m mainly interested where indexes are numeric, so hoping for a pretty fast fixed storage lookup, doesn’t even need to be a sparse array – though could be)

as far as i can tell its:
a) put a list in a coll/table, and then index list.
b) use dict with a nested dictionary?
c) javascript?

(a) would is limited to a 2d, I could not do N dimensions e.g. X[3][2][10]=14
(b) seems nice, but a bit of overkill, and presumably not very good for performance, as it works with symbols.
c) I’ve not looked into, and not sure i want to add the complexity

have i missed any other options? where are preferred ways?
(whats the coll or table?)

can I pull coll/tables into other coll/tables?

thanks for any pointers
Mark

#278196
Jan 14, 2014 at 5:34am

Maybe jit.matrix.

#278198
Jan 14, 2014 at 6:46am

If your looking for examples, here’s a coll version of a 2d 4×4 array.

<code>

– Pasted Max Patch, click to expand. –

</code>

You could also do this patch with a preset obj

<code>

– Pasted Max Patch, click to expand. –

</code>

#278200
Jan 14, 2014 at 7:27am

Get familiar with jitter… It’s quite the powerful little tool. You can use it purely for managing numbers and doing math. No bouncing basketballs or ducks required.

Anyway, here are a few max examples in the spirit as Rick’s input.

– Pasted Max Patch, click to expand. –
#278204
Jan 14, 2014 at 7:54am

FTM is your friend and very efficient

http://ftm.ircam.fr/index.php/Main_Page

– Miguel

#278211
Jan 14, 2014 at 8:08am

thanks… lots to learn :)
I realised i could use a single dimension by calculating index (e.g. z*(X*Y)+x*Y+y), but was hoping for something that had appropriate messages (easier to read code)

Yup, I thought jit objects were for bouncing ducks :) so will take a more careful look obviously wrong – jit.matrix looks pretty ideal – any drawbacks? (given the number of options, is it ‘heavy’, i guess not if its used for video etc)

nth on coll, these looks like it could be what I’m after for 2d.

FTM, ah bumped into this the other day… looks interesting, but Im trying to stay vanilla max initially, just so I can grasp a better understanding of whats there – but will definitely add FTM to my list for looking at afterwards.

special thanks for the examples, very helpful seeing how these things work.

#278212

You must be logged in to reply to this topic.