public RationalNumber[][] GetLinEqSetMatrixOrd() { long m = EquationsCount; long n = VarsCount; RationalNumber[][] A = AppHelper.CreateAmnMatrix <RationalNumber>(m, n + 1); RationalNumber[][] A_local = A; for (int i = 0; i < m; i++) { for (int j = 0; j < n + 1; j++) { A[i][j] = new RationalNumber(0, 1); } } Equations.ForEach(r1 => r1.Value.ForEach( r2 => { A_local[r1.Key][r2.Key] = new RationalNumber(r2.Value); })); VectorB.ForEach(r => { A_local[r.Key][n] = new RationalNumber(r.Value.Value); }); return(A); }
public (long[][], long[][]) GetLinEqSetMatrixFast() { long m = EquationsCount; long n = VarsCount; long[][] A_p = AppHelper.CreateAmnMatrix <long>(m, n + 1); long[][] A_q = AppHelper.CreateAmnMatrix <long>(m, n + 1); for (int i = 0; i < m; i++) { for (int j = 0; j < n + 1; j++) { A_p[i][j] = 0; A_q[i][j] = 1; } } Equations.ForEach(r1 => r1.Value.ForEach( r2 => { A_p[r1.Key][r2.Key] = r2.Value.ToLong(); A_q[r1.Key][r2.Key] = 1; })); VectorB.ForEach(r => { A_p[r.Key][n] = r.Value.Value.ToLong(); A_q[r.Key][n] = 1; }); return(A_p, A_q); }
public SparseMatrix GetLinEqSetSparseMatrix() { long m = EquationsCount; long n = VarsCount; SparseMatrix A = new(m, n + 1); Equations.ForEach(r1 => r1.Value.ForEach( r2 => { A.Set(r1.Key, r2.Key, new RationalNumber(r2.Value)); })); VectorB.ForEach(r => { A.Set(r.Key, n, new RationalNumber(r.Value.Value)); }); return(A); }