I have a two dimensional array 'v' representing a list of vectors And I have a three dimensional array 'a' that represents a list of matrices
ILArray v = counter(2, 3);
ILArray a = counter(2, 3, 3);
Now I want to take a subarray of both and do a matrix multiply:
ILArray av = multiply(a[1,full,full], v[1,full]);
It will complain that the dimensions do not match and this is because the dimensions of a[1,full,full]
is (1,3,3)
and of v[1,full]
is (1,3)
. In other words, the subarrays contain a singleton dimension. In matlab I can remove these singleton dimensions with squeeze(). But how can I do that in ILNumerics?
I just discovered that if the singleton dimension are trailing, then they are automagically removed by ILNumerics, so this works:
ILArray v = counter(3, 2);
ILArray a = counter(3, 3, 2);
ILArray av = multiply(a[full,full, 1], v[full, 1]);
Also, a[full,full,1]
has dimension (3,3)
and not (3,3,1)
.
Does that mean that ILNumerics does not support non-trailing singleton dimensions? In other words, does not support strided arrays in calculations but only contiguous ones? That would be rather restrictive to say the least.
Thanks, Luc
Shouldn’t a simple reshape do the trick?
Having a
squeeze
function would be more convenient. You may open a feature request on the bugtracker in order to have it implemented in one of the next releases: http://ilnumerics.net/mantis