I was provided a function listed below that I have to create code for, to find the determinant of a 1x1, 2x2, or 3x3 matrix.
double det (int size, double matrix[size][size]) {
It calls for a two dimensional array of type double, as a beginner I am unfamiliar with this and not sure how to declare it. I looked online and couldn't find anything. My ideas were int[][] but nothing is working. Any Ideas? Using C btw, thank you!
For example, if I use
int main() {
double test[2][2] = {{1.0,2.0},{2.0,3.0}};
det(2, test);
return(0);}
I attempted to declare it with
double det (int size, double matrix[size][size]) {
double matrix[size][size];
however I get the error
/tmp/tmpwhrzhcqq.c: In function ‘det’:
/tmp/tmpwhrzhcqq.c:9:10: error: ‘matrix’ redeclared as different kind of symbol
9 | double matrix[size][size];
| ^~~~~~
/tmp/tmpwhrzhcqq.c:8:30: note: previous definition of ‘matrix’ was here
8 | double det (int size, double matrix[size][size]) {
| ~~~~~~~^~~~~~~~~~~~~~~~~~