public static void CheckIntIsInRange(ParameterInfo parameterInfo, object argument, Attribute attribute) { var intIsAttribute = (IntIsInRangeAttribute)attribute; var value = NumericOperations.ConvertToInt(argument, parameterInfo); switch (intIsAttribute.IncludingBorders) { case IncludingBorders.None: Checks.ExecutePreconditionCheck(() => value > intIsAttribute.Lower && value < intIsAttribute.Upper, () => $"{parameterInfo.Name} must be in Range ]{intIsAttribute.Lower}..{intIsAttribute.Upper}[ but found {value}"); break; case IncludingBorders.Lower: Checks.ExecutePreconditionCheck(() => value >= intIsAttribute.Lower && value < intIsAttribute.Upper, () => $"{parameterInfo.Name} must be in Range [{intIsAttribute.Lower}..{intIsAttribute.Upper}[ but found {value}"); break; case IncludingBorders.Upper: Checks.ExecutePreconditionCheck(() => value > intIsAttribute.Lower && value <= intIsAttribute.Upper, () => $"{parameterInfo.Name} must be in Range ]{intIsAttribute.Lower}..{intIsAttribute.Upper}] but found {value}"); break; case IncludingBorders.Lower | IncludingBorders.Upper: Checks.ExecutePreconditionCheck(() => value >= intIsAttribute.Lower && value <= intIsAttribute.Upper, () => $"{parameterInfo.Name} must be in Range [{intIsAttribute.Lower}..{intIsAttribute.Upper}] but found {value}"); break; default: throw new PreconditionViolatedException("unknown range border definition"); } }
public T InnerProduct(Vector <T> v2) { T result = NumericOperations.Multiply(this[MinIndex], v2[v2.MinIndex]); for (int i = v2.MinIndex + 1; i <= v2.MaxIndex; i++) { result = NumericOperations.Multiply(result, NumericOperations.Multiply(this[i], v2[i])); } return(result); }
//operator overloading for '*' operator. multiplying t1 with every index of v1 public static Vector <T> operator *(Vector <T> v1, T t1) { Vector <T> result = new Vector <T>(v1.Length, v1.MinIndex); /* if( mulTT == null ) * { * mulTT = new BinaryOperatorT<T,T,T>( GenericOperatorFactory<T, T, T, Vector<T>>.Multiply ); * }*/ for (int i = v1.MinIndex; i <= v1.MaxIndex; i++) { result[i] = NumericOperations.Multiply(v1[i], t1); } return(result); }
//operator overloading for '-' operator. Substracting v1 from t1 public static Vector <T> operator -(T t1, Vector <T> v1) { Vector <T> result = new Vector <T>(v1.Length, v1.MinIndex); /* if( subTT == null ) * { * subTT = new BinaryOperatorT<T,T,T>( GenericOperatorFactory<T, T, T, Vector<T>>.Subtract ); * }*/ for (int i = v1.MinIndex; i <= v1.MaxIndex; i++) { result[i] = NumericOperations.Subtract(t1, v1[i]); } return(result); }
//Operator overloading for '+' operator. Adding v2 to v1 public static Vector <T> operator +(Vector <T> v1, Vector <T> v2) { Vector <T> result = new Vector <T>(v1.Length, v1.MinIndex); int delta = v1.MinIndex - v2.MinIndex; /* if( addTT == null ) * { * addTT = new BinaryOperatorT<T,T,T>( GenericOperatorFactory<T, T, T, Vector<T>>.Add ); * }*/ for (int i = v1.MinIndex; i <= v1.MaxIndex; i++) { result[i] = NumericOperations.Add(v1[i], v2[(i - delta)]); } return(result); }
/// <summary> /// Creates a new instance of <see cref="NumericFilterCondition"/>. /// </summary> /// <param name="property">The property name, case insensitive.</param> /// <param name="operation">The operation to compare.</param> protected NumericFilterCondition(string property, NumericOperations operation) { Property = property; Operation = operation; }
public static NumberValue operator /(NumberValue a, NumberValue b) => NumericOperations.Mul(a, b.Inv());
public static NumberValue operator *(NumberValue a, NumberValue b) => NumericOperations.Mul(a, b);
public static NumberValue operator -(NumberValue a, NumberValue b) => NumericOperations.Add(a, b.Neg());
public static NumberValue operator +(NumberValue a, NumberValue b) => NumericOperations.Add(a, b);
/// <summary> /// Creates a new instance of <see cref="DateTimeFilterCondition"/>. /// </summary> /// <param name="property">The property name, case insensitive.</param> /// <param name="filter">The value used to filter.</param> /// <param name="filterTo">The other value used to filter. Used when the operation == "inRange"</param> /// <param name="operation">The operation to compare.</param> public DateTimeFilterCondition(string property, string filter, string filterTo, NumericOperations operation) : base(property, operation) { ParseFiltersValues(filter, filterTo); }
/// <summary> /// Creates a new instance of <see cref="DateTimeFilterCondition"/>. /// </summary> /// <param name="property">The property name, case insensitive.</param> /// <param name="filter">The value used to filter.</param> /// <param name="filterTo">The other value used to filter. Used when the operation == "inRange"</param> /// <param name="operation">The operation to compare.</param> public DateTimeFilterCondition(string property, DateTime?filter, DateTime?filterTo, NumericOperations operation) : base(property, operation) { Filter = filter; FilterTo = filterTo; }
/// <summary> /// Creates a new instance of <see cref="DoubleFilterCondition"/>. /// </summary> /// <param name="property">The property name, case insensitive.</param> /// <param name="filter">The value used to filter.</param> /// <param name="filterTo">The other value used to filter. Used when the operation == "inRange"</param> /// <param name="operation">The operation to compare.</param> public DoubleFilterCondition(string property, double?filter, double?filterTo, NumericOperations operation) : base(property, operation) { Filter = filter; FilterTo = filterTo; }