示例#1
0
 private PolynomialTerm(IndeterminateExpression term)
 {
     _coefficient = 1;
     if (term.IsOne)
     {
         _indeterminates            = default;
         _indeterminatesSignature   = string.Empty;
         GreatestPowerIndeterminate = default;
     }
     else
     {
         _indeterminates            = new[] { term };
         _indeterminatesSignature   = _indeterminates.AsList().Single().ToString();
         GreatestPowerIndeterminate = term;
     }
 }
示例#2
0
        private PolynomialTerm(
            double coefficient,
            ReadOnlyArray <IndeterminateExpression> indeterminates,
            string?signature,
            IndeterminateExpression greatestPowerExpression)
        {
            bool anyIndeterminates = indeterminates.Length > 0;
            bool hasSignature      = signature != null;

            if (coefficient.NumericEquals(0) && anyIndeterminates)
            {
                throw new ArgumentException(nameof(indeterminates));
            }

            _coefficient    = coefficient;
            _indeterminates = indeterminates;
            if (anyIndeterminates == hasSignature)
            {
                _indeterminatesSignature   = signature ?? string.Empty;
                GreatestPowerIndeterminate = greatestPowerExpression;
            }
            else
            {
                _indeterminatesSignature   = anyIndeterminates ? string.Join(string.Empty, indeterminates.AsList()) : string.Empty;
                GreatestPowerIndeterminate = anyIndeterminates ? FindGreatestPowerIndeterminate(indeterminates.AsList()) : default;
            }
        }
示例#3
0
        /*
         * Query
         */

        internal IEnumerable <VariableTerm> GetIdentityVariableTerms()
        {
            return(_indeterminates
                   .AsList()
                   .Where(i => !i.HasUnaryModifier).Select(i => new VariableTerm(variable: i.Variable, power: i.Power)));
        }
        /*
         * Query
         */

        internal Dictionary <char, ushort> GetIdentityVariableTerms()
        {
            return(_terms.AsList().Select(t => t.GetIdentityVariableTerms())
                   .AggregateCommonBy(v => v.Variable, vc => vc.Select(v => v.Power).MinDefensive()));
        }