Convert 3D matrix to 2D matrix (for mesh, multiple, etc)
Hi all,
I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr, as
data for jit.gl.multiple and/or jit.gl.mesh. Since neither multiple
nor mesh support 3D matrices, I’m wondering if there’s a way to
efficiently convert a 3D matrix of arbitrary size to a 2D matrix
(e.g. Nx(NxN)). I can’t figure it out.
Schema:
[bang]

[jit.matrix 3 float32 10 10 10]

[ ??? ]

jit.matrix 3 float32 1000] or [jit.matrix 3 float32 10 100]

[jit.gl.multiple]
Thanks
grrr waaa
http://www.grahamwakefield.net
On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr,
> as data for jit.gl.multiple and/or jit.gl.mesh. Since neither
> multiple nor mesh support 3D matrices, I’m wondering if there’s a
> way to efficiently convert a 3D matrix of arbitrary size to a 2D
> matrix (e.g. Nx(NxN)). I can’t figure it out.
#1, you should be able to convert your expr to a 2D expression to
begin with (thinking of the large 2D matrix as a tiling of a 3D matrix).
However, if that doesn’t work for you, you’ll probably want to use
jit.matrix and something like the following email client JS (or
patcher equivalent)…watch for typos and or other oversights in the
following as I didn’t take the time to test.
dest.adapt = 0;
dest.dim = [width, height*depth];
dest.usesrcdim = 1;
dest.usedstdim = 1;
for (i=0;i
{
dest.srcdimstart = [0, 0, i];
dest.srcdimend = [width1, height1, i];
dest.dstdimstart = [0, i*height];
dest.srcdimend = [width1, (i*height) + (height1)];
dest.frommatrix(source);
}
Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which
would be ideal for this sort of job.
Joshua
Hmm, I’d like to do this efficiently. Sounds like a simple jitter
external; but my matrix SDK knowledge is rusty…
Can I simply pass the data from input to output
jit_object_method(out_matrix,_jit_sym_data,in_bp);
and change the out_minfo.dim[0] key to be equiv. in_minfo.dim[0] *
in_minfo.dim[1] * in_minfo.dim[2] etc., out_minfo.dimcount = 1, and
so on, followed by
err = (t_jit_err) jit_object_method(out_matrix, _jit_sym_setinfo_ex,
&out_minfo);
Or do I need to manually copy the data in for loops?
Thanks
On Apr 17, 2007, at 6:40 PM, Joshua Kit Clayton wrote:
>
> On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
>
>> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr,
>> as data for jit.gl.multiple and/or jit.gl.mesh. Since neither
>> multiple nor mesh support 3D matrices, I’m wondering if there’s a
>> way to efficiently convert a 3D matrix of arbitrary size to a 2D
>> matrix (e.g. Nx(NxN)). I can’t figure it out.
>
> #1, you should be able to convert your expr to a 2D expression to
> begin with (thinking of the large 2D matrix as a tiling of a 3D
> matrix).
>
> However, if that doesn’t work for you, you’ll probably want to use
> jit.matrix and something like the following email client JS (or
> patcher equivalent)…watch for typos and or other oversights in
> the following as I didn’t take the time to test.
>
> dest.adapt = 0;
> dest.dim = [width, height*depth];
> dest.usesrcdim = 1;
> dest.usedstdim = 1;
>
> for (i=0;i
> {
> dest.srcdimstart = [0, 0, i];
> dest.srcdimend = [width1, height1, i];
> dest.dstdimstart = [0, i*height];
> dest.srcdimend = [width1, (i*height) + (height1)];
>
> dest.frommatrix(source);
> }
>
> Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which
> would be ideal for this sort of job.
>
> Joshua
grrr waaa
http://www.grahamwakefield.net
Hmm, I’d like to do this efficiently. Sounds like a simple jitter
external; but my matrix SDK knowledge is rusty…
Can I simply pass the data from input to output
jit_object_method(out_matrix,_jit_sym_data,in_bp);
and change the out_minfo.dim[0] key to be equiv. in_minfo.dim[0] *
in_minfo.dim[1] * in_minfo.dim[2] etc., out_minfo.dimcount = 1, and
so on, followed by
err = (t_jit_err) jit_object_method(out_matrix, _jit_sym_setinfo_ex,
&out_minfo);
Or do I need to manually copy the data in for loops?
Thanks
On Apr 17, 2007, at 6:40 PM, Joshua Kit Clayton wrote:
>
> On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
>
>> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr,
>> as data for jit.gl.multiple and/or jit.gl.mesh. Since neither
>> multiple nor mesh support 3D matrices, I’m wondering if there’s a
>> way to efficiently convert a 3D matrix of arbitrary size to a 2D
>> matrix (e.g. Nx(NxN)). I can’t figure it out.
>
> #1, you should be able to convert your expr to a 2D expression to
> begin with (thinking of the large 2D matrix as a tiling of a 3D
> matrix).
>
> However, if that doesn’t work for you, you’ll probably want to use
> jit.matrix and something like the following email client JS (or
> patcher equivalent)…watch for typos and or other oversights in
> the following as I didn’t take the time to test.
>
> dest.adapt = 0;
> dest.dim = [width, height*depth];
> dest.usesrcdim = 1;
> dest.usedstdim = 1;
>
> for (i=0;i
> {
> dest.srcdimstart = [0, 0, i];
> dest.srcdimend = [width1, height1, i];
> dest.dstdimstart = [0, i*height];
> dest.srcdimend = [width1, (i*height) + (height1)];
>
> dest.frommatrix(source);
> }
>
> Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which
> would be ideal for this sort of job.
>
> Joshua
grrr waaa
http://www.grahamwakefield.net
Ok I see now that this won’t work, because of different dimstrides.
So, next Q: can I use _matrix_conv_info to do the dirty work, or do I
really need to manually write out for loops?
On Apr 17, 2007, at 8:45 PM, Graham Wakefield wrote:
> Hmm, I’d like to do this efficiently. Sounds like a simple jitter
> external; but my matrix SDK knowledge is rusty…
>
> Can I simply pass the data from input to output
>
> jit_object_method(out_matrix,_jit_sym_data,in_bp);
>
> and change the out_minfo.dim[0] key to be equiv. in_minfo.dim[0] *
> in_minfo.dim[1] * in_minfo.dim[2] etc., out_minfo.dimcount = 1, and
> so on, followed by
>
> err = (t_jit_err) jit_object_method(out_matrix,
> _jit_sym_setinfo_ex, &out_minfo);
>
> Or do I need to manually copy the data in for loops?
>
> Thanks
>
> On Apr 17, 2007, at 6:40 PM, Joshua Kit Clayton wrote:
>
>>
>> On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
>>
>>> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr,
>>> as data for jit.gl.multiple and/or jit.gl.mesh. Since neither
>>> multiple nor mesh support 3D matrices, I’m wondering if there’s a
>>> way to efficiently convert a 3D matrix of arbitrary size to a 2D
>>> matrix (e.g. Nx(NxN)). I can’t figure it out.
>>
>> #1, you should be able to convert your expr to a 2D expression to
>> begin with (thinking of the large 2D matrix as a tiling of a 3D
>> matrix).
>>
>> However, if that doesn’t work for you, you’ll probably want to use
>> jit.matrix and something like the following email client JS (or
>> patcher equivalent)…watch for typos and or other oversights in
>> the following as I didn’t take the time to test.
>>
>> dest.adapt = 0;
>> dest.dim = [width, height*depth];
>> dest.usesrcdim = 1;
>> dest.usedstdim = 1;
>>
>> for (i=0;i
>> {
>> dest.srcdimstart = [0, 0, i];
>> dest.srcdimend = [width1, height1, i];
>> dest.dstdimstart = [0, i*height];
>> dest.srcdimend = [width1, (i*height) + (height1)];
>>
>> dest.frommatrix(source);
>> }
>>
>> Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which
>> would be ideal for this sort of job.
>>
>> Joshua
>
> grrr waaa
> http://www.grahamwakefield.net
>
>
>
>
grrr waaa
http://www.grahamwakefield.net
You can use it to do the 2D slices for you, but not a oneshot
conversion. At a minimum, you’ll need a for loop across the 3rd
dimension.
wes
On 4/17/07, Graham Wakefield
>
> Ok I see now that this won’t work, because of different dimstrides. So,
> next Q: can I use _matrix_conv_info to do the dirty work, or do I really
> need to manually write out for loops?
>
>
> On Apr 17, 2007, at 8:45 PM, Graham Wakefield wrote:
>
> Hmm, I’d like to do this efficiently. Sounds like a simple jitter external;
> but my matrix SDK knowledge is rusty…
>
> Can I simply pass the data from input to output
>
> jit_object_method(out_matrix,_jit_sym_data,in_bp);
>
> and change the out_minfo.dim[0] key to be equiv. in_minfo.dim[0] *
> in_minfo.dim[1] * in_minfo.dim[2] etc., out_minfo.dimcount = 1, and so on,
> followed by
>
> err = (t_jit_err) jit_object_method(out_matrix, _jit_sym_setinfo_ex,
> &out_minfo);
>
> Or do I need to manually copy the data in for loops?
>
> Thanks
>
> On Apr 17, 2007, at 6:40 PM, Joshua Kit Clayton wrote:
>
>
>
> On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
>
>
> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr, as data
> for jit.gl.multiple and/or jit.gl.mesh. Since neither multiple nor mesh
> support 3D matrices, I’m wondering if there’s a way to efficiently convert a
> 3D matrix of arbitrary size to a 2D matrix (e.g. Nx(NxN)). I can’t figure
> it out.
>
> #1, you should be able to convert your expr to a 2D expression to begin with
> (thinking of the large 2D matrix as a tiling of a 3D matrix).
>
> However, if that doesn’t work for you, you’ll probably want to use
> jit.matrix and something like the following email client JS (or patcher
> equivalent)…watch for typos and or other oversights in the following as I
> didn’t take the time to test.
>
> dest.adapt = 0;
> dest.dim = [width, height*depth];
> dest.usesrcdim = 1;
> dest.usedstdim = 1;
>
> for (i=0;i
> {
> dest.srcdimstart = [0, 0, i];
> dest.srcdimend = [width1, height1, i];
> dest.dstdimstart = [0, i*height];
> dest.srcdimend = [width1, (i*height) + (height1)];
>
> dest.frommatrix(source);
> }
>
> Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which would be
> ideal for this sort of job.
>
> Joshua
>
> grrr waaa
> http://www.grahamwakefield.net
>
>
>
>
>
> grrr waaa
> http://www.grahamwakefield.net
>
>
>
>
>
>
>
I don’t get it. I thought that internally, the matrices are all
stored in a single array, so an ND matrix is stored sequentially,
thus for example a [jit.matrix 3 char 2 2 2] is accessed like this:
[[[r g b] [r g b]] [[r g b] [r g b]]] [[[r g b] [r g b]] [[r g b] [r
g b]]]
but is actually stored in memory like this:
[r g b r g b r g b r g b r g b r g b r g b r g b]
Since the actual size of memory isn’t changing, only the matrix_info
interface, shouldn’t I be able to ‘change the header’ without
touching the data?
On Apr 17, 2007, at 9:07 PM, Wesley Smith wrote:
> You can use it to do the 2D slices for you, but not a oneshot
> conversion. At a minimum, you’ll need a for loop across the 3rd
> dimension.
>
> wes
>
> On 4/17/07, Graham Wakefield
>>
>> Ok I see now that this won’t work, because of different
>> dimstrides. So,
>> next Q: can I use _matrix_conv_info to do the dirty work, or do I
>> really
>> need to manually write out for loops?
>>
>>
>> On Apr 17, 2007, at 8:45 PM, Graham Wakefield wrote:
>>
>> Hmm, I’d like to do this efficiently. Sounds like a simple jitter
>> external;
>> but my matrix SDK knowledge is rusty…
>>
>> Can I simply pass the data from input to output
>>
>> jit_object_method(out_matrix,_jit_sym_data,in_bp);
>>
>> and change the out_minfo.dim[0] key to be equiv. in_minfo.dim[0] *
>> in_minfo.dim[1] * in_minfo.dim[2] etc., out_minfo.dimcount = 1,
>> and so on,
>> followed by
>>
>> err = (t_jit_err) jit_object_method(out_matrix, _jit_sym_setinfo_ex,
>> &out_minfo);
>>
>> Or do I need to manually copy the data in for loops?
>>
>> Thanks
>>
>> On Apr 17, 2007, at 6:40 PM, Joshua Kit Clayton wrote:
>>
>>
>>
>> On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
>>
>>
>> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr,
>> as data
>> for jit.gl.multiple and/or jit.gl.mesh. Since neither multiple
>> nor mesh
>> support 3D matrices, I’m wondering if there’s a way to efficiently
>> convert a
>> 3D matrix of arbitrary size to a 2D matrix (e.g. Nx(NxN)). I
>> can’t figure
>> it out.
>>
>> #1, you should be able to convert your expr to a 2D expression to
>> begin with
>> (thinking of the large 2D matrix as a tiling of a 3D matrix).
>>
>> However, if that doesn’t work for you, you’ll probably want to use
>> jit.matrix and something like the following email client JS (or
>> patcher
>> equivalent)…watch for typos and or other oversights in the
>> following as I
>> didn’t take the time to test.
>>
>> dest.adapt = 0;
>> dest.dim = [width, height*depth];
>> dest.usesrcdim = 1;
>> dest.usedstdim = 1;
>>
>> for (i=0;i
>> {
>> dest.srcdimstart = [0, 0, i];
>> dest.srcdimend = [width1, height1, i];
>> dest.dstdimstart = [0, i*height];
>> dest.srcdimend = [width1, (i*height) + (height1)];
>>
>> dest.frommatrix(source);
>> }
>>
>> Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which
>> would be
>> ideal for this sort of job.
>>
>> Joshua
>>
>> grrr waaa
>> http://www.grahamwakefield.net
>>
>>
>>
>>
>>
>> grrr waaa
>> http://www.grahamwakefield.net
>>
>>
>>
>>
>>
>>
>>
grrr waaa
http://www.grahamwakefield.net
Not necessarily because of the potential difference between
dim*planecount*sizeof(datatype)
and
dimstride
data from dimension to dimension isn’t guaranteed to be tightly packed
except for within a row.
wes
On 4/18/07, Graham Wakefield
>
> I don’t get it. I thought that internally, the matrices are all stored in a
> single array, so an ND matrix is stored sequentially, thus for example a
> [jit.matrix 3 char 2 2 2] is accessed like this:
>
> [[[r g b] [r g b]] [[r g b] [r g b]]] [[[r g b] [r g b]] [[r g b] [r g b]]]
>
> but is actually stored in memory like this:
>
> [r g b r g b r g b r g b r g b r g b r g b r g b]
>
> Since the actual size of memory isn’t changing, only the matrix_info
> interface, shouldn’t I be able to ‘change the header’ without touching the
> data?
>
>
> On Apr 17, 2007, at 9:07 PM, Wesley Smith wrote:
>
> You can use it to do the 2D slices for you, but not a oneshot
> conversion. At a minimum, you’ll need a for loop across the 3rd
> dimension.
>
> wes
>
> On 4/17/07, Graham Wakefield
>
> Ok I see now that this won’t work, because of different dimstrides. So,
> next Q: can I use _matrix_conv_info to do the dirty work, or do I really
> need to manually write out for loops?
>
>
> On Apr 17, 2007, at 8:45 PM, Graham Wakefield wrote:
>
> Hmm, I’d like to do this efficiently. Sounds like a simple jitter external;
> but my matrix SDK knowledge is rusty…
>
> Can I simply pass the data from input to output
>
> jit_object_method(out_matrix,_jit_sym_data,in_bp);
>
> and change the out_minfo.dim[0] key to be equiv. in_minfo.dim[0] *
> in_minfo.dim[1] * in_minfo.dim[2] etc., out_minfo.dimcount = 1, and so on,
> followed by
>
> err = (t_jit_err) jit_object_method(out_matrix, _jit_sym_setinfo_ex,
> &out_minfo);
>
> Or do I need to manually copy the data in for loops?
>
> Thanks
>
> On Apr 17, 2007, at 6:40 PM, Joshua Kit Clayton wrote:
>
>
>
> On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
>
>
> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr, as data
> for jit.gl.multiple and/or jit.gl.mesh. Since neither multiple nor mesh
> support 3D matrices, I’m wondering if there’s a way to efficiently convert a
> 3D matrix of arbitrary size to a 2D matrix (e.g. Nx(NxN)). I can’t figure
> it out.
>
> #1, you should be able to convert your expr to a 2D expression to begin with
> (thinking of the large 2D matrix as a tiling of a 3D matrix).
>
> However, if that doesn’t work for you, you’ll probably want to use
> jit.matrix and something like the following email client JS (or patcher
> equivalent)…watch for typos and or other oversights in the following as I
> didn’t take the time to test.
>
> dest.adapt = 0;
> dest.dim = [width, height*depth];
> dest.usesrcdim = 1;
> dest.usedstdim = 1;
>
> for (i=0;i
> {
> dest.srcdimstart = [0, 0, i];
> dest.srcdimend = [width1, height1, i];
> dest.dstdimstart = [0, i*height];
> dest.srcdimend = [width1, (i*height) + (height1)];
>
> dest.frommatrix(source);
> }
>
> Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which would be
> ideal for this sort of job.
>
> Joshua
>
> grrr waaa
> http://www.grahamwakefield.net
>
>
>
>
>
> grrr waaa
> http://www.grahamwakefield.net
>
>
>
>
>
>
>
>
>
> grrr waaa
> http://www.grahamwakefield.net
>
>
>
>
>
>
>
You mean, a matrix may have holes?
If all cells are of the same datatype, and same planecount, and row
sizes are constant between columns (etc to higher dimensions), why
would there be any holes? Or, if you’re talking about the output
matrix, since it would be a 1xM matrix only the dimstride[0] matters
(which should be sizeof(datatype)*planecount). I’m only asking
because I don’t understand. I wondered whether perhaps nD matrices
are actually sets of distinct 2D matrices and therefore not
contiguous in memory?
BTW an important point is that I do not need to worry about the order
of the cells (so long as the plane order remains constant), so
however the ‘flattening’ of the matrix reorders them, I do not mind.
But I really would like to find a simple & efficient solution so I
can drive jit.gl.mesh (@draw_mode points) and/or jit.gl.multiple with
3D (and later nD) matrices.
For Josh’s #1 solution, wouldn’t it be expensive to include modulus
terms into the expr for a 2D simulation of 3D, not to mention
making the expression itself a degree more difficult to read and
interact with? What I’m making is going to be for other people to
use, so I’d like to avoid unnecessary complications.
I tried to write something in C, but I think I would need to spend
quite a bit more time getting to know the Jitter SDK. Some kind of
recursive function call per dimension to copy each cell one by one
from source to destination, resulting in a 1xM matrix, seems the
solution, but I wouldn’t want to do this if there is a more efficient
solution.
Thanks
On Apr 17, 2007, at 10:23 PM, Wesley Smith wrote:
> Not necessarily because of the potential difference between
>
> dim*planecount*sizeof(datatype)
>
> and
>
> dimstride
>
> data from dimension to dimension isn’t guaranteed to be tightly packed
> except for within a row.
>
> wes
>
> On 4/18/07, Graham Wakefield
>>
>> I don’t get it. I thought that internally, the matrices are all
>> stored in a
>> single array, so an ND matrix is stored sequentially, thus for
>> example a
>> [jit.matrix 3 char 2 2 2] is accessed like this:
>>
>> [[[r g b] [r g b]] [[r g b] [r g b]]] [[[r g b] [r g b]] [[r g b]
>> [r g b]]]
>>
>> but is actually stored in memory like this:
>>
>> [r g b r g b r g b r g b r g b r g b r g b r g b]
>>
>> Since the actual size of memory isn’t changing, only the matrix_info
>> interface, shouldn’t I be able to ‘change the header’ without
>> touching the
>> data?
>>
>>
>> On Apr 17, 2007, at 9:07 PM, Wesley Smith wrote:
>>
>> You can use it to do the 2D slices for you, but not a oneshot
>> conversion. At a minimum, you’ll need a for loop across the 3rd
>> dimension.
>>
>> wes
>>
>> On 4/17/07, Graham Wakefield
>>
>> Ok I see now that this won’t work, because of different
>> dimstrides. So,
>> next Q: can I use _matrix_conv_info to do the dirty work, or do I
>> really
>> need to manually write out for loops?
>>
>>
>> On Apr 17, 2007, at 8:45 PM, Graham Wakefield wrote:
>>
>> Hmm, I’d like to do this efficiently. Sounds like a simple jitter
>> external;
>> but my matrix SDK knowledge is rusty…
>>
>> Can I simply pass the data from input to output
>>
>> jit_object_method(out_matrix,_jit_sym_data,in_bp);
>>
>> and change the out_minfo.dim[0] key to be equiv. in_minfo.dim[0] *
>> in_minfo.dim[1] * in_minfo.dim[2] etc., out_minfo.dimcount = 1,
>> and so on,
>> followed by
>>
>> err = (t_jit_err) jit_object_method(out_matrix, _jit_sym_setinfo_ex,
>> &out_minfo);
>>
>> Or do I need to manually copy the data in for loops?
>>
>> Thanks
>>
>> On Apr 17, 2007, at 6:40 PM, Joshua Kit Clayton wrote:
>>
>>
>>
>> On Apr 17, 2007, at 5:12 PM, Graham Wakefield wrote:
>>
>>
>> I’m trying to feed a 3D matrix (NxNxN), the output of a jit.expr,
>> as data
>> for jit.gl.multiple and/or jit.gl.mesh. Since neither multiple
>> nor mesh
>> support 3D matrices, I’m wondering if there’s a way to efficiently
>> convert a
>> 3D matrix of arbitrary size to a 2D matrix (e.g. Nx(NxN)). I
>> can’t figure
>> it out.
>>
>> #1, you should be able to convert your expr to a 2D expression to
>> begin with
>> (thinking of the large 2D matrix as a tiling of a 3D matrix).
>>
>> However, if that doesn’t work for you, you’ll probably want to use
>> jit.matrix and something like the following email client JS (or
>> patcher
>> equivalent)…watch for typos and or other oversights in the
>> following as I
>> didn’t take the time to test.
>>
>> dest.adapt = 0;
>> dest.dim = [width, height*depth];
>> dest.usesrcdim = 1;
>> dest.usedstdim = 1;
>>
>> for (i=0;i
>> {
>> dest.srcdimstart = [0, 0, i];
>> dest.srcdimend = [width1, height1, i];
>> dest.dstdimstart = [0, i*height];
>> dest.srcdimend = [width1, (i*height) + (height1)];
>>
>> dest.frommatrix(source);
>> }
>>
>> Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which
>> would be
>> ideal for this sort of job.
>>
>> Joshua
>>
>> grrr waaa
>> http://www.grahamwakefield.net
>>
>>
>>
>>
>>
>> grrr waaa
>> http://www.grahamwakefield.net
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> grrr waaa
>> http://www.grahamwakefield.net
>>
>>
>>
>>
>>
>>
>>
grrr waaa
http://www.grahamwakefield.net
On 4/18/07, Graham Wakefield
>
> You mean, a matrix may have holes?
>
I mean there may be extra bytes at the end of a row for example to 4
byte alignment purposes. If you reshape the 3D matrix such that each
2D slice is a row in very wide 2D matrix, you may end up with holes
because of the extra bytes.
wes
On Apr 18, 2007, at 12:43 AM, Graham Wakefield wrote:
> I wouldn’t want to do this if there is a more efficient solution.
Graham, I would suggest you try the solution I sent you, before you
worry about the fastest possible way. frommatrix is *quite* fast, and
when you have an NxNxN size matrix, N steps is a relatively small
fraction. jit.expr with anything nontrivial is going to be way more
expensive than this. Doing this in C is relatively simple if you want
to code it up. However, I’ll bet that the performance difference will
be negligible since you are working on optimizing something which is
most likely not the bottleneck.
FWIW, each row is 16 byte aligned (unless you use your own memory and
dimstrides which aren’t 16 byte aligned) which is what explains the
possible holes.
Joshua
On Apr 18, 2007, at 8:02 AM, Joshua Kit Clayton wrote:
>
> On Apr 18, 2007, at 12:43 AM, Graham Wakefield wrote:
>
>> I wouldn’t want to do this if there is a more efficient solution.
>
> Graham, I would suggest you try the solution I sent you, before you
> worry about the fastest possible way. frommatrix is *quite* fast,
> and when you have an NxNxN size matrix, N steps is a relatively
> small fraction. jit.expr with anything nontrivial is going to be
> way more expensive than this.
> Doing this in C is relatively simple if you want to code it up.
> However, I’ll bet that the performance difference will be
> negligible since you are working on optimizing something which is
> most likely not the bottleneck.
>
> FWIW, each row is 16 byte aligned (unless you use your own memory
> and dimstrides which aren’t 16 byte aligned) which is what explains
> the possible holes.
Right – I will do this. Thanks for all your help, both you and Wes.
"Unfortunately jit.scanwrap doesn’t work for > 2 dimensions, which
would be ideal for this sort of job."
> i guess there is still no jit.scanwrap alternative that can work for >2 dim as one simple object?
i want to fill 1d, 2d and 3d matrices with lists generated by a single multislider and do that with jit.fill for 1d and 2d, and a iter + setcell3d + expr combo for 3d. That works now fine for me. Still if anybody knows a faster way for 3d:
<code> Pasted Max Patch, click to expand. Copy all of the following text. Then, in Max, select New From Clipboard.begin_max5_patcher 1437.3oc4Z99SiaCFG+0s+UXEsSZmTGDameXuWMj.1NcHPZv1dwzITZpALKM oK0k0iS2+6K1IoD1Zcb6k5BE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