2014-12-23 70 views
0

我想通過使用mkl.lib DCT函數替換ipp.lib DCT函數。 我用下列基於伊普API做DCT:mkl庫DCT函數實現問題

ippsDCTFwdInitAlloc_32f 
ippsDCTFwd_32f 
ippsDCTFwdFree_32f 

PFB我MKL基於DCT的示例代碼:

#include <time.h> 
#include <stdlib.h> 
#include "mkl.h" 
int main(int argc, char* argv[]){ 

    float *dpar; 
    float *out; 
    MKL_INT *ipar; 
    MKL_INT tt_type,stat,n_1,nn; 
    FILE *fp,*fw,*fonce; 
    fp = fopen("D:\\dump\\fileinput.txt","r"); 
    if(fp == NULL){ 
     cout<<"file not created properly"<<endl; 
    } 
    DFTI_DESCRIPTOR_HANDLE handle = 0; 
    int n = 150; /*Hardcoded to run for my code TODO: going to change after integrating into my main codebase.As I can't attach my full fileinput.txt .So just taken n value = 150 */ 
    nn = (MKL_INT)n; 
    tt_type = MKL_STAGGERED_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[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; 

} 

但我沒有得到正確的輸出。我感到困惑,我的執行是否正確。

因爲我不知道如何附加我的fileinput.txt,所以我把文件內容放在這裏。 對不起,該:(

129.000000 128.000000 145.000000 140.000000 102.000000 93.000000 100.000000 97.000000 94.000000 88.000000 58.000000 67.000000 
79.000000 62.000000 62.000000 64.000000 63.000000 63.000000 70.000000 80.000000 61.000000 62.000000 63.000000 64.000000 
62.000000 78.000000 66.000000 65.000000 68.000000 74.000000 78.000000 66.000000 67.000000 76.000000 67.000000 65.000000 
76.000000 83.000000 66.000000 66.000000 65.000000 66.000000 72.000000 80.000000 65.000000 66.000000 69.000000 80.000000 
75.000000 66.000000 71.000000 80.000000 69.000000 80.000000 85.000000 70.000000 77.000000 68.000000 67.000000 80.000000 
83.000000 69.000000 71.000000 73.000000 69.000000 70.000000 71.000000 71.000000 70.000000 71.000000 88.000000 86.000000 
78.000000 78.000000 70.000000 73.000000 81.000000 83.000000 76.000000 75.000000 72.000000 72.000000 73.000000 75.000000 
79.000000 76.000000 80.000000 87.000000 84.000000 79.000000 73.000000 72.000000 72.000000 72.000000 73.000000 79.000000 
76.000000 74.000000 76.000000 78.000000 76.000000 74.000000 73.000000 76.000000 78.000000 78.000000 73.000000 74.000000 
73.000000 72.000000 72.000000 73.000000 75.000000 77.000000 76.000000 75.000000 74.000000 74.000000 75.000000 78.000000 
81.000000 78.000000 75.000000 74.000000 74.000000 74.000000 75.000000 77.000000 79.000000 80.000000 81.000000 78.000000 
76.000000 75.000000 74.000000 74.000000 74.000000 75.000000 76.000000 76.000000 75.000000 77.000000 78.000000 79.000000 
80.000000 79.000000 79.000000 79.000000 78.000000 76.000000 76.000000 76.000000 76.000000 77.000000 77.000000 77.000000 
78.000000 80.000000 80.000000 80.000000 80.000000 80.000000 78.000000 78.000000 78.000000 78.000000 78.000000 80.000000 
+0

我會檢查這個。但至少運行你的代碼,因爲它是,您應該使用「COUT」或「printf」上。或者添加#「的iostream」 using namespace std; – Ashwin

回答

0

我覺得你說的這些函數的參數DPAR。 實際上,它們不被用於計算的結果。他們只是用來存儲中間正弦/餘弦數據在TT計算用於

對於運算功能: d_forward_trig_transform(雙F [],DFTI_DESCRIPTOR_HANDLE *手柄,MKL_INT IPAR [],雙DPAR [],MKL_INT * STAT);

兩者輸入。和輸出是F [],它是相同的大小 以獲取更多信息,您可以參考以下鏈接: link here

+0

它幫助我理解了一些觀點,但它仍然不能解決問題! –