示例#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;
 }
示例#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;
            }
        }
示例#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);
                }
            }
        }
示例#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);
        }
示例#5
0
 public Variable(double value, Dimension dimension)
 {
     this.value = value;
     this.dimension = dimension;
 }
示例#6
0
 internal KnownUnit(IUnitSystem system, double factor, Dimension dimension, string symbol, string name)
     : this(system, factor, dimension, symbol, name, false)
 {
     this.Symbol = symbol;
 }
示例#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);
        }