Exemplo n.º 1
0
 public static IntegerNumber operator *(IntegerNumber a, IntegerNumber b)
 {
     if (!Functional.BothAreEqual(a, b, HierarchyLevel.INTEGER))
     {
         return(Number.OpMul(a, b) as IntegerNumber);
     }
     return(new IntegerNumber(CtxMultiply(a.Value, b.Value)));
 }
        public static RationalNumber operator *(RationalNumber a, RationalNumber b)
        {
            if (!Functional.BothAreEqual(a, b, HierarchyLevel.RATIONAL))
            {
                return(Number.OpMul(a, b) as RationalNumber);
            }
            var num = CtxMultiply(a.Numerator, b.Numerator);
            var den = CtxMultiply(a.Denominator, b.Denominator);

            return(Number.Functional.Downcast(new RationalNumber(num, den)) as RationalNumber);
        }
Exemplo n.º 3
0
        public static ComplexNumber operator *(ComplexNumber a, ComplexNumber b)
        {
            if (!Functional.BothAreEqual(a, b, HierarchyLevel.COMPLEX))
            {
                return(Number.OpMul(a, b) as ComplexNumber);
            }
            var Re = a.Real * b.Real - a.Imaginary * b.Imaginary;
            var Im = a.Real * b.Imaginary + a.Imaginary * b.Real;

            return(Number.Functional.Downcast(new ComplexNumber(Re, Im)) as ComplexNumber);
        }
Exemplo n.º 4
0
 public static RealNumber operator *(RealNumber a, RealNumber b)
 {
     if (!a.IsDefinite() || !b.IsDefinite())
     {
         return(UndefinedStateSuperSwitch.Switch(
                    () => new RealNumber(UndefinedState.POSITIVE_INFINITY),
                    () => new RealNumber(UndefinedState.POSITIVE_INFINITY),
                    () => new RealNumber(UndefinedState.NEGATIVE_INFINITY),
                    () => new RealNumber(UndefinedState.NEGATIVE_INFINITY),
                    () => EDecimalWrapper.IsGreater(b.Value, 0) ? new RealNumber(UndefinedState.POSITIVE_INFINITY) : new RealNumber(UndefinedState.NEGATIVE_INFINITY),
                    () => EDecimalWrapper.IsGreater(b.Value, 0) ? new RealNumber(UndefinedState.NEGATIVE_INFINITY) : new RealNumber(UndefinedState.POSITIVE_INFINITY),
                    () => EDecimalWrapper.IsGreater(a.Value, 0) ? new RealNumber(UndefinedState.POSITIVE_INFINITY) : new RealNumber(UndefinedState.NEGATIVE_INFINITY),
                    () => EDecimalWrapper.IsGreater(a.Value, 0) ? new RealNumber(UndefinedState.NEGATIVE_INFINITY) : new RealNumber(UndefinedState.POSITIVE_INFINITY),
                    a, b));
     }
     if (!Functional.BothAreEqual(a, b, HierarchyLevel.REAL))
     {
         return(Number.OpMul(a, b) as RealNumber);
     }
     return(Number.Functional.Downcast(new RealNumber(CtxMultiply(a.Value, b.Value))) as RealNumber);
 }