コード例 #1
0
ファイル: BoolMatrix.cs プロジェクト: axelSok/graduate-work
        /// <summary>
        /// Построить полную матрицу векторов
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public BoolMatrix GetExtendedMatrix()
        {
            var binaryVectors = new BoolMatrix(this.Where(item => item.Count(value => value.Value == "-") == 0));

            var  ternaryVectors1 = new BoolMatrix(this.Where(item => item.Count(value => value.Value == "-") > 0));
            bool repeat;

            do
            {
                repeat = false;
                var ternaryVectors2 = new BoolMatrix();
                foreach (BoolVector boolVector in ternaryVectors1)
                {
                    for (int i = 0; i < boolVector.Count; i++)
                    {
                        if (boolVector[i].Value == "-")
                        {
                            var newVector1 = new BoolVector(boolVector);
                            var newVector2 = new BoolVector(boolVector);
                            newVector1[i] = new MatrixValue("0");
                            newVector2[i] = new MatrixValue("1");

                            if (newVector1.Any(item => item.Value == "-"))
                            {
                                ternaryVectors2.Add(newVector1);
                                repeat = true;
                            }
                            else if (!binaryVectors.Contains(newVector1))
                            {
                                binaryVectors.Add(newVector1);
                            }

                            if (newVector2.Any(item => item.Value == "-"))
                            {
                                ternaryVectors2.Add(newVector2);
                                repeat = true;
                            }
                            else if (!binaryVectors.Contains(newVector2))
                            {
                                binaryVectors.Add(newVector2);
                            }
                        }
                    }
                }
                if (repeat)
                {
                    ternaryVectors1 = new BoolMatrix(ternaryVectors2);
                }
            } while (repeat);

            return(binaryVectors);
        }
コード例 #2
0
ファイル: BoolMatrix.cs プロジェクト: axelSok/graduate-work
        /// <summary>
        /// Обобщенное склеивание матрицы
        /// </summary>
        /// <param name="matrix"></param>
        /// <returns></returns>
        public BoolMatrix GeneralBonding()
        {
            bool repeat;
            var  newMatrix = new BoolMatrix(this);

            do
            {
                repeat = false;
                for (var i = 0; i < newMatrix.Count - 1; i++)
                {
                    for (var j = i + 1; j < newMatrix.Count; j++)
                    {
                        var boundVector = newMatrix[i].GenericBonding(newMatrix[j]);
                        if (boundVector != null && !newMatrix.Contains(boundVector))
                        {
                            newMatrix.Add(boundVector);
                            repeat = true;
                        }
                    }
                }
            } while (repeat);

            return(newMatrix);
        }