C ++ error: can not convert '' :: Vectordouble 'to' double 'in assignment sum_aux = A [f] [j] * xk [j];

1

Good! I am having problems with the exposed error when I try to multiply the matrix A with the vector xk. The matrix A lame from an external input file. Would anyone know how to fix it ?. Thank you very much in advance! I attach the interesting parts of the code:

Matrix <double> A,B,C;

Vector <double> xk[9] = {27.0000, -0.000901816789824, 0, 0, 0, 0,0, -0.000901816789824 , 0};

int f,j,n, m, p,a,b,b2,c,tam;

double sum_aux=0;
a = 9;
A.resize(a, a);

//Para matriz A
{
    getline(myfile, line);      
    std::istringstream is(line);

    for (int i = 0; i < a; i++) 
        for (int j = 0; j < n; j++)
            is >> A[i][j] >> ch;
}
for(f=1;f<=a;f++){
    sum_aux=0;
    for(j=1;j<=a;j++){
        sum_aux=(double)A[f][j]*xk[j];
        sum_aux=sum_aux + (double)A[f][j+1]*xk[j+1];
    }
    xk_aux[j]=sum_aux;
}
    
asked by Clara_teleco 23.01.2017 в 20:20
source

1 answer

0

Maybe you could try simple examples. You can also try to make the accesses with the functions of the vector library in C ++, for example the "at" function. Try a code similar to the following:

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<double> xk(9);
    xk.resize(9);
    xk.at(0)=27;
    xk.at(1)=0;
    xk.at(2)=0;
    xk.at(3)=0;
    xk.at(4)=0;
    xk.at(5)=0;
    xk.at(6)=0;
    xk.at(7)=0;
    xk.at(8)=0;

    /* Ejemplo de multiplicación. */
    double res = 0.0;

    res = 2*xk.at(0);

    cout << res << endl;
    return 0;

}

Greetings!

    
answered by 23.01.2017 / 21:24
source