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); }
//ind the angle between this vector and the parameter vector public double AngleTo(Vector3D Vec) { //organizando os vetores antes de calcular o produto escalar Vector3D VectorA; Vector3D VectorB; VectorA = UnitVector(); VectorB = Vec.UnitVector(); double AdotB = DotProduct(VectorA, VectorB); //produto escalar double ALstarBL = VectorA.Length() * VectorB.Length(); //produto das normas //Normalizando o produto escalar if (ALstarBL == 0) { return(0.0); } return(System.Math.Acos(AdotB / ALstarBL)); //double angle = Math.Acos(dot_pro); angle = angle * 180 / Math.PI; angle = 180 - angle; }
public void RemoveEquation(long equation) { Equations.Remove(equation); VectorB.Remove(equation); }