Question

I'm trying to convert some code from Matlab into ILNumerics and everything was working find until I needed to fold an array. Like so:

MatLab's original Version:

d1 = data(1:2:end,:);  % test code.
d2 = data(end:-2:2,:); % test code.
data = [ data(1:2:end,:); data(end:-2:2,:) ]; % original code.
dct = weight .* fft(data);

ILNumerics converted Version:

ILArray<double> d1 = data[r(0, 2, end), full];
ILArray<double> d2 = data[r(end, -2, 1), full];
data = data[r(0, 2, end), full].Concat(data[r(end, -2, 1), full], 0);
ILArray<complex> dct = weights * fft(data);

data is a <16384x1 double> and d1 and d2 are <8192x1 double> and the sizes between both versions match. But when I check d1's and d2's max() values, against IL's version, they aren't the same. And the values I get from fft(data) don't match either.

Are my ILNumerics indexing offsets wrong or something else?

Was it helpful?

Solution

Found my bug, it was an off-by-one error located earlier in the code. The idea to use ILMatFile, suggested by @haymonkutschbach, helped me tracked it down. See comments above.

Edit: the test I used was dif = data[abs(data - dataFromMatlab) > 0.000000000000001 ]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top