Compilation Error
The error message is rather self-explanatory. You're applying subscription (indexing) to a type, that is not an array-like type.
The compiler even references you the line where the problem happens:
main.c: In function ‘MTRX_add’:
main.c:45:5: error: subscripted value is neither array nor pointer nor vector
45 | a[i][j] = m[i][j] + n[i][j];
| ^
If you look at your function's signature, you'll see the following:
struct Matrix MTRX_add(struct Matrix *a, struct Matrix *b, int fillValue)
The type of a is a pointer to a Matrix structure.
Your code indexes a (the pointer to Matrix), then tries to index the result of that (the Matrix itself), but that has no support for such an operation.
Logic Error
What you probably should have done instead is to make the Matrix type hold the dimensions of the matrix (number of columns and number of rows) and all the elements (two-dimensional array).
Let's forget about passing arguments to functions via pointers (to save performance) to reduce confusion. You can do it later when the rest of the code works).
So with this, you'd have something like the code below. I've done a proof of concept for the add operation (not complete as it's missing checks).
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int columnCount;
int rowCount;
float **elements;
} Matrix;
Matrix MatrixNew(int columnCount, int rowCount)
{
Matrix matrix;
matrix.columnCount = columnCount;
matrix.rowCount = rowCount;
matrix.elements = (float**)malloc(sizeof(float*) * columnCount);
for (int column = 0; column < columnCount; column++)
matrix.elements[column] = (float*)malloc(sizeof(float) * rowCount);
return matrix;
}
Matrix MatrixAdd(Matrix a, Matrix b)
{
// TODO: check if the two matrices have the same dimensions.
Matrix newMatrix = MatrixNew(a.columnCount, a.rowCount);
for (int column = 0; column < newMatrix.columnCount; column++)
for (int row = 0; row < newMatrix.rowCount; row++)
newMatrix.elements[column][row] = a.elements[column][row] + b.elements[column][row];
return newMatrix;
}
void MatrixPrint(Matrix m)
{
for (int column = 0; column < m.columnCount; column++)
{
for (int row = 0; row < m.rowCount; row++)
{
printf("% 10.3f", m.elements[column][row]);
}
printf("\n");
}
}
int main()
{
Matrix a = MatrixNew(2, 3);
a.elements[0][0] = 1;
a.elements[0][1] = 2;
a.elements[0][2] = 3;
a.elements[1][0] = 4;
a.elements[1][1] = 5;
a.elements[1][2] = 6;
Matrix b = MatrixNew(2, 3);
b.elements[0][0] = 10;
b.elements[0][1] = 20;
b.elements[0][2] = 30;
b.elements[1][0] = 40;
b.elements[1][1] = 50;
b.elements[1][2] = 60;
Matrix sum = MatrixAdd(a, b);
MatrixPrint(sum);
return 0;
}
What Is a Matrix?
What you tried to implement for matrix multiplication and transposition is not what mathematicians mean by such matrix operations.
Read how matrices work here.
Good luck!