Hello everyone,

I'm trying to declare a 2-dimension (A[][]) dynamic matrix but I'm having problems ...

The A's elements need to be FLOAT.

The size of lines and columns are both vectorX.size().

One of error's message is: "cannot convert `double' to `float**' in initialization"

// --------------------------------------
// DYNAMIC DECLARATION OF MATRIX
float **A = 0.0; // pointer for A
A = new float *[vectorX.size()];
for(int i=0;i<vectorX.size();i++)
A[i]= new float [vetorX.size()];
// END DYNAMIC DECLARATION OF MATRIX
// --------------------------------------

for(int i=0; i < vectorX.size();i++)
{
for(int j=0; j<= i;j++)
{
if(vectorY[i] == "NA" and vectorZ[i] == "NA")
{

A[i][i]= 1.53;
}
else if(vectorY[i] == "NA" and vectorZ[i] != "NA")
{
A[i][i]= 1.63;
}
else if(vectorY[i] != "NA" and vectorZ[i] == "NA")
{

A[i][i]= 1.73;
}
else if(vectorY[i] != "NA" and vectorZ[i] != "NA")
{
A[i][i]= 1.73 + 0.5 ;

}
}
}
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
float **A = 0.0; // pointer for A

You cannot do that. The initialisation takes a double calue (0.0) and tries to assign it to a pointer (A**) that is a type mismatch.