Exemple #1
0
        private static Matix NormalBestValues(Matix basematrix, Matix matix, bool plus)
        {
            Matix matix1 = new Matix(basematrix.Xcount, 1);

            foreach (MatrixNode matrixNode in matix1)
            {
                double            sum = 0;
                List <MatrixNode> equalNodesXElement = basematrix.FindEqualNodesXElement(matrixNode.X);
                if (plus)
                {
                    foreach (MatrixNode node in equalNodesXElement)
                    {
                        double sumrow = ((node.Value ?? 0) - (matix[1, node.Y].Value ?? 0));
                        sum += Math.Pow(sumrow, 2);
                    }
                }
                else
                {
                    foreach (MatrixNode node in equalNodesXElement)
                    {
                        double sumrow = ((node.Value ?? 0) - (matix[1, node.Y].Value ?? 0));
                        sum += Math.Pow(sumrow, 2);
                    }
                }
                double val = Math.Sqrt(sum);
                matrixNode.Value = (double?)val;
            }
            return(matix1);
        }
Exemple #2
0
        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);
        }