private static void MatrixNormal(Matix matix) { Matix matix1 = new Matix(matix.Xcount, matix.YCount); foreach (MatrixNode matrixNode in matix) { List <MatrixNode> findEqualNodesYElement = matix.FindEqualNodesYElement(matrixNode.Y); double sum = 0; foreach (MatrixNode node in findEqualNodesYElement) { sum += Math.Pow(node.Value ?? 0, 2); } double pow = Math.Sqrt(sum); double value = matrixNode.Value ?? 0; if (value > 0) { double result = value / pow; matix1[matrixNode.X, matrixNode.Y].Value = (double?)result; } else { matix1[matrixNode.X, matrixNode.Y].Value = 0; } } foreach (MatrixNode matrixNode in matix1) { matix[matrixNode.X, matrixNode.Y].Value = matrixNode.Value; } }
private static Matix GetBestValueColum(Matix matix, bool plus) { Matix matix1 = new Matix(1, matix.YCount); foreach (MatrixNode matrixNode in matix1) { List <MatrixNode> equalNodesYElement = matix.FindEqualNodesYElement(matrixNode.Y); matrixNode.Value = plus ? equalNodesYElement.Max(x => x.Value) : equalNodesYElement.Min(x => x.Value); } return(matix1); }
private static Matix MultiplicationMatrix(Matix matixa, Matix matixb) { Matix matix1 = new Matix(matixa.Xcount, matixb.YCount); foreach (MatrixNode matrixNode in matix1) { List <MatrixNode> equalNodesXElement = matixa.FindEqualNodesXElement(matrixNode.X); List <MatrixNode> findEqualNodesYElement = matixb.FindEqualNodesYElement(matrixNode.Y); double val = 0; for (int i = 0; i < matixa.YCount; i++) { double f = (equalNodesXElement[i].Value ?? 0) * (findEqualNodesYElement[i].Value ?? 0); val += f; } matrixNode.Value = (double?)val; } return(matix1); }