Example #1
0
        public override bool Equals(object obj)
        {
            if (obj is Unit)
            {
                return(OperationUtility.Equals(this, (obj as Unit)));
            }

            return(false);
        }
Example #2
0
        public override bool Equals(object obj)
        {
            if (obj is Dimension)
            {
                return(OperationUtility.Equals(this, obj as Dimension));
            }

            return(false);
        }
Example #3
0
        public static Dimension operator /(Dimension dividend, Dimension divisor)
        {
            if (divisor == Dimension.None)
            {
                return(dividend);
            }

            return(OperationUtility.RearrangeDivision((x, y) => x * y, (x, y) => x / y, dividend, divisor) ??
                   OperationUtility.ReduceDivision(x => x.Multiply((a, b) => a * b, Dimension.None), (x, y) => x / y, (x, y) => x ^ y, dividend, divisor) ??
                   Div(dividend, divisor));
        }
Example #4
0
        public static Unit operator /(Unit dividend, Unit divisor)
        {
            if (divisor == None)
            {
                return(dividend);
            }

            return(OperationUtility.RearrangeDivision((x, y) => x * y, (x, y) => x / y, dividend, divisor) ??
                   OperationUtility.ReduceDivision(x => x.Multiply((a, b) => a * b, None), (x, y) => x / y, (x, y) => x ^ y, dividend, divisor) ??
                   Divide(dividend, divisor));
        }
Example #5
0
        public static Dimension operator *(Dimension d1, Dimension d2)
        {
            if (d1 == Dimension.None) // and if d2 == None, return d2 (=None)
            {
                return(d2);
            }

            if (d2 == Dimension.None)
            {
                return(d1);
            }

            // where to put OperationUtility.ReduceMultiplication
            return(OperationUtility.RearrangeMultiplication(x => x.Multiply((a, b) => a * b, Dimension.None), (x, y) => x / y, d1, d2) ??
                   OperationUtility.ReduceMultiplication(x => x.Multiply((a, b) => a * b, Dimension.None), (x, y) => x ^ y, d1, d2) ??
                   Mult(d1, d2));
        }
Example #6
0
        public static Unit operator *(Unit u1, Unit u2)
        {
            if (u1 == None) // and if u2 == None, return u2 (=None)
            {
                return(u2);
            }

            if (u2 == None)
            {
                return(u1);
            }

            // where to put OperationUtility.ReduceMultiplication
            return(OperationUtility.RearrangeMultiplication(x => x.Multiply((a, b) => a * b, None), (x, y) => x / y, u1, u2) ??
                   OperationUtility.ReduceMultiplication(x => x.Multiply((a, b) => a * b, None), (x, y) => x ^ y, u1, u2) ??
                   Multiply(u1, u2));
        }
Example #7
0
        public static Dimension operator ^(Dimension @base, int exponent)
        {
            if (exponent < 0)
            {
                return(1 / (@base ^ (-exponent)));
            }

            if (exponent == 0)
            {
                return(Dimension.None);
            }

            if (exponent == 1)
            {
                return(@base);
            }

            return(OperationUtility.ExpandPower(x => x.Multiply((a, b) => a * b, Dimension.None), (x, y) => x / y, (x, y) => x ^ y, @base, exponent) ??
                   Pow(@base, exponent));
        }
Example #8
0
 public override bool Equals(object obj) => OperationUtility.Equals(this, obj as IDivisionOperation);
Example #9
0
 public static Dimension operator /(int dividend, Dimension divisor)
 {
     return(OperationUtility.RearrangeDivision((x, y) => x * y, (x, y) => x / y, Dimension.None, divisor) ??
            Div(Dimension.None, divisor));
 }
Example #10
0
 public override bool Equals(object obj) => OperationUtility.Equals(this, obj as IProductOperation);
Example #11
0
 public ProductUnit(Unit[] operands)
 {
     _operands = new ReadOnlyCollection<Unit>(OperationUtility.LinearizeMultiplication(operands).ToList());
 }
Example #12
0
 public static Unit operator /(int dividend, Unit divisor)
 {
     return(OperationUtility.RearrangeDivision((x, y) => x * y, (x, y) => x / y, None, divisor) ??
            Divide(None, divisor));
 }
 internal ProductDimension(params Dimension[] operands)
 {
     _operands = new ReadOnlyCollection <Dimension>(OperationUtility.LinearizeMultiplication(operands).ToList());
 }