1

blas 呼び出しが n エラーをスローする理由を理解するのに苦労しています。問題の呼び出しは、最後の blas 呼び出しです。コードは問題なくコンパイルされ、この呼び出しが次のメッセージで失敗するまで正常に実行されます。

** ACML エラー: DGEMV へのエントリで、パラメータ番号 6 に不正な値がありました

入力タイプが正しく、配列 a が持っているすべてを伝えることができる限り、問題についての洞察をいただければ幸いです。ありがとう

#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 a matrix?\n" );
  fscanf( stdin, "%i", &n );

  /* Allocate the matrix and set it to random values but
     with a big value on the diagonal. This makes sure we don't
     accidentally get a singular matrix */
  a = alloc_2d_double( n, n );
  A= alloc_2d_double( n, n );

  for( i = 0; i < n; i++ ){
    for( j = 0; j < n; j++ ){
      a[ i ][ j ] = ( ( double ) rand() ) / RAND_MAX;
    }
    a[ i ][ i ] = a[ i ][ i ] + n;
  }
  memcpy(A[0],a[0],n*n*sizeof(double)+1);


  /* Allocate and initalise b */
  b = alloc_1d_double( n );
  B = alloc_1d_double( n );
  C = alloc_1d_double( n );

  for( i = 0; i < n; i++ ){
    b[ i ] = 1;
  }

  cblas_dcopy(n,b,1,B,1);
  /* the pivot array */
  ipiv = alloc_1d_int( n );

  /* Note we MUST pass pointers, so have to use a temporary var */
  nrhs = 1;

  /* Call the Fortran. We need one underscore on our system*/
  dgesv_(  &n, &nrhs, a[ 0 ], &n, ipiv, b, &n, &info );

  /* Tell the world the results */
  printf( "info = %i\n", info );
  for( i = 0; i < n; i++ ){
    printf( "%4i ", i );
    printf( "%12.8f", b[ i ] );
    printf( "\n" );
  }

  /* Want to check my lapack result with blas */

cblas_dgemv(CblasRowMajor,CblasTrans,n,n,1.0,A[0],1,B,1,0.0,C,1);

return 0;
}
4

1 に答える 1