예제 #1
0
        public IGMacCompositeBinding PickConstantComponents()
        {
            var mvPattern = new GMacMultivectorBinding(BaseFrameMultivector);

            foreach (var pair in _patternDictionary.Where(pair => pair.Value.IsConstant))
            {
                mvPattern._patternDictionary.Add(pair.Key, pair.Value);
            }

            return(mvPattern);
        }
예제 #2
0
        /// <summary>
        /// Create a multivector pattern binding all IDs in the given subspace to variables
        /// </summary>
        /// <param name="subspace"></param>
        /// <returns></returns>
        public static GMacMultivectorBinding Create(AstFrameSubspace subspace)
        {
            var mvPattern = new GMacMultivectorBinding(subspace.FrameMultivector);

            foreach (var id in subspace.AssociatedSubspace.SubspaceSignaturePattern.TrueIndexes)
            {
                mvPattern.BindCoefToVariable(id);
            }

            return(mvPattern);
        }
예제 #3
0
        /// <summary>
        /// True if the given multivector pattern matches this pattern in all its variables and constants
        /// </summary>
        /// <param name="mvPattern"></param>
        /// <returns></returns>
        public bool MatchesPattern(GMacMultivectorBinding mvPattern)
        {
            if (_patternDictionary.Count != mvPattern._patternDictionary.Count)
            {
                return(false);
            }

            return
                (_patternDictionary
                 .All(
                     pair => mvPattern.ContainsScalarPattern(pair.Key, pair.Value)
                     ));
        }
예제 #4
0
        /// <summary>
        /// Create a multivector pattern from the given multivector value using only non-constant components
        /// from the multivector
        /// </summary>
        /// <param name="mv"></param>
        /// <returns></returns>
        public static GMacMultivectorBinding CreateFromNonConstants(AstValueMultivector mv)
        {
            var mvPattern = new GMacMultivectorBinding(mv.FrameMultivector);

            foreach (var term in mv.AssociatedMultivectorValue.MultivectorCoefficients)
            {
                if (term.Value.IsConstant() == false)
                {
                    mvPattern.BindCoefToVariable(term.Key);
                }
            }

            return(mvPattern);
        }
예제 #5
0
        public IGMacBinding ToConstantsFreePattern()
        {
            var mvPattern = new GMacMultivectorBinding(BaseFrameMultivector);

            foreach (var pair in _patternDictionary)
            {
                mvPattern
                ._patternDictionary
                .Add(
                    pair.Key,
                    (GMacScalarBinding)pair.Value.ToConstantsFreePattern()
                    );
            }

            return(mvPattern);
        }
예제 #6
0
        /// <summary>
        /// Create a multivector pattern having no constant components from the given multivector value
        /// </summary>
        /// <param name="mv"></param>
        /// <param name="ignoreZeroCoefs"></param>
        /// <returns></returns>
        public static GMacMultivectorBinding CreateConstantsFree(AstValueMultivector mv, bool ignoreZeroCoefs = true)
        {
            var mvPattern = new GMacMultivectorBinding(mv.FrameMultivector);

            foreach (var term in mv.AssociatedMultivectorValue.MultivectorCoefficients)
            {
                if (ignoreZeroCoefs && term.Value.IsZero())
                {
                    continue;
                }

                mvPattern.BindCoefToVariable(term.Key);
            }

            return(mvPattern);
        }
예제 #7
0
        /// <summary>
        /// Create a multivector pattern from the given multivector value using only constant components
        /// from the multivector
        /// </summary>
        /// <param name="mv"></param>
        /// <param name="ignoreZeroCoefs"></param>
        /// <returns></returns>
        public static GMacMultivectorBinding CreateFromConstants(AstValueMultivector mv, bool ignoreZeroCoefs = true)
        {
            var mvPattern = new GMacMultivectorBinding(mv.FrameMultivector);

            foreach (var term in mv.AssociatedMultivectorValue.MultivectorCoefficients)
            {
                if (ignoreZeroCoefs && term.Value.IsZero())
                {
                    continue;
                }

                if (term.Value.IsConstant())
                {
                    mvPattern.BindCoefToConstant(term.Key, term.Value.MathExpr);
                }
            }

            return(mvPattern);
        }
예제 #8
0
        /// <summary>
        /// Create a multivector pattern from the given multivector value using only constant components
        /// from the multivector. All the created bindings are variable bindings
        /// </summary>
        /// <param name="mv"></param>
        /// <param name="ignoreZeroCoefs"></param>
        /// <returns></returns>
        public static GMacMultivectorBinding CreateConstantsFreeFromConstants(AstValueMultivector mv, bool ignoreZeroCoefs = true)
        {
            var mvPattern = new GMacMultivectorBinding(mv.FrameMultivector);

            foreach (var term in mv.AssociatedMultivectorValue.SymbolicMultivector.NonZeroTerms)
            {
                if (ignoreZeroCoefs && term.Value.IsZero())
                {
                    continue;
                }

                if (term.Value.IsConstant())
                {
                    mvPattern.BindCoefToVariable(term.Key);
                }
            }

            return(mvPattern);
        }