public virtual DirectionRange <double>?ToDouble(DirectionRange <TAlgebraicNumber> range)
        {
            if (range is null)
            {
                throw new ArgumentNullException(nameof(range));
            }

            var start = ToDouble(range.Start);
            var end   = ToDouble(range.End);

            if (start != end || range.Start == range.End)
            {
                return(DoubleFactory.CreateDirectionRange(start, end, range.Orientation));
            }

            var isAlmostOmniRange =
                range.Orientation == Orientation.CounterClockwise
                    ? range.Start.CompareTo(range.End, range.Start.Opposite()) == DirectionOrder.After
                    : range.Start.CompareTo(range.End, range.Start.Opposite()) == DirectionOrder.Before;

            return(isAlmostOmniRange
                       ? DoubleFactory.CreateDirectionRange(start, end, range.Orientation)
                       : Policy switch
            {
                InvalidConversionPolicy.Throw =>
                throw new InvalidOperationException(
                    "The range collapsed to a single direction during conversion to double."),
                InvalidConversionPolicy.IgnoreSilently => null,
                _ => throw new NotSupportedException(
                    $"Only Silent and ThrowException modes are supported but got {Policy}.")
            });
        public virtual Direction <double> ToDouble(Direction <TAlgebraicNumber> direction)
        {
            if (direction is null)
            {
                throw new ArgumentNullException(nameof(direction));
            }

            return(DoubleFactory.CreateDirection(ToDouble(direction.X), ToDouble(direction.Y)));
        }
        public virtual Point <double> ToDouble(Point <TAlgebraicNumber> point)
        {
            if (point is null)
            {
                throw new ArgumentNullException(nameof(point));
            }

            return(DoubleFactory.CreatePoint(ToDouble(point.X), ToDouble(point.Y)));
        }
예제 #4
0
    public static void Main()
    {
        AssocArray <int, double> assArr = new  AssocArray <int, double> ();

        assArr[0]    = 2.0;
        assArr[100]  = 3.0;
        assArr[10]   = 43.0;
        assArr[1000] = 34.0;

        Console.WriteLine(assArr[100]);
        foreach (KeyValuePair <int, double> kvp in assArr)
        {
            Console.WriteLine("{0}, {1}", kvp.Key, kvp.Value);
        }

        Set <string> RowNames = new Set <string>();

        RowNames.Insert("A1");
        RowNames.Insert("A2");
        RowNames.Insert("A3");
        RowNames.Insert("A4");
        RowNames.Insert("B1");

        Set <string> ColNames = new Set <string>();

        ColNames.Insert("C1");
        ColNames.Insert("C2");
        ColNames.Insert("C3");
        ColNames.Insert("C4");
        ColNames.Insert("C5");

        //double defaultValue = 10.0;

        // Contents of associative matrix (numeric values)
        NumericMatrix <double> mat1 = new NumericMatrix <double>(RowNames.Size(), ColNames.Size());

        mat1.initCells(3.0);

        AssocMatrix <string, string, double> myMat = new AssocMatrix <string, string, double>(RowNames, ColNames, mat1);

        Factory fs = new DoubleFactory();

        object b;

        b = fs.create();
        Set <double> s1 = (Set <double>)b;

        Console.WriteLine(s1.Size());
    }
예제 #5
0
        public static Evaluator getEvaluator(Integer typeObj,
                                             Integer operObj)
        {
            int type = typeObj.intValue();
            int oper = operObj.intValue();

            switch (type)
            {
            case Evaluator.__Fields.STRING_TYPE:
                return(StringFactory.getStringEvaluator(oper));

            case Evaluator.__Fields.OBJECT_TYPE:
                return(ObjectFactory.getObjectEvaluator(oper));

            case Evaluator.__Fields.SHORT_TYPE:
                return(ShortFactory.getShortEvaluator(oper));

            case Evaluator.__Fields.INTEGER_TYPE:
                return(IntegerFactory.getIntegerEvaluator(oper));

            case Evaluator.__Fields.BOOLEAN_TYPE:
                return(BooleanFactory.getBooleanEvaluator(oper));

            case Evaluator.__Fields.DOUBLE_TYPE:
                return(DoubleFactory.getDoubleEvaluator(oper));

            case Evaluator.__Fields.CHAR_TYPE:
                return(CharacterFactory.getCharacterEvaluator(oper));

            case Evaluator.__Fields.BYTE_TYPE:
                return(ByteFactory.getByteEvaluator(oper));

            case Evaluator.__Fields.FLOAT_TYPE:
                return(FloatFactory.getFloatEvaluator(oper));

            case Evaluator.__Fields.LONG_TYPE:
                return(LongFactory.getLongEvaluator(oper));

            case Evaluator.__Fields.DATE_TYPE:
                return(DateFactory.getDateEvaluator(oper));

            case Evaluator.__Fields.ARRAY_TYPE:
                return(ArrayFactory.getArrayEvaluator(oper));

            default:
                throw new RuntimeException("Type '" + type + "' does not exist for BaseEvaluator.__FieldsFactory");
            }
        }