using System; using System.Numerics; using System.Windows.Forms; namespace gaussJordan{ public static class complexEq { static private double precision=0.000001; static public void setPrecision(double val){ if(val>0.0){ precision=val; } } static public void swapRows(int r1, int r2, Complex[,] mat, Complex[] vec){ Complex tmp; tmp=vec[r1]; vec[r1]=vec[r2]; vec[r2]=tmp; int end=mat.GetLength(0); for(int i=0; i -precision && mat[x, y].Real < precision){ mat[x, y] = new Complex(0.0, mat[x, y].Imaginary); } if (mat[x, y].Imaginary > -precision && mat[x, y].Imaginary < precision){ mat[x, y] = new Complex(mat[x, y].Real, 0.0); } } } } static public int getRowIdOfMaxElemInCol(Complex[,] mat, int col){ //szuka tylko pod główną przekątną int id=col; //Complex max=Complex.Abs(mat[col,col]); double max=Math.Abs(mat[col,col].Real)+Math.Abs(mat[col,col].Imaginary); int end=mat.GetLength(1); for(int i=col+1; i max){ max=Math.Abs(mat[col,col].Real)+Math.Abs(mat[col,col].Imaginary); id=i; } } return id; } static public bool dgv2MatAndVec(DataGridView dgvM, DataGridView dgvV, Complex[,] mat, Complex[] vec){ int x=dgvM.ColumnCount; int y=dgvM.RowCount; int i=0; int j=0; string[] split; try{ for(i=0; i0.0){ precision=val; } } static public void swapRows(int r1, int r2, double[,] mat, double[] vec){ double tmp; tmp=vec[r1]; vec[r1]=vec[r2]; vec[r2]=tmp; int end=mat.GetLength(0); for(int i=0; i -precision && mat[x,y] < precision){ mat[x,y]=0; } } } } static public int getRowIdOfMaxElemInCol(double[,] mat, int col){ //szuka tylko pod główną przekątną int id=col; double max=mat[col,col]; int end=mat.GetLength(1); for(int i=col+1; i max){ max=mat[col,i]; id=i; } } return id; } static public bool dgv2MatAndVec(DataGridView dgvM, DataGridView dgvV, double[,] mat, double[] vec){ int x=dgvM.ColumnCount; int y=dgvM.RowCount; int i=0; int j=0; try{ for(i=0; i