Quantcast
Channel: Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 2652

Is there a problem with hemm() ?

$
0
0

If I multiply two complex diagonal 2x2 matrices, with chemm(), I don't get a diagonal matrix ! 

Here is the code for C=A.B 

Matrix A is stored as an upper triangle hermitian matrix. 

#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <complex>
#include <math.h>

#define MKL_Complex8 std::complex<float>
#define MKL_INT int
#include "mkl.h"
using namespace std;
typedef std::complex<float> Comp ;
int main(int argc, char** argv)
{
CBLAS_ORDER order= CblasColMajor;
CBLAS_SIDE Left = CblasLeft;
CBLAS_UPLO Uplo= CblasUpper;
Comp one=1; Comp zero =0;
Comp A[3]; 
Comp B[4]; 
Comp C[4]; 
A[0]=1.0;A[1]=0;A[2]=1.0;
B[0]=2.0;B[1]=0;B[2]=2.0;B[3]=0;
cblas_chemm ( order,  Left, Uplo, 2, 2, &one, A, 2, B, 2, &zero, C, 2); //C=A.B

for (int i=0;i<2;i++)
    { 
    for (int j=0;j<2;j++)
        cout<<C[i+2*j]<<" ";
    cout<<endl;
    }

}

 

 

 

  


Viewing all articles
Browse latest Browse all 2652

Trending Articles