Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Failed to call DGELSS from C#

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-27-2010
11:54 AM

236 Views

Failed to call DGELSS from C#

Trying to access

When I call this function nothing happens. All output parameters remain at the same values they had before the call. Absolutely nothing. Perhaps I am not calling correctly into the MKL library? I don't know

Attached is a Visual Studio (2005) solution with a very simple example. Note: the sample also calls

Please advise,

Thanks,

Roy.

Link Copied

13 Replies

Vladimir_Koldakov__I

New Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-28-2010
01:55 AM

236 Views

Hi Roy,

There are 4 errors in your code.

1.Skipped first argument: int matrix_order

2. Extra INFO argument: c-lapack interface justreturnsINFO as function value

3.If you use WORK array, use _work version of interface: clapack_dgelss_work

4. Use LWORK = -1 to calculate the optimal size of the array work

Below are minimal changes for successful work.

Thanks,

Vladimir

$ diff Program.cs-orig Program.cs

226c226

< int LWORK = 1;

---

> int LWORK = -1;

233c233

< CMKL.dgelss(m_numRows, // M - The number of rows in the A matrix

---

> info = CMKL.dgelss(m_numRows, // M - The number of rows in the A matrix

244,245c244,245

< LWORK, // LWORK - The dimension of the array WORK

< info); // = 0: successful exit

---

> LWORK // LWORK - The dimension of the array WORK

> ); // = 0: successful exit

297c297

< public static void dgelss(int M, int N, int NRHS,

---

> public static int dgelss(int M, int N, int NRHS,

302c302

< int LWORK, [Out] int INFO)

---

> int LWORK)

304c304

< CMKLNative.clapack_dgelss(M, N, NRHS, A, lda, B, ldb, S, RCOND, iRANK, WORK, LWORK, INFO);

---

> return CMKLNative.clapack_dgelss_work(1,M, N, NRHS, A, lda, B, ldb, S, RCOND, iRANK, WORK, LWORK);

340c340

< internal static extern void clapack_dgelss(

---

> internal static extern int clapack_dgelss_work( int matrix_order,

352,353c352,353

< int LWORK, // The dimension of the array WORK

< [Out] int INFO); // = 0: successful exit

---

> int LWORK // The dimension of the array WORK

> ); // = 0: successful exit

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-28-2010
06:09 AM

236 Views

Thank ... we're progressing.

Nevertheless, even with your points applied, the return value I receive is always -1012.

Attached is the updated program ...appreciatevery much your advise.

Thanks,

Roy.

Roy.

Vladimir_Koldakov__I

New Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-28-2010
09:11 AM

236 Views

Roy,

The beta version has inconsistent C-LAPACK and CBLAS constants. You can find in the MKL/include/mkl_clapack.h header file following values:

#define CLAPACK_ROW_MAJOR 0

#define CLAPACK_COL_MAJOR 1

#define CLAPACK_WORK_MEMORY_ERROR -1010

#define CLAPACK_TRANSPOSE_MEMORY_ERROR -1011

#define CLAPACK_ORDER_ERROR -1012

So -1012 means wrong matrix_order value. Use please 0 instead of CMKL.ORDER.RowMajor.

Also use ref int iRANK for C-declared pointers to scalars: clapack_int* rank => ref int rank.

Below are minimal changes for successful work.

Thanks,

Vladimir

$ diff Program.cs Program.cs-orig

238c238

< 0, // The matrix order - whether the two-dimensional arrays are row-major (CLAPACK_ROW_MAJOR) or column-major (CLAPACK_COL_MAJOR).

---

> CMKL.ORDER.RowMajor, // The matrix order - whether the two-dimensional arrays are row-major (CLAPACK_ROW_MAJOR) or column-major (CLAPACK_COL_MAJOR).

302c302

< return CMKLNative.clapack_dgelss(matrix_order, M, N, NRHS, A, lda, B, ldb, S, RCOND, ref iRANK);

---

> return CMKLNative.clapack_dgelss(matrix_order, M, N, NRHS, A, lda, B, ldb, S, RCOND, iRANK);

356c356

< ref int iRANK); // The effective rank of A, i.e., the number of singular values which are greater than RCOND*S(1)

---

> [Out] int iRANK); // The effective rank of A, i.e., the number of singular values which are greater than RCOND*S(1)

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-31-2010
02:20 AM

236 Views

Almost there.

Although the function now returns info = 0, the results themselves are not correct yet.

