sptensor/full: does not work on tensors created from file using import_data()
When creating an sptensor using sptenrand
or sptensor
, the values in the subs
field are double
. But when importing an sptensor from file using import_data()
, the values in the subs
field are int32
. The impact of this difference is that full
results in an error, as Matlab does not know how to handle the int32
values in tt_sub2ind()
, which is called from sptensor/full
.
Below is an example of the behavior. The file sptensor_small.tns
is attached, and is a copy of A2
below.sptensor_small.tns
>> A1 = sptenrand([3,4,5],.1);
>> class(A1.subs)
ans =
double
>> A2 = sptensor([1 1 1;2 2 2;3 3 3],[1 2 3]',[3 3 3]);
>> class(A2.subs)
ans =
double
>> A3 = import_data('sptensor_small.tns');
>> class(A3.subs)
ans =
int32
>> B1=full(A1);
>> B2=full(A2);
>> B3=full(A3);
Error using *
MTIMES is not fully supported for integer classes. At least one input must be scalar.
To compute elementwise TIMES, use TIMES (.*) instead.
Error in tt_sub2ind (line 28)
idx = (subs - 1) * mult' + 1;
Error in sptensor/full (line 37)
idx = tt_sub2ind(siz,A.subs);