0

我正在使用 C++ 通过边界元素方法解决,我的代码有问题:

#include <stdio.h> 
#include <math.h> 
#include <gsl/gsl_linalg.h> 
using namespace std; 
string STRING; 
int i,q,s;  
int const nodes = 16; 
double A[nodes][nodes];  
double b[nodes]; 
 int main(){ 
  for (i=0;i<nodes;i++) 
       { 


           { 
            A[q][i] = 1.;       
            b[q] = 1.; 
           }        
       } 

一旦建立了 A 和 b,我们需要通过
计算 x=A^(-1)*b 的倒数来求解系统 Ax=b

gsl_matrix_view m = gsl_matrix_view_array (*A, nodes, nodes); for(q=0;q<nodes;q++)
gsl_matrix_view b = gsl_matrix_view_array (b, nodes, nodes); 
gsl_vector *x = gsl_vector_alloc (nodes); 
gsl_permutation * p = gsl_permutation_alloc (nodes); 
gsl_linalg_LU_decomp (&m.matrix, p, &s); 
gsl_linalg_LU_solve (&m.matrix, p, &b.vector, x); 

      return 0;    
     }  

当我使用 cygwin 编译时

g++ test.cpp -lm -lgsl -o bem.out -L/usr/bin

我收到以下错误:

test.cpp: In function 'int main()':
test.cpp:39:59: error: cannot convert 'gsl_matrix_view' to 'double*' for argument '1' to '_gsl_matrix_view gsl_matrix_view_array(double*, size_t, size_t)'
test.cpp:43:39: error: 'struct gsl_matrix_view' has no member named 'vector'

我遵循了 GSL 教程公开的相同示例,但我收到了这些错误。有人可以帮忙吗?我真的很感激。

谢谢!

4

1 回答 1

1

您已经在编译抱怨的同一行中重新声明b为 a 。gsl_matrix_view您之前已将其声明为double数组。

于 2011-02-17T00:13:07.987 回答