resize a matrix non destructively?

    Oct 20 2010 | 11:04 am
    I have a multiplane matrix which is being filled data one row at a time using jit.fill and an offset command.
    I want to resize the matrix on the fly, taking its dimensions from say 1x100 to 1x10.
    When i send the matrix a "dim 1 $1" command the matrix is resized correctly but all the data is deleted.
    Is there a way to resize the matrix but keep all the data intact? I thought i might be overlooking an easy command?
    Otherwise I guess i'll have to keep a 2nd copy of the matrix, resize the 1st matrix then refill it with the data from the second matrix? How does this sound?
    Look forward to hearing some opinions,

    • Oct 20 2010 | 1:27 pm
      will jit.submatrix help?
    • Oct 20 2010 | 3:45 pm
      just connect two jit.matrix objects as below:
      [jit.matrix 1 100]
      [jit.matrix 1 10]
    • Oct 20 2010 | 11:05 pm
      Thanks for the input, I've spent the day looking into these and other various ways forward but have had no luck,
      I guess I should have been more clear about what im aiming for,
      I have a multiplane matrix 6 planes each 1 by 1024 filled with values which i want to keep intact.
      1- Using [number box] id like to reduce the matrix down to "1 by [number box]" keeping the values that exist in this range unchanged.
      2- Id then like to be able to increase the matrix to "1 by [number box}" any new cells made should be filled with 0's.
      So far i've found a convoluted way of almost achieving 1, although instead of reducing the matrix's dimensions the values im wanting to get rid of are replaced with zeros- this is not a massive problem.
      However when I scale the matrix back up the new values are not replaced with zero's, they're going back to what was previously in the matrix.
      I've attached a patch which demonstrated the problem. opening up p interface and p matrix planes shows what im getting at. using the lcd in 'p interface' puts values into the matrix. scrolling the 'total objects' number box increases and decreases the matrix. the matrix is viewable in 'p matrix planes'
      If anyone could take a look at the patch id really appreciate it, thought id be able to sort it out in a couple of hours but have been at it all day with no luck so far!
    • Oct 21 2010 | 2:03 pm
      Sorry I don't have time to study your patch, but maybe this example will be helpful(?). The example uses a 4-plane 256x256 matrix for easy visualization, but it could easily be adapted to a 6-plane 1x1024 matrix.
    • Oct 21 2010 | 3:16 pm
      Oops. A small misspelling in the above patch: the word "dsdimstart" should be changed to "dstdimstart".
      Corrected version below.
    • Oct 22 2010 | 3:42 pm
      Hi Christopher,
      Thank you! Thats almost exactly what I was looking for, I had tried the dstdimstart stuff but had gotten it all wrong, your example really makes sense of it. Your patch works brilliantly when scaling the matrix down but when I scale it back up id like the freshly viewable values to be reset to zero- im going to have a look at using setcell for those bits.
      Thanks again, was going a bit crazy with it!
    • Oct 22 2010 | 7:40 pm
      I'm glad it was helpful. To set all values in a matrix to 0 most quickly, use the 'clear' message. To set them all to something else, use the 'setall ' message. Then, by specifying the dststartdim and dstenddim points, you can impose a smaller matrix onto a part of the larger one, changing all those values while leaving the others as you set them.
    • Feb 12 2013 | 5:34 am
      hate to dig up old dead threads but I was looking for an answer its one of the best returns on searches for resizing matrices nondestructively, turns out you can use the method posted here and also use a submatrix object, which can then be dynamically resized without information loss