0

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().

Could you help me please?

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
Last Post by sadsdw
0
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.
use instead:

float **A = 0 /* or NULL, although some people frown upon using NULL*/; // pointer for A

Edited by drkybelk: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.