public static double[,] SwapRows(double[,] mat, int row1, int row2)
for (int j = 0; j < mat.GetLength(1); j++)
mat[row1, j] = mat[row2, j];
public static double[,] ScaleRow(double[,] mat, int row, double scalar)
for (int j = 0; j < mat.GetLength(1); j++)
public static double[,] AddScaledRow(double[,] mat, int sourceRow, int targetRow, double scalar)
for (int j = 0; j < mat.GetLength(1); j++)
mat[targetRow, j] += scalar * mat[sourceRow, j];
public static void PrintMatrix(double[,] mat)
for (int i = 0; i < mat.GetLength(0); i++)
for (int j = 0; j < mat.GetLength(1); j++)
Console.Write(mat[i, j] + "\t");
public static void Main()
double[,] m = new double[4, 5];
for (int i = 0; i < 4; i++)
for (int j = 0; j < 5; j++)
Console.WriteLine("Matriz Original:");
m = AddScaledRow(m, 1, 3, -2);
Console.WriteLine("Matriz Después de Operaciones de Gauss-Jordan:");