Я даю 8×8 входных данных для моего кода дискретного косинусного преобразования (DCT) на основе MKL:
«fileinput.txt» ВХОД:
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255
DCT ВЫХОД ИЗ НИЖЕГО КОДА как:
32385 -727.349243 -619.955444 -458.675903 -267.323547 -74.151535 92.318069 207.505844
764.404419 717.50531 602.316772 435.846893 242.6754 51.322887 -109.956779 -217.350159
-762.619629 -706.582764 -583.869446 -412.598663 -218.058334 -28.972321 126.74057 226.088898
759.648132 694.603516 564.651367 388.979492 193.525208 7.147152 -142.635284 -233.70639
-755.498901 -681.59967 -544.712891 -365.049927 -169.138 14.096443 157.598663 240.180206
750.180115 667.597656 524.094971 340.860809 144.948898 -34.714363 -171.600922 -245.499771
-743.705566 -652.633789 -502.85144 -316.473694 -121.019257 54.652824 184.604614 249.648224
736.088623 636.739502 481.026154 291.940552 97.400169 -73.870857 -196.583725 -252.620102
ОЖИДАЕМЫЙ ВЫХОД:
16320 8.331551 -8.493903 8.775995 -9.19324 9.772106 -10.552611 11.595706
8.332954 0.004307 -0.004317 0.004504 -0.00472 0.004989 -0.005391 0.00592
-8.494178 -0.004317 0.004454 -0.004576 0.004765 -0.005109 0.005472 -0.006031
8.776941 0.004504 -0.004545 0.004746 -0.004965 0.005248 -0.005666 0.006251
-9.193484 -0.004659 0.004811 -0.00495 0.005198 -0.005507 0.005955 -0.006519
9.771847 0.005035 -0.005079 0.005241 -0.005522 0.005852 -0.006314 0.00696
-10.552428 -0.005383 0.005533 -0.005627 0.00591 -0.006314 0.006844 -0.007483
11.59587 0.005882 -0.00605 0.006274 -0.006557 0.006974 -0.007506 0.008264
КОД:
#include <time.h>
#include <stdlib.h>
#include "mkl.h"#include "iostream"using namespace std;
int main(int argc, char* argv[]){
float *dpar;
float *out;
MKL_INT *ipar;
MKL_INT tt_type,stat,n_1,nn;
FILE *fp;
fp = fopen( "D:\\fileinput.txt","r" );if(fp == NULL){
cout<<"file not created properly"<<endl;
}
printf("\n===== DCT CODE ======== \n");
DFTI_DESCRIPTOR_HANDLE handle = 0;
int n = 64;//8x8 matrix;
nn = (MKL_INT)n;
tt_type = MKL_COSINE_TRANSFORM;
n_1 = nn + 1 ;
out = (float*)malloc((n+1)*sizeof(float));
dpar= (float*)malloc((5*n_1/2+2)*sizeof(float));
ipar= (MKL_INT*)malloc((128)*sizeof(int));
s_init_trig_transform(&n_1,&tt_type,ipar,dpar,&stat);
for (int srcSize =0 ;srcSize< n ; srcSize++)
{
fscanf(fp,"%f\n",&out[srcSize]);
}
fclose(fp);
if (stat != 0)
{
printf("\n============================================================================\n");
printf("FFTW2MKL FATAL ERROR: MKL TT initialization has failed with status=%d\n",(MKL_INT)stat);
printf("Please refer to the Trigonometric Transform Routines Section of MKL Manual\n");
printf("to find what went wrong...\n");
printf("============================================================================\n");
return NULL;
}
ipar[10] = 1; //nx, that is, the number of intervals along the x-axis, in the Cartesian case.
ipar[11] = 1; //ny, that is, the number of intervals along the x-axis, in the Cartesian case.
ipar[14] = n_1; //specifies the internal partitioning of the dpar array.
ipar[15] = 1; //value of ipar[14]+1,Specifies the internal partitioning of the dpar array.
s_commit_trig_transform(out,&handle,ipar,dpar,&stat);
if (stat != 0)
{
printf("\n============================================================================\n");
printf("FFTW2MKL FATAL ERROR: MKL TT commit step has failed with status=%d\n",(MKL_INT)stat);
printf("Please refer to the Trigonometric Transform Routines Section of MKL Manual\n");
printf("to find what went wrong...\n");
printf("============================================================================\n");
return NULL;
}
s_forward_trig_transform(out,&handle,ipar,dpar,&stat);
if (stat != 0)
{
printf("\n============================================================================\n");
printf("FFTW2MKL FATAL ERROR: MKL TT commit step has failed with status=%d\n",(MKL_INT)stat);
printf("Please refer to the Trigonometric Transform Routines Section of MKL Manual\n");
printf("to find what went wrong...\n");
printf("============================================================================\n");
return NULL;
}
free_trig_transform(&handle,ipar,&stat);
printf("\n===== DCT GOT OVER ======== \n");return 0;
}
Можете ли вы направить меня, чтобы выяснить, какую ошибку я совершаю в своем коде
Больше вопроса, чем ответа. Эти 4 строки правильны?
ipar[10] = 1; //nx, that is, the number of intervals along the x-axis,
ipar[11] = 1; //ny, that is, the number of intervals along the x-axis,
ipar[14] = n_1; //specifies the internal partitioning of the dpar array.
ipar[15] = 1; //value of ipar[14]+1,Specifies the ... of the dpar array.
В первых двух случаях число интервалов действительно равно 1?
В четвертом случае комментарий гласит, что ipar[15]
это значение ipar[14]+1 = n_1 + 1 = nn + 2 = n + 2 = 66
хотя мы не знаем, что происходит с n_1
в s_init_trig_transform()
,