I faced LAPACKE source for the first time and stuck in very first usage.
I run very simple code (see below) and trying you brand new svd functionality: sgesvdx.
But it does not work. All I see is output:
** On entry to SGESVDX parameter number 15 had an illegal value
Digging into code I could not see any logic in C/Fortran API compliance: at C level (LAPACKE_sgesvdx_work routine) there is a check for 'a' and 's' letters for jobu variable, while in Fortran (SGESVDX routine) it checks for 'v' and 'n'.
Could you please tell me if I miss something?
Thank you in advance,
Victor.
- Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include "lapacke.h"
/* Parameters */
#define N 500
#define NRHS 3
#define LDA 3000
#define LDB NRHS
#include <time.h>
/* Main program */
int mmm() {
float *a = (float*)LAPACKE_malloc(LDA*N * sizeof(float));
float *b = (float*)LAPACKE_malloc(LDB*N * sizeof(float));
int maxDim = __max(LDA, N);
int minDim = __min(LDA, N);
float *eigenValues = (float*)LAPACKE_malloc(maxDim * sizeof(float));
float *workAr = (float*)LAPACKE_malloc(maxDim * sizeof(float));
float *eigenVectorsU = (float*)LAPACKE_malloc(maxDim*maxDim * sizeof(float));
float *eigenVectorsV = (float*)LAPACKE_malloc(maxDim*maxDim * sizeof(float));
for (int i = 0; i < LDA; i++)
{
for (int j = 0; j < N; j++)
{
a[j*LDA + i] = rand() / (float)RAND_MAX;
}
}
for (int i = 0; i < minDim; i++)
{
eigenValues[i] = 0;
}
clock_t startTime = clock();
int NS = LDA;
LAPACKE_sgesvdx(LAPACK_ROW_MAJOR, 'V', 'V', 'A', (int)N, (int)LDA, a, (int)LDA, 0, 0, 0, 0, NS, eigenValues, eigenVectorsU, (int)maxDim, eigenVectorsV, (int)maxDim, workAr);
float times = (clock() - (float)startTime) / CLOCKS_PER_SEC;
printf("time = %f\n", times);
LAPACKE_free(eigenValues);
LAPACKE_free(a);
LAPACKE_free(b);
LAPACKE_free(workAr);
LAPACKE_free(eigenVectorsU);
LAPACKE_free(eigenVectorsV);
exit(0);
}

