private Variable(double value, Dictionary<Dimension, int> compositeDimension, Dimension dimension, bool isCompositeDimension) { this.value = value; this.complexDimension = compositeDimension; this.dimension = dimension; this.isComplexDimension = isCompositeDimension; }
internal KnownUnit(IUnitSystem system, double factor, Dimension dimension, string symbol, string name, bool inherentPrefix) : base(system, factor, dimension) { Check.Argument(symbol, nameof(symbol)).IsNotNull(); Check.Argument(name, nameof(name)).IsNotNull(); this.Symbol = symbol; this.Name = name; if (inherentPrefix) { this.DeriveInherentFactorAndBaseSymbol(symbol); } else { this.InherentFactor = 1; this.BaseSymbol = symbol; } }
private static Variable Convert(Variable v, double coefficient, Dimension si, Dimension notSi) { if (!v.IsComplexDimension) { return new Variable(v.Value * coefficient, si); } else { var dimension = CloneDimension.Clone(v.ComplexDimension); var power = dimension[notSi]; dimension.Remove(notSi); dimension.Add(si, power); if (power > 0) { return new Variable(v.Value * Math.Pow(coefficient, power), dimension); } else { return new Variable(v.Value / Math.Pow(coefficient, power * (-1)) , dimension); } } }
public Unit CreateUnit(double factor, Dimension dimension) { // Prefer returning a known unit KnownUnit known; if (this.units.TryGetValue(Tuple.Create(factor, dimension), out known)) { return known; } return this.unitFactory.CreateUnit(this, factor, dimension); }
public Variable(double value, Dimension dimension) { this.value = value; this.dimension = dimension; }
internal KnownUnit(IUnitSystem system, double factor, Dimension dimension, string symbol, string name) : this(system, factor, dimension, symbol, name, false) { this.Symbol = symbol; }
public Unit CreateUnit(double factor, Dimension dimension) { // Prefer returning a known or coherent unit KnownUnit known; Unit coherent; if (this.units.TryGetValue(Tuple.Create(factor, dimension), out known)) { return known; } else if(factor.Equals(1) && this.coherentUnits.TryGetValue(dimension, out coherent)) { return coherent; } return this.unitFactory.CreateUnit(this, factor, dimension); }