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

Possible bug (or misleading documentation) in mkl_zcsradd

Massimiliano_Culpo
281 Views
Hi,

I found a possibly wrong behavior of the function mkl_zcsradd, isolated in the example below:
[fortran]program csradd

  implicit none

  ! Matrix A
  integer    :: aia (1:4)
  integer    :: aja (1:5)
  complex(8) :: aval(1:5)
  ! Matrix B
  integer    :: bia (1:4)
  integer    :: bja (1:2)
  complex(8) :: bval(1:2)
  ! Matrix C
  integer    :: cia (1:4)
  integer    :: cja (1:7)
  complex(8) :: cval(1:7)
  ! MKL variables
  integer    :: info
  integer    :: request
  integer    :: nrow = 3
  integer    :: ncol = 3
  integer    :: sort = 3
  integer    :: nnz  = 7
  complex(8) :: beta = cmplx(1.0d0,0.0d0,8)
  
  ! Set Matrix A
  aia     = (/ 1, 3, 4, 6 /)
  aja     = (/ 1, 3, 2, 1, 2 /)
  aval(1) = cmplx(1.0d0,0.0d0,8)
  aval(2) = cmplx(3.0d0,0.0d0,8)
  aval(3) = cmplx(4.0d0,0.0d0,8)
  aval(4) = cmplx(5.0d0,0.0d0,8)
  aval(5) = cmplx(0.0d0,4.0d0,8)
  ! Set Matrix B
  bia     = (/ 1, 1, 2, 3 /)
  bja     = (/ 3, 3 /)
  bval(1) = cmplx(2.0d0,0.0d0,8)
  bval(2) = cmplx(2.0d0,0.0d0,8)
  ! C = A + B
  request = 1
  call mkl_zcsradd("N",request,sort,nrow,ncol,aval,aja,aia,beta,bval,bja,bia,cval,cja,cia,nnz,info)
  print *, info
  print *
! nnz = size(cja) (as in MKL documentation)
request = 0 call mkl_zcsradd("N",request,sort,nrow,ncol,aval,aja,aia,beta,bval,bja,bia,cval,cja,cia,nnz,info) print *, info print *, cja print * ! nnz = size(cja) + 1
request = 0 call mkl_zcsradd("N",request,sort,nrow,ncol,aval,aja,aia,beta,bval,bja,bia,cval,cja,cia,nnz+1,info) print *, info print *, cja end program csradd [/fortran]
The program is compiled with the command:
[bash]ifort -O0 -warn all csradd.f90 -lmkl_intel -lmkl_sequential -lmkl_core[/bash]
and gives the following output:
[bash]           0
 
           3
           1           3           2           3           1           2
           0
 
           0
           1           3           2           3           1           2
           3
[/bash]
In the documentation it is written:
[xml]nzmax    INTEGER. The length of the arrays c and jc.[/xml]
while it seems that for the function to work correctly nzmax must be set to:
[fortran]nzmax = size(jc) + 1[/fortran]
I would like to ask if this behavior is reproducible by anyone.

Also, if the problem will be confirmed, I am not sure if it is really a bug or just a typo in the documentation.

Massimiliano
0 Kudos
3 Replies
Gennady_F_Intel
Moderator
281 Views

Massimiliano,

Yes, I reproduced the behavior.This is the bug in the code.The documentation is correct.Nzmax must be equal size(jc) as originally is pointed into manual.

--Gennady

0 Kudos
Gennady_F_Intel
Moderator
281 Views
Hi Massimiliano. The problem you reported has been fixed in Update 5 available now. Please check the problem and let us know the resullts.
--Gennady
0 Kudos
Massimiliano_Culpo
281 Views
Hi Gennady,
sorry for the late answer. I just checked the test and now it works fine. The new output is:

[bash]0
 
0
1           3           2           3           1           2
3
 
0
1           3           2           3           1           2
3
[/bash]

Massimiliano
0 Kudos
Reply