Beispiel #1
0
        // Prints only the CheckConditions.
        public override string ToString()
        {
            List <string> conditionsText = new List <string>();

            conditionsText.Add($"geometry3D of the object must be contained within the Zone aligned to the reference element and of size " +
                               $"{(Width != 0 ? Width.ToString() : "")}" +
                               $"{(Height != 0 ? "x"+ Height.ToString() : "")}" +
                               $"{(Depth != 0 ? "x" + Depth.ToString() : "")}.");
            conditionsText.AddRange(CheckConditions.Select(c => c?.ToString()));

            return($"{(string.IsNullOrWhiteSpace(SpecName) ? "This Specification" : $"`{SpecName}`")} is defined for the zone `{ZoneName}` and " +
        /// <summary>
        /// Find the <paramref name="power"/> degree root of <paramref name="number"/>.
        /// </summary>
        /// <param name="number">The initial number.</param>
        /// <param name="power">The degree of root.</param>
        /// <param name="accuracy">The accuracy of operation.</param>
        /// <returns>The result of operation</returns>
        /// <exception cref="ArgumentException">If input values are invalid.</exception>
        public static double NthRoot(double number, int power, double accuracy)
        {
            if (power == 1)
            {
                return(number);
            }

            CheckConditions.NthRoot(number, power, accuracy);

            double prevResult, currentResult = 1;

            do
            {
                prevResult = currentResult;

                currentResult  = ((power - 1) * prevResult + DivideWithArgumentInPower(number, prevResult, power - 1));
                currentResult /= power;
            }while (Math.Abs(prevResult - currentResult) > accuracy);

            return(currentResult);
        }
 //Находим циклы полным перебором
 private static void Decision(ref int[,] arrayMatrix)
 {
     //Проверяем, использовали ли мы вершину до этого и есть ли путь между вершинами
     if (!CheckConditions.UseVertexBefore(ref arraySequence, nextVertex) && CheckConditions.WayBetweenVertex(ref arrayMatrix, currentVertex, nextVertex))
     {
         //Записываем вершинуы
         StepForward(ref arrayMatrix);
     }
     else
     {
         //Проверяем, есть ли еще свободные вершины и есть ли путь к начальной вершине
         if ((numberOfVertex == indexNextVertex) && (arrayMatrix[currentVertex, beginVertex] != 0))
         {
             //Записываем решение
             SetDecision(ref arrayMatrix);
         }
         else
         {
             //Возращаемся назад или ищим другую вершину
             FindNewVertex(ref arrayMatrix);
         }
     }
 }