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

Question about the mkl_?omatcopy

Ye_C_1
Beginner
549 Views

I can not understand the manual about the following parameters of the function.

rows        The number of rows in matrix B (the destination matrix).

cols         The number of columns in matrix B (the destination matrix).

ldb          If ordering = 'R' or 'r' , ldb represents the number of elements in array
               b between adjacent rows of matrix B.
             
              •If trans = 'T' or 't' or 'C' or 'c' , ldb must be at least equal to rows .
             •If trans = 'N' or 'n' or 'R' or 'r' , ldb must be at least equal to cols .

              If ordering = 'C' or 'c' , ldb represents the number of elements in array
              b between adjacent columns of matrix B.

             •If trans = 'T' or 't' or 'C' or 'c' , ldb must be at least equal to cols .
             •If trans = 'N' or 'n' or 'R' or 'r' , ldb must be at least equal to rows.

Please see the code in MKL official examples.

int main(int argc, char *argv[])
{
  size_t n=3, m=5;
  double src[] = {
    1.,   2.,   3.,   4.,   5.,
    6.,   7.,   8.,   9.,   10.,
    11.,  12.,  13.,  14.,  15.
  }; /* source matrix */
  double dst[8]; /* destination matrix */
  size_t src_stride = 5;
  size_t dst_stride = 2;

  printf("\nThis is example of using mkl_domatcopy\n");

  printf("INPUT DATA:\nSource matrix:\n");
  print_matrix(n, m, 'd', src);

  /*
  **  Source submatrix(2,4) a will be transposed
  */
  mkl_domatcopy('R'        /* row-major ordering */,
                'T'        /* A will be transposed */,
                2          /* rows */,
                4          /* cols */,
                1.         /* scales the input matrix */,
                src        /* source matrix */,
                src_stride /* src_stride */,
                dst        /* destination matrix */,
                dst_stride /* dst_stride */);
  /*  New matrix: src = {
  **      1,  6,
  **      2,  7,
  **      3,  8,
  **      4,  9,
  **    }
  */
  printf("OUTPUT DATA:\nDestination matrix:\n");
  print_matrix(4, 2, 'd', dst);

  return 0;
}

The new matrix should be 4 rows and 2 cols, but in the code are 2 and 4.

If the code is correct, the rows should be explained as the rows of destination matrix without "operation".

Would you please look into the manual and give me some advice?

Thanks.

 

 

0 Kudos
3 Replies
Pamela_H_Intel
Moderator
549 Views

Thank you, Ye. It looks like the documentation is incorrect. I will verify with the MKL developers and get back to you.

Pamela

0 Kudos
Gennady_F_Intel
Moderator
549 Views

The similar issue has been already reported and we will update the documentation and will keep this thread updated accordingly.

0 Kudos
Pamela_H_Intel
Moderator
549 Views

Meanwhile - here is the corrected version:

According to our examples the description of parameters should be as follows:

rows - the number of rows in matrix A

cols - the number of columns in matrix A

alpha - this parameter scales the input matrix by alpha.

a - array of size at least lda*rows in case of Row-major ordering (ordering = 'R'). And lda*cols in case of Column-major ordering (ordering = 'C')

lda - If ordering = 'R' or 'r', lda represents the number of elements in array a between adjacent rows of matrix A; lda must be at least equal to cols. 

        If ordering = 'C' or 'c', lda represents the number of elements in array a between adjacent columns of matrix A; lda must be at least equal to rows.

b - If trans == 'R' or 'N' then it is array of size at least ldb*rows in case of Row-major ordering (ordering = 'R'). And ldb*cols in case of Column-major ordering (ordering = 'C').

     If trans == 'T' or 'C' then it is array of size at least ldb*cols in case of Row-major ordering (ordering = 'R'). And ldb*rows in case of Column-major ordering (ordering = 'C').

ldb - If ordering = 'R' or 'r', lda represents the number of elements in array a between adjacent rows of matrix B; ldb must be at least equal to cols if trans=='R' or 'N'. And rows if trans=='C' or 'T'

        If ordering = 'C' or 'c', lda represents the number of elements in array a between adjacent columns of matrix B; ldb must be at least equal to rows if trans=='R' or 'N'. And cols if trans=='C' or 'T'

 

The same changes should be applied to ?omatcopy2 routine + the following:

stridea - If ordering = 'R' or 'r', stridea represents the number of elements in array 'a' between adjacent columns of matrix A. stridea must be at least 1.

              If ordering = 'C' or 'c', stridea represents the number of elements in array 'a' between adjacent rows of matrix A. stridea must be at least 1.

strideb - If ordering = 'R' or 'r', strideb represents the number of elements in array 'b' between adjacent columns of matrix B. strideb must be at least 1.

              If ordering = 'C' or 'c', strideb represents the number of elements in array 'b' between adjacent rows of matrix B. strideb must be at least 1.

0 Kudos
Reply