Exemplo n.º 1
0
        public Expr[] KVectorPartToColumnVector(int grade)
        {
            var columnVectorLength = GMacMathUtils.KvSpaceDimension(VSpaceDimension, grade);
            var columnVector       = new Expr[columnVectorLength];

            for (var index = 0; index < columnVectorLength; index++)
            {
                columnVector[index] = this[grade, index];
            }

            return(columnVector);
        }
        /// <summary>
        /// Create a default subspaces of k-vectors with a given grade and name
        /// </summary>
        private void DefineDefaultSubspaces_KVectors(GMacFrame frame, int grade, string subspaceName)
        {
            var basisCount = GMacMathUtils.KvSpaceDimension(frame.VSpaceDimension, grade);
            var idsList    = new List <int>(basisCount);

            for (var index = 0; index < basisCount; index++)
            {
                idsList.Add(GMacMathUtils.BasisBladeId(grade, index));
            }

            var subspaceSignature = BooleanPattern.CreateFromTrueIndexes(frame.GaSpaceDimension, idsList);

            var subspace = frame.DefineSubspace(subspaceName, subspaceSignature);

            subspace.AddCodeLocation(Context.GetCodeLocation(frame.ParseNode));
        }
Exemplo n.º 3
0
        public GMacMultivectorBinding BindKVectorToVariables(int grade)
        {
            if (BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame.IsValidGrade(grade) == false)
            {
                throw new InvalidOperationException("Grade not accepted");
            }

            var kvSpaceDim =
                GMacMathUtils.KvSpaceDimension(BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame.VSpaceDimension, grade);

            for (var index = 0; index < kvSpaceDim; index++)
            {
                BindCoefToVariable(grade, index);
            }

            return(this);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the basis blades having the given grades grouped by their grade
        /// </summary>
        /// <param name="gradesSeq"></param>
        /// <returns></returns>
        public Dictionary <int, List <AstFrameBasisBlade> > BasisBladesGroupedByGrade(params int[] gradesSeq)
        {
            var result = new Dictionary <int, List <AstFrameBasisBlade> >();

            foreach (var grade in gradesSeq)
            {
                var kvSpaceDim = GMacMathUtils.KvSpaceDimension(VSpaceDimension, grade);

                var newList = new List <AstFrameBasisBlade>(kvSpaceDim);

                for (var index = 0; index < kvSpaceDim; index++)
                {
                    newList.Add(BasisBlade(grade, index));
                }

                result.Add(grade, newList);
            }

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns the basis blades having the given grades grouped by their grade
        /// </summary>
        /// <param name="startGrade"></param>
        /// <returns></returns>
        public Dictionary <int, List <AstFrameBasisBlade> > BasisBladesGroupedByGrade(int startGrade = 0)
        {
            var result = new Dictionary <int, List <AstFrameBasisBlade> >();

            for (var grade = startGrade; grade <= VSpaceDimension; grade++)
            {
                var kvSpaceDim = GMacMathUtils.KvSpaceDimension(VSpaceDimension, grade);

                var newList = new List <AstFrameBasisBlade>(kvSpaceDim);

                for (var index = 0; index < kvSpaceDim; index++)
                {
                    newList.Add(BasisBlade(grade, index));
                }

                result.Add(grade, newList);
            }

            return(result);
        }
        /// <summary>
        /// Create the default subspace of odd multivectors named @odd@
        /// </summary>
        /// <returns></returns>
        private GMacFrameSubspace DefineDefaultSubspaces_Odd(GMacFrame frame)
        {
            var idsList = new List <int>(frame.GaSpaceDimension);

            for (var grade = 1; grade <= frame.VSpaceDimension; grade = grade + 2)
            {
                var basisCount = GMacMathUtils.KvSpaceDimension(frame.VSpaceDimension, grade);

                for (var index = 0; index < basisCount; index++)
                {
                    idsList.Add(GMacMathUtils.BasisBladeId(grade, index));
                }
            }

            const string subspaceName      = "Odd";
            var          subspaceSignature = BooleanPattern.CreateFromTrueIndexes(frame.GaSpaceDimension, idsList);

            var subspace = frame.DefineSubspace(subspaceName, subspaceSignature);

            subspace.AddCodeLocation(Context.GetCodeLocation(frame.ParseNode));

            return(subspace);
        }