   float *a_data = THCudaTensor_data(state, a);
   float *b_data = THCudaTensor_data(state, b);
 
-  int *ipiv = th_magma_imalloc_pinned(n);
+  int *ipiv = th_magma_malloc_pinned<int>(n);
 
   int info;
   magma_sgesv_gpu(n, nrhs, a_data, n, ipiv, b_data, n, &info);

}

#ifdef USE_MAGMA
static inline float* th_magma_smalloc_pinned(size_t n)
{
  float* ptr;
  if (MAGMA_SUCCESS != magma_smalloc_pinned(&ptr, n))
    THError("$ Torch: not enough memory: you tried to allocate %dGB. Buy new RAM!", n/268435456);
  return ptr;
}

static inline int* th_magma_imalloc_pinned(size_t n)
{
  int* ptr;
  if (MAGMA_SUCCESS != magma_imalloc_pinned(&ptr, n))
    THError("$ Torch: not enough memory: you tried to allocate %dGB. Buy new RAM!", n/268435456);
  return ptr;
}

static void THCudaTensor_copyArray1d(THCState *state, THCudaTensor *self, float *src, int k)

  magma_sgeev(MagmaNoVec, jobvr, n, a_data, n, wr, wi, NULL, 1, vr_data, ldvr, &wkopt, -1, &info);

  int lwork = (int) wkopt;
  float *work_data = th_magma_malloc_pinned<float>(lwork);

  magma_sgeev(MagmaNoVec, jobvr, n, a_data, n, wr, wi, NULL, 1, vr_data, ldvr, work_data, lwork, &info);

