Beispiel #1
0
 private Variable(double value,
      Dictionary<Dimension, int> compositeDimension,
      Dimension dimension, 
      bool isCompositeDimension)
 {
     this.value = value;
     this.complexDimension = compositeDimension;
     this.dimension = dimension;
     this.isComplexDimension = isCompositeDimension;
 }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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);
                }
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public Variable(double value, Dimension dimension)
 {
     this.value = value;
     this.dimension = dimension;
 }
Beispiel #6
0
 internal KnownUnit(IUnitSystem system, double factor, Dimension dimension, string symbol, string name)
     : this(system, factor, dimension, symbol, name, false)
 {
     this.Symbol = symbol;
 }
Beispiel #7
0
        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);
        }