Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

cblas_zsyrk returns wrong results

$
0
0

I have the following function and I'm trying to compute C = A*A' using zsyrk from blas, but when I print the C matrix the results are wrong. What am I missing?

double* zsyrk(int N, double *A) {

	int i,j;

	int K;
	K = N;

	const int * alpha;
	int a = 1;
	alpha = &a;

	int lda = N;
	int ldc = N;

	const int * beta;
	int b = 0;
	beta = &b;

	double *C;
	C = (double *)calloc( N*N, sizeof(double));

	for (i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			printf("%lf ", A[i*N + j]);
		}
		printf("\n");
	}

	cblas_zsyrk(CblasRowMajor, CblasUpper, CblasTrans, N, K, alpha, A, lda, beta, C, ldc);

	for (i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			printf("%lf ", C[i*N + j]);
		}
		printf("\n");
	}
	
	return C;
}

The restults are:

Matrix A:

-662.059957 -942.824833
545.621059 -270.699577

Matrix C:
-0.000000 0.000000
0.000000 -0.000000

 


Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>