Attached is a zip in which I try to solve the following equation:

A X B

------ --- ---

1 2 3 1 17

4 5 6 * 2 = 38

7 8 10 3 63

The results I actually get in X are --> (-8.78 E 275, 38, 63). Notice how the two last elements are actually remnantsof the old B vector.

Note: just out ofcuriosity, I did try to give the DGELSS a ColMajor option (although I believe I work in RowMajor). I did get "better" results. X -->(26.333, -9.333, 4.00). Notice how the 4.00 is part of the correct answer, but the other 2 elements are not correct.

Please advise,

Thanks,

Roy.

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-01-2010
11:05 PM

236 Views

Can anyone help on this?

I fail to get correct results from DGELSS.

Zip file with sample problem (in C#) is attached to previous post.

Thanks,

Roy.

Roy.

Vladimir_Koldakov__I

New Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-09-2010
10:35 PM

236 Views

Roy, your actual data are

A X B

------ --- ---

1 2 3 1 17

4 5 6 * 2 = 38

7 8 10 **4 ** 63

As you use row-major order you should set ldb=1. just replace:

B.Length, // ldb - The leading dimension of the array B

with 1. After that I have:

0.99999999999998823

2.0000000000000044

4.0000000000000044

Also lda should be m_numColumns.

-Vladimir

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-10-2010
04:06 AM

236 Views

I know understand how to use DGELSS.

Please note that the documentation is misleading.

- m -INTEGER. The number of rows of the matrix
`A`().`m`0 - n -INTEGER. The number of columns of the matrix
`A`().`n`0 - lda -INTEGER. The first dimension of
`a`; at least max(1,`m`). - ldb -INTEGER. The first dimension of
`b`; must be at least max(1,`m`,`n`).

Thanks anyway,

Roy.

Vladimir_Koldakov__I

New Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-10-2010
10:06 AM

236 Views

Roy, thank you for the comments.

Please look at the announcement http://software.intel.com/en-us/articles/c-interface-for-lapack/

You can find there more details in the C interface to LAPACK technical paper, in particular:

*LAPACK routines use a stride corresponding to the FORTRAN leading dimension (LDA) with all 2D arrays. We must do the same. For RowMajor matrices, elements within a row are assumed to be contiguous and elements from one row to the next are assumed to be a stride/leading dimension apart.*

-Vladimir

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-14-2010
08:39 AM

236 Views

Amazingly, we need to reopen this issue.

We are extremely frustrated!!!

We have upgraded from 10.3 beta to the official 10.3 release version.

Immediately thereafter, our application stopped working. Going back to the sample we sent you (Test_DGELSS.zip) we see an error "

We also noticed on the 10.3 release notes that the C interface had changed (http://software.intel.com/en-us/articles/c-interface-for-lapack/). Is that related?

Release 10.3 veresion (not working)

------------------------------------------

mkl_rt.dll 10.3.0.1

Beta 10.3 veresion (working)

----------------------------------

mkl_rt.dll 10.3.0.0

Please Help ASAP.

Thanks,

Roy.

Vladimir_Koldakov__I

New Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-15-2010
12:15 AM

236 Views

Yes, interface names have been changed.

Please use 10.3 LAPACKE_dgelss instead of 10.3 beta clapack_dgelss.

Thanks,

Vladimir

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-15-2010
03:14 AM

236 Views

Thank-you for the quick response.

After changing the function name, my application does not show anymore the error it previously shown ("**Unable to find an entry point named 'clapack_dgelss' in DLL 'mkl_rt'**.").

Nevertheless, the return code I receive from the function is -1.

I have attached the entire solution so you could have a look.

Please check this so we can resolve this issue quickly ... unfortuatly, we are now 3 weeks trying to solve the same problem and frankly, somewhat fed up with it. We seriously consider ditching MKL and finding an alternative solution.

Thanks,

Roy.

Roy.

Vladimir_Koldakov__I

New Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-15-2010
04:02 AM

236 Views

Roy,

Sorry, forgot to say that matrix_order constants have been changed also to the more natural values.

Please replace CMKL.CLAPACK_ORDER.RowMajor with CMKL.ORDER.RowMajor.

Thanks,

Vladimir

Roy_Tal

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-15-2010
04:07 AM

236 Views

Yes ... I have just reached the same conclusion myself.

Now, my program is working again (and also the test program - TEST_DGELSS)

Thanks for your prompt response,

Roy.

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.