Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22009

Variable type matching problem with Eigen

$
0
0

I am using Eigen on google cloud platform on an ubuntu machine. I have installed gcc-7 and I am trying to run a C++ code containing a huge matrix (1000X1000) of doubles. The code is running fine on Xcode 11.3 with clang, but on the ubuntu machine I am having a problem with variable type conversion. The part of the code which is causing problems:

Matrix<double, Dynamic, Dynamic> Mat(double x, double y, double En, int Np, double Kmax){
Matrix<double, Dynamic, Dynamic> M(Np, Np);
double eps = (double)Kmax / (double)Np;
double result, error;
struct params ps;
ps.x = x;
ps.y = y;
ps.En = En;
gsl_set_error_handler_off();
gsl_integration_workspace * w = gsl_integration_workspace_alloc (iters);
gsl_function F;
F.function = &intDeltFunc;
F.params = &ps;
gsl_integration_qags (&F, 0, y, 0, prec, iters, w, &result, &error);
gsl_integration_workspace_free (w);
for ( int i = 0; i < Np  ; i++){
    for ( int j = 0; j < Np ; j++){
        double p = eps * i + y;
        double q = eps * j + y;
        if ( (j == 0) || (j == Np - 1) ){
            M(i , j) =  Diag(p, q, x, y, En) + eps * Integral(p, q, x, y, En, result) / 2.0;
        }
        else{
            M(i , j) = Diag(p, q, x, y, En) + eps * Integral(p, q, x, y, En, result);
        }
    }
}
return M;}

Here Np = 1000.

The problem encountered with ubuntu:

Screenshot

main.cpp:247:26: error: no viable overloaded '='
            M(i , j) = DiagTerm + 0.5 * eps * IntegralTerm;
            ~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/Eigen/src/Core/MatrixBase.h:139:14: note: candidate function not viable: no known conversion
      from 'double' to 'const Eigen::MatrixBase<Eigen::IndexedView<Eigen::Matrix<double, -1, -1, 0, -1, -1>,
      double, double> >' for 1st argument
    Derived& operator=(const MatrixBase& other);

I have tried to download Eigen multiple times, to refer the compiler to its exact location when compiling, and also to use clang (which Xcode uses) and I still have the problem. Do you have any ideas what might be the problem ?


Viewing all articles
Browse latest Browse all 22009

Trending Articles



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