Ok thanks, i totally forgot about the heap and stack behaviour..
That's just moving my ignorance esewhere, though, i never ever worked with templates, and from what i read it's quite advanced stuff.
I want to point out that rows and cols are not constants for the compiler, they will depend on the inputs of the object (i want to create a vandermonde matrix to fit some data with a polynomial, and the row size depends on the number of sample points, while the col size depends on the degree of the polynomial, which are in the hands of the user).
At this point i wonder if it's better to defined the float m array outside the matrix_create function, and then pass the pointer to the function:
int a = something;
int b = something_else;
matrix_create(a, b, &M, MAT1);
That would make the rows and cols variables quite pointless though, if the array size is smaller than the actual rows*cols.
What do you think?