Esempio n. 1
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            //String type F.GetArgumentTypeName(0, S.m_GMV.Name);
            return((F.Name == "equals") && (F.MatchNbArguments(NB_ARGS)) &&
                   G25.CG.Shared.Functions.NotMixSmvGmv(S, F, NB_ARGS, S.m_GMV.Name) &&
                   G25.CG.Shared.Functions.NotUseOm(S, F, NB_ARGS, S.m_GMV.Name));
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            string arg1Type = F.GetArgumentTypeName(0, S.m_GMV.Name);

            return((IsIncrement(F) || IsDecrement(F)) && (F.MatchNbArguments(1) &&
                                                          (S.IsSpecializedMultivectorName(arg1Type) || (arg1Type == S.m_GMV.Name))));
        }
Esempio n. 3
0
 /// <summary>
 /// Checks if this FunctionGenerator can implement a certain function.
 /// </summary>
 /// <param name="S">The specification of the algebra.</param>
 /// <param name="F">The function to be implemented.</param>
 /// <returns>true if 'F' can be implemented</returns>
 public override bool CanImplement(Specification S, G25.fgs F)
 {
     return(((F.Name == "hp") || (F.Name == "ihp")) && (F.MatchNbArguments(NB_ARGS)) &&
            G25.CG.Shared.Functions.NotMixScalarGmv(S, F, NB_ARGS, S.m_GMV.Name) &&
            G25.CG.Shared.Functions.NotMixSmvGmv(S, F, NB_ARGS, S.m_GMV.Name) &&
            G25.CG.Shared.Functions.NotUseOm(S, F, NB_ARGS, S.m_GMV.Name));
 }
Esempio n. 4
0
        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented.</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            int NB_ARGS = 2;

            return((IsAdd(F) || IsSubtract(F)) && (F.MatchNbArguments(NB_ARGS)) &&
                   G25.CG.Shared.Functions.NotMixSmvGmv(S, F, NB_ARGS, S.m_GMV.Name) &&
                   G25.CG.Shared.Functions.NotMixScalarGmv(S, F, NB_ARGS, S.m_GMV.Name) &&
                   G25.CG.Shared.Functions.NotUseOm(S, F, NB_ARGS, S.m_GMV.Name));
        }
Esempio n. 5
0
        protected RefGA.Multivector m_returnValue; ///< returned value (symbolic multivector)

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            String arg1Type = F.GetArgumentTypeName(0, S.m_GMV.Name);

            return((F.Name == "sas") && (F.MatchNbArguments(3) &&
                                         (S.IsSpecializedMultivectorName(arg1Type) || (arg1Type == S.m_GMV.Name)) &&
                                         S.IsFloatType(F.GetArgumentTypeName(1, S.m_GMV.Name)) &&
                                         S.IsFloatType(F.GetArgumentTypeName(2, S.m_GMV.Name))));
        }
Esempio n. 6
0
        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            if (!(IsApplyVersor(F) || IsApplyVersorWI(F) || IsApplyUnitVersor(F)))
            {
                return(false);
            }

            int nbArgs = GetNbArgs(F);

            // don't allow mixing of GMV/SMV or Scalar/SMV
            if (!G25.CG.Shared.Functions.NotMixSmvGmv(S, F, nbArgs, S.m_GMV.Name))
            {
                return(false);
            }
            if (!G25.CG.Shared.Functions.NotMixScalarGmv(S, F, nbArgs, S.m_GMV.Name))
            {
                return(false);
            }

            return(((IsApplyVersor(F) || IsApplyUnitVersor(F)) && F.MatchNbArguments(2)) ||
                   (IsApplyVersorWI(F) && F.MatchNbArguments(3)));
        }
Esempio n. 7
0
        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            if (!((F.Name == "log") && (F.MatchNbArguments(1))))
            {
                return(false);
            }

            string type = F.GetOption("type");

            if (type == null)
            {
                return(false);
            }

            return(type.ToLower().Equals("euclidean"));
        }
Esempio n. 8
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            if (F.Name.Length < G25.CG.Shared.CANSparts.EXTRACT_GRADE.Length)
            {
                return(false);
            }

            try
            {
                int gradeIdx = GetGradeIdx(F.Name);
                return(F.Name.StartsWith(G25.CG.Shared.CANSparts.EXTRACT_GRADE) && F.MatchNbArguments(1) && // get the name & number of arguments right
                       (((gradeIdx >= 0) && (gradeIdx <= S.m_dimension)) ||                                 // either specify the grade index
                        ((gradeIdx < 0) && (F.GetArgumentTypeName(0, S.m_GMV.Name) == S.m_GMV.Name))));     // or be a function over general multivectors and leave out the grade
            }
            catch (Exception)
            {
                // we arrive there when F.Name is gradeX where X is not a number.
                return(false);
            }
        }
Esempio n. 9
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented.</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            int NB_ARGS = 2;
            // do a basic check first:
            bool OK1 = ((F.Name == "applyOM") &&
                        (F.MatchNbArguments(NB_ARGS)) &&
                        G25.CG.Shared.Functions.IsOm(S, F, 0) && // argument 0 must be an outermorphism
                        G25.CG.Shared.Functions.IsMv(S, F, 1));  // argument 1 must be an multivector

            if (!OK1)
            {
                return(false);
            }

            // specialized outermorphisms can only be applied to specialized multivectors
            if (G25.CG.Shared.Functions.IsSom(S, F, 0) &&
                (!G25.CG.Shared.Functions.IsSmv(S, F, 1)))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
 /// <summary>
 /// Checks if this FunctionGenerator can implement a certain function.
 /// </summary>
 /// <param name="S">The specification of the algebra.</param>
 /// <param name="F">The function to be implemented.</param>
 /// <returns>true if 'F' can be implemented</returns>
 public override bool CanImplement(Specification S, G25.fgs F)
 {
     return((F.Name == "div") && (F.MatchNbArguments(2) &&
                                  S.IsFloatType(F.ArgumentTypeNames[1])));
 }
Esempio n. 11
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            return((IsNorm(F) || IsNorm2(F)) && (F.MatchNbArguments(1)));
        }
Esempio n. 12
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            return((IsHip(F) || IsMHip(F) || IsLc(F) || IsRc(F) || IsSp(F)) &&
                   (F.MatchNbArguments(2)));
        }
Esempio n. 13
0
 /// <returns>true when input to function is coordinates.</returns>
 public bool IsRandom(Specification S, G25.fgs F)
 {
     return((F.Name == "randomCgaPoint") && F.MatchNbArguments(0));
 }
Esempio n. 14
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            return((IsReverse(F) || IsNegate(F) || IsCliffordConjugate(F) || IsGradeInvolution(F)) &&
                   (F.MatchNbArguments(1)));
        }
Esempio n. 15
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>();                  ///< generated function name with full mangling, etc


        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            return((IsExp(F) || IsCos(F) || IsSin(F) || IsCosh(F) || IsSinh(F)) && (F.MatchNbArguments(1)));
        }
Esempio n. 16
0
 /// <returns>true when input to function is coordinates.</returns>
 public bool IsCoordBased(Specification S, G25.fgs F, FloatType FT)
 {
     return(F.MatchNbArguments(S.m_dimension - 2) &&
            S.IsFloatType(F.GetArgumentTypeName(0, FT.type)) &&
            (!IsRandom(S, F)));
 }
Esempio n. 17
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented.</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            return(IsGradeBitmap(F) && (F.MatchNbArguments(2)));
        }
Esempio n. 18
0
        protected G25.VariableType m_returnType;                                              ///< return type

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            return((F.Name == "versorInverse") && F.MatchNbArguments(1));
        }
Esempio n. 19
0
        protected Dictionary <string, string> m_funcName = new Dictionary <string, string>(); ///< generated function name with full mangling, etc

        /// <summary>
        /// Checks if this FunctionGenerator can implement a certain function.
        /// </summary>
        /// <param name="S">The specification of the algebra.</param>
        /// <param name="F">The function to be implemented.</param>
        /// <returns>true if 'F' can be implemented</returns>
        public override bool CanImplement(Specification S, G25.fgs F)
        {
            return((F.Name == "op") && (F.MatchNbArguments(2)));
        }
Esempio n. 20
0
 /// <summary>
 /// Checks if this FunctionGenerator can implement a certain function.
 /// </summary>
 /// <param name="S">The specification of the algebra.</param>
 /// <param name="F">The function to be implemented.</param>
 /// <returns>true if 'F' can be implemented.</returns>
 public override bool CanImplement(Specification S, G25.fgs F)
 {
     return(IsRandom(S, F) ||
            (((F.Name == "cgaPoint") && (F.MatchNbArguments(1) || F.MatchNbArguments(S.m_dimension - 2)))));
 }