Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Coding error?

flashnik
Beginner
1,311 Views
Hello!

I'm trying to use MKL in my C# project.

But I get an exception even in such a simple function as dgetrf.



In this example I want to factorize matrix {(2,0),(0,1)}



[DllImport("C:\IA32\bin\mkl_lapack64.dll" )]

static extern int dgetrf(ref int m,ref int n, ref double[] a,ref int lda,ref int[] ipiv,ref int info);



private void button1_Click(object sender, EventArgs e)

{

double[] a = (double[])Array.CreateInstance(typeof(double),4);

a[0] = 2;

a[1] = 0;

a[2] = 0;

a[3] = 1;

int[] ipiv=(int[])Array.CreateInstance(typeof(int),2);

int info=0;

int m=2,n=2;

int lda =2;

dgetrf(ref m,ref n,ref a,ref lda,ref ipiv, ref info);

}



The exception is 'System.AccessViolationException'.Attempted to read or write protected memory.



Possibly you could tell me where I'm mistaken.



if I set lda=1 I don't get the exception but info returns -4.

Message Edited by flashnik on 03-28-200603:14 PM

Message Edited by flashnik on 03-28-200603:16 PM

0 Kudos
3 Replies
ttppo
Beginner
1,311 Views
dgetrf(ref m,ref n,ref a,ref lda,ref ipiv, ref info)?

If dgetrf is call by C-code:
dgetrf(&m,&n,a,&lda,ipiv,&info);

so the problem is...
0 Kudos
bo_y_
Beginner
1,311 Views

hi flashnik

​any luck with your problem? i've got similar situation here.

 

0 Kudos
Ying_H_Intel
Moderator
1,311 Views

Hi Bo,

We had some example for how to call MKL function in C#.  You may download the Intel_MKL_C#_Examples.zip from

https://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program

and try them to see if you can run them first.

Best Regards,

Ying

0 Kudos
Reply