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

dgelss will output incorrect result when matrix = [100, 3]

Hai
Beginner
554 Views

Hi,

I am using dgelss to simulate same result as pinv() in Matlab. When I set matrix to be [10, 3], the result is correct. But when I change the matrix size to be [100, 3], then the outcome will become a matrix with most elements to be 0.

Any input will be welcome.

Thanks

Hai

0 Kudos
6 Replies
Chao_Y_Intel
Moderator
554 Views

Hai,

Do you have a test code that could show this problem?

Regards,

Chao

0 Kudos
Hai
Beginner
554 Views

Did someone else have similar problem?

0 Kudos
mecej4
Honored Contributor III
554 Views

Did someone else have similar problem?

Merely asking that question, instead of describing your problem in sufficient detail, is not likely to lead to answers.

Here is an example that shows GELSS working correctly for a 100 X 3 matrix. Therefore, the MKL implementation of GELSS works for some inputs. If you have an input for which it fails to give correct results, please publish the example. [fortran] program gelss_example USE MKL95_LAPACK, ONLY: GELSS !DEC$ OBJCOMMENT lib:'mkl_lapack95' implicit none integer, parameter :: dp=kind(1d0) integer, parameter :: M=100,N=3 integer :: i,j,k real(dp) :: A(M,N),x(N),B(M),delta(M) ! ! create test problem ! call RANDOM_NUMBER(A); call RANDOM_NUMBER(delta) x(1)=2.718; x(2)=3.1425; x(3)=0.1729 A=(2*A-1)*10 ! random numbers between -10 and +10 B=MATMUL(A,x)+(2*delta-1)*0.01 ! call GELSS(A,B) write(*,10)x,B(1:N) 10 format(' Original x used to create B: ',3F8.5,/, & ' GELSS results for x : ',3F8.5) end program gelss_example [/fortran]

Compiling and running on Windows using

[bash] ifort /Qmkl xgelss.f90[/bash]

I get the output

[bash] Original x used to create B: 2.71800 3.14250 0.17290 GELSS results for x : 2.71796 3.14250 0.17291 [/bash]

0 Kudos
Hai
Beginner
554 Views

I already sent my code to Chao Y who help me provided a temporary solution which can calculate dgelss correctly for a 100x3 matrix.

I am not sure how Fortran code works. But my code works fine for a matrix with size 10x3. But when I change the matrix size to 100x3 or larger, the results will be almost zeros.

Thanks for your input.

0 Kudos
Chao_Y_Intel
Moderator
554 Views

Thanks, Hai for the code.  yes, we could verify this is a bug, and will fix it in the future release soon.  I am also checking if there is any workaound for this problem.

Regards,
Chao

0 Kudos
Sergey_K_Intel1
Employee
554 Views

Dear Hai,

The problem comes from your code. Your reproducer has internal error: lwork query was done for the parameters differs from those of the second call of functionality.

According to the MKL Reference Guide  the size of work array for dgelss depends on the first three input parameters. You call dgelss for determining the size of workspace for the set (m, n, n)

dgelss(&m, &n, &n ...

where m=100 and n=3. Meanwhile the second call is for another set of parameters (m, n, m)

dgelss(&m, &n, &m, ..

BUT the values  of these parameters must be identical for both calls.

All the best

Sergey

0 Kudos
Reply