So I've got a lab due tomorrow and our assignment is to input a matrix into an array and then preform row operations to get the inverse. So we have to have an A matrix that is inputted and a B matrix that is the identity matrix, and then do the row ops to get the inverse of A. I know how to scan in the matrix A, but I have absolutely no idea whatsoever on how to preform row operations (multiplying, dividing, switching rows etc) on both the A and B matricies. Does anyone know how to do this?
This is what I have so far - just freeing the memory for dynamic array and about to scan in the numbers, but I'm stumped as to how to do the row ops.
This is what I have so far - just freeing the memory for dynamic array and about to scan in the numbers, but I'm stumped as to how to do the row ops.
Code:
//Lab 6 of APS105 - Computing a Matrix Inverse
#include <stdio.h>
int main(void)
{
int M, N;
printf("Enter the dimension of square matrix:\n");
scanf("%d", &M);
N = M;
//Allocate memory for rows in matrix
double **matrix = (double**)malloc(sizeof(double*)*M);
//Allocate memory for columns in matrix
int i;
for(i=0; i<M; i++)
{
matrix[i] = (double*)malloc(sizeof(double)*N);
}
printf("Enter the %d entries of the matrix:\n", size*size);
scanf("
for(i=0;i<M;i++)
{
free(matrix[i]);
}
free(matrix);
}