Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2013
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include <WolframLibrary.h>
  5. #include <mkl_lapacke.h>
  6.  
  7. DLLEXPORT mint WolframLibrary_getVersion( ) {
  8.     return WolframLibraryVersion;
  9. }
  10.  
  11. DLLEXPORT int WolframLibrary_initialize( WolframLibraryData libData) {
  12.     return 0;
  13. }
  14.  
  15. DLLEXPORT void WolframLibrary_uninitialize( WolframLibraryData libData) {
  16.     return;
  17. }
  18.  
  19. DLLEXPORT int zheev(
  20.         WolframLibraryData libData,
  21.         mint argc,
  22.         MArgument *args,
  23.         MArgument res) {
  24.     MTensor input = MArgument_getMTensor(args[0]);
  25.     MKL_Complex16 *data = (MKL_Complex16*) libData->MTensor_getComplexData(input);
  26.     const mint *dims = libData->MTensor_getDimensions(input);
  27.    
  28.     MKL_INT n = dims[0], info, lda = n;
  29.    
  30.     double *w = (double*) malloc(n*sizeof(double));
  31.    
  32.     info = LAPACKE_zheev(LAPACK_ROW_MAJOR, 'V', 'L', n, data, lda, w);
  33.    
  34.     if (info > 0) {
  35.         free(w);
  36.         return LIBRARY_NUMERICAL_ERROR;
  37.     }
  38.    
  39.     MArgument_setMTensor(res, input);
  40.     return LIBRARY_NO_ERROR;
  41.    
  42. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement