<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic The complex double data type in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-complex-data-type-in-MKL-C-program/m-p/1056625#M21454</link>
    <description>&lt;P&gt;The complex double data type in the C API of MKL is just a struct with a pair of double type numbers, real and imag.&lt;/P&gt;

&lt;P&gt;MKL doesn't have arithmetic functions (such as multiply, conjugate, etc.) that operate on scalar complex numbers. But you can find these functions in the standard C99 complex.h.&lt;/P&gt;

&lt;P&gt;MKL has arithmetic functions that operates on vectors of complex numbers. Check the "VML Mathematical Functions" chapter in the MKL reference manual.&lt;/P&gt;

&lt;P&gt;MKL provides BLAS functions for matrix-matrix and matrix-vector multiplications. All S, D, C, Z data types are supported. Check the "BLAS and Sparse BLAS Routines" chapter in the MKL reference manual.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jul 2014 18:07:47 GMT</pubDate>
    <dc:creator>Zhang_Z_Intel</dc:creator>
    <dc:date>2014-07-07T18:07:47Z</dc:date>
    <item>
      <title>How to use complex data type in MKL C program?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-complex-data-type-in-MKL-C-program/m-p/1056624#M21453</link>
      <description>&lt;P&gt;Dear all:&lt;/P&gt;

&lt;P&gt;I am facing a problem on how to use&amp;nbsp;lapack_complex_double data type,&lt;STRONG&gt; Including multiply, divide,conjugate&lt;/STRONG&gt;(I can do this using z_imag=-z_imag, is this the best way?), &lt;STRONG&gt;and print the results&lt;/STRONG&gt;(actually I can print the result, but every time I need a cast (double)z.real, (double)z.imag, which is not convenient).I have tried cast the variable&amp;nbsp;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;(double complex) z the multiply, but it failed. I will give my sample program. Anyone please kindly show me how I can handle this data type. Please modify on my program so that I can see clear how this is done. I am a novice in both C and MKL programming. I have searched this site and found some similar thread, but I still cannot work it out.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Below is my program, you can do the matrix element operations using matrix m in it.&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include    &amp;lt;complex.h&amp;gt;
#include    &amp;lt;math.h&amp;gt;
#include    &amp;lt;stdlib.h&amp;gt;
#include    &amp;lt;stdint.h&amp;gt;
#include    &amp;lt;stdio.h&amp;gt;
#include    &amp;lt;mkl.h&amp;gt;
lapack_int LAPACKE_zheev( int matrix_order, char jobz, char uplo, lapack_int n, lapack_complex_double* a, lapack_int lda, double* w );
//hermitian matrix, each row in output is an eigenvector
void    diag(lapack_complex_double *mat, double *e, lapack_int n)
{
    char    jobz='V';   //also eigenvectors
    char    uplo='U';   //upper triangle
    lapack_int  info;

    info=LAPACKE_zheev(LAPACK_ROW_MAJOR,jobz,uplo,n,mat,n,e);

    if(info!=0){
        printf("matrix diag fail,the %d argument is wrong\n",info);
        exit(1);
    }
}

int main()
{
    lapack_complex_double *mat;
    lapack_complex_double *m;
    double  *e;

    mat=(lapack_complex_double *)malloc(sizeof(lapack_complex_double)*4);
    m=(lapack_complex_double *)malloc(sizeof(lapack_complex_double)*4);
    e=(double *)malloc(sizeof(double)*2);
    mat[0].real=1.0;    mat[0].imag=0.0;
    mat[1].real=1.0;    mat[1].imag=-1.0;
    mat[2].real=1.0;    mat[2].imag=1.0;
    mat[3].real=2.0;    mat[3].imag=0.0;
    *m=*mat;
    *(m+1)=*(mat+1);
    *(m+2)=*(mat+2);
    *(m+3)=*(mat+3);
diag(mat,e,2);

    printf("{(%f,+%fI),(%f,+%fI)}\n",(double)m[0].real,(double)m[0].imag,(double)m[1].real,(double)m[1].imag);
    printf("{(%f,+%fI),(%f,+%fI)}\n",(double)m[2].real,(double)m[2].imag,(double)m[3].real,(double)m[3].imag);
    printf("the eigenvalue is %f,%f\n",e[0],e[1]);

    printf("{(%f,+%fI),(%f,+%fI)}\n",(double)mat[0].real,(double)mat[0].imag,(double)mat[1].real,(double)mat[1].imag);
    printf("{(%f,+%fI),(%f,+%fI)}\n",(double)mat[2].real,(double)mat[2].imag,(double)mat[3].real,(double)mat[3].imag);

    printf("{(%f,+%fI),(%f,+%fI)}\n",(double)mat[0].real,(double)mat[0].imag,(double)mat[1].real,(double)mat[1].imag);
    printf("{(%f,+%fI),(%f,+%fI)}\n",(double)mat[2].real,(double)mat[2].imag,(double)mat[3].real,(double)mat[3].imag);
    free(mat);
    free(m);
    free(e);
    return 0;
}
&lt;/PRE&gt;

&lt;P&gt;By the way, I am using gcc, below is my Makefile so that you may need when you compile the above program.&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;NAME=upload
OBJECTS = $(NAME).c
cc = gcc
MKLPATH=/opt/intel/composer_xe_2013.5.192/mkl/lib/intel64
MKLINCLUDE=/opt/intel/composer_xe_2013.5.192/mkl/include
MODPATH=/opt/intel/composer_xe_2013.5.192/mkl/include/intel64/lp64
FLAGS= -L$(MKLPATH) -I$(MKLINCLUDE)  -I$(MODPATH)    -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core  -liomp5 -lm -lpthread

OUTNAME=$(NAME).out

$(NAME): $(OBJECTS)
    $(cc) -o $(OUTNAME) $(OBJECTS) $(FLAGS)
clean:
    rm -f $(OUTNAME)
&lt;/PRE&gt;

&lt;P&gt;Another question is how I can easily do the matrix-matrix multiply and matrix-vector multiply using C program. Is there any function in MKL or something can do this? If so, can you add that to the above program? thanks very much!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jul 2014 15:51:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-complex-data-type-in-MKL-C-program/m-p/1056624#M21453</guid>
      <dc:creator>Ming_L_1</dc:creator>
      <dc:date>2014-07-07T15:51:41Z</dc:date>
    </item>
    <item>
      <title>The complex double data type</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-complex-data-type-in-MKL-C-program/m-p/1056625#M21454</link>
      <description>&lt;P&gt;The complex double data type in the C API of MKL is just a struct with a pair of double type numbers, real and imag.&lt;/P&gt;

&lt;P&gt;MKL doesn't have arithmetic functions (such as multiply, conjugate, etc.) that operate on scalar complex numbers. But you can find these functions in the standard C99 complex.h.&lt;/P&gt;

&lt;P&gt;MKL has arithmetic functions that operates on vectors of complex numbers. Check the "VML Mathematical Functions" chapter in the MKL reference manual.&lt;/P&gt;

&lt;P&gt;MKL provides BLAS functions for matrix-matrix and matrix-vector multiplications. All S, D, C, Z data types are supported. Check the "BLAS and Sparse BLAS Routines" chapter in the MKL reference manual.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jul 2014 18:07:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-complex-data-type-in-MKL-C-program/m-p/1056625#M21454</guid>
      <dc:creator>Zhang_Z_Intel</dc:creator>
      <dc:date>2014-07-07T18:07:47Z</dc:date>
    </item>
    <item>
      <title>Quote:Zhang Z (Intel) wrote:</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-complex-data-type-in-MKL-C-program/m-p/1056626#M21455</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Zhang Z (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;The complex double data type in the C API of MKL is just a struct with a pair of double type numbers, real and imag.&lt;/P&gt;

&lt;P&gt;MKL doesn't have arithmetic functions (such as multiply, conjugate, etc.) that operate on scalar complex numbers. But you can find these functions in the standard C99 complex.h.&lt;/P&gt;

&lt;P&gt;MKL has arithmetic functions that operates on vectors of complex numbers. Check the "VML Mathematical Functions" chapter in the MKL reference manual.&lt;/P&gt;

&lt;P&gt;MKL provides BLAS functions for matrix-matrix and matrix-vector multiplications. All S, D, C, Z data types are supported. Check the "BLAS and Sparse BLAS Routines" chapter in the MKL reference manual.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Hi Zhang Z:&lt;/P&gt;

&lt;P&gt;Thanks very much for you reply. I think I will assign the value of MKL complex data to a C double complex variable, then use it as I wish. Thank you for providing me the additional information about the BLAS.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;cheers.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 06:13:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-complex-data-type-in-MKL-C-program/m-p/1056626#M21455</guid>
      <dc:creator>Ming_L_1</dc:creator>
      <dc:date>2014-07-09T06:13:57Z</dc:date>
    </item>
  </channel>
</rss>

