2

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?

Kabua
  • 889
  • 8
  • 19
  • 1
    Are you sure, both `data` sources are equal? Can you try to import the one used in Matlab (using `ILMatFile`) and compare: `data.Equals(dataFromMatlab)` – Haymo Kutschbach May 02 '14 at 08:12
  • It might be easier to find out by using some smaller test data: `data = counter(1.0,1.0,8,1)`... There is nothing obviously wrong with your indexing. – Haymo Kutschbach May 02 '14 at 08:14
  • @HaymoKutschbach thanks for the `ILMatFile` tip. I was able to use this idea (plus `dif = data[abs(data - dataFromMatlab) > 0.00001]`) to test for equality. It turned out that my version of `histc()` had an off-by-one error. – Kabua May 02 '14 at 15:04
  • @Kaboo: I m also working on a DCT in c#, have some working code in matlab for a 3d DCT. Just started to look at ILNumerics for this. Could you please post the entire DCT code? – nik May 31 '14 at 13:59

1 Answers1

1

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 ]

Kabua
  • 889
  • 8
  • 19