linear algebra - MKL dtrsv wrong output -


i trying use 'cblas_dtrsv' not right output , not know why. here example(dtrsv_example.c)

#include <stdio.h> #include <stdlib.h> #include "mkl.h"  int main() {   double *a, *b, *x;   int m, n, k, i, j;    m = 4, k = 4, n = 4;    printf (" allocating memory matrices aligned on 64-byte boundary better \n"       " performance \n\n");   = (double *)mkl_malloc( m*k*sizeof( double ), 64 );   b = (double *)mkl_malloc( n*sizeof( double ), 64 );   x = (double *)mkl_malloc( n*sizeof( double ), 64 );    if (a == null || b == null || x == null) {     printf( "\n error: can't allocate memory matrices. aborting... \n\n");     mkl_free(a);     mkl_free(b);     mkl_free(x);     return 1;   }     a[0] = 11;   (i = 0; < m; i++) {     (j = 0; j <= i; j++) {       a[j + i*m] = (double)(j+i*m);     }   }  (i = 0; < n; i++) {     x[i] = (i+1)*5.0;   }   printf ("\n computations completed.\n\n");    printf ("\n result x: \n");   (j = 0; j < n; j++) {     printf ("%f\n", x[i]);   }     printf ("\n deallocating memory \n\n");   mkl_free(a);   mkl_free(b);   mkl_free(x);    printf (" example completed. \n\n");   return 0; } 

compilation seems fine:

icc -c -wall   -c -o dtrsv_example.o dtrsv_example.c icc dtrsv_example.o -o dtrsv_example -l/opt/intel/mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm 

however, wrong result:

./dtrsv_example computations completed.    result x:  0.000000 0.000000 0.000000 0.000000   deallocating memory    example completed.  

any ideas of might doing wrong here?

even though thought had checked it, after break realized of beginner mistake:

  (j = 0; j < n; j++) {     printf ("%f\n", x[i]);   } 

it should x[j] instead! other people can use example understand how cblas_dtrsv interface used.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -