Blas DGEMV input error -
i'm having trouble figuring out why piece of blas call throwing n error. problem call last blas call. code compiles without issue , runs fine until call fails following message.
** acml error: on entry dgemv parameter number 6 had illegal value
as far can tell input types correct , array has appreciate insight problem. thanks
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "cblas.h" #include "array_alloc.h" int main( void ) { double **a, **a; double *b, *b, *c; int *ipiv; int n, nrhs; int info; int i, j; printf( "how big matrix?\n" ); fscanf( stdin, "%i", &n ); /* allocate matrix , set random values big value on diagonal. makes sure don't accidentally singular matrix */ = alloc_2d_double( n, n ); a= alloc_2d_double( n, n ); for( = 0; < n; i++ ){ for( j = 0; j < n; j++ ){ a[ ][ j ] = ( ( double ) rand() ) / rand_max; } a[ ][ ] = a[ ][ ] + n; } memcpy(a[0],a[0],n*n*sizeof(double)+1); /* allocate , initalise b */ b = alloc_1d_double( n ); b = alloc_1d_double( n ); c = alloc_1d_double( n ); for( = 0; < n; i++ ){ b[ ] = 1; } cblas_dcopy(n,b,1,b,1); /* pivot array */ ipiv = alloc_1d_int( n ); /* note must pass pointers, have use temporary var */ nrhs = 1; /* call fortran. need 1 underscore on our system*/ dgesv_( &n, &nrhs, a[ 0 ], &n, ipiv, b, &n, &info ); /* tell world results */ printf( "info = %i\n", info ); for( = 0; < n; i++ ){ printf( "%4i ", ); printf( "%12.8f", b[ ] ); printf( "\n" ); } /* want check lapack result blas */ cblas_dgemv(cblasrowmajor,cblastrans,n,n,1.0,a[0],1,b,1,0.0,c,1); return 0; }
the leading dimension (lda) needs @ least large number of columns (n) rowmajor matrix. you’re passing lda of 1.
separately, i’m suspicious of matrix types; without seeing how alloc_2d_double
implemented there’s no way sure if you’re laying out matrix correctly or not. speaking, intermixing pointer-to-pointer-style “matrices” blas-style matrices (contiguous arrays row or column stride) of code smell. (however, possible correctly, , may handling properly; it’s not possible tell if case code posted).
Comments
Post a Comment