コード例 #1
0
ファイル: Function.cs プロジェクト: tipfom/calq
        public override Term Clone()
        {
            Function ret = null;

            Term[] paras = Parameters.Select(x => (Term)x.Clone()).ToArray();
            switch (Name)
            {
            case FuncType.Addition:
                ret = new Addition(IsAddInverse, IsMulInverse, paras); break;

            case FuncType.Multiplication:
                ret = new Multiplication(IsAddInverse, IsMulInverse, paras); break;

            case FuncType.Power:
                ret = new Power(IsAddInverse, IsMulInverse, paras); break;

            case FuncType.Sin:
                ret = new Sin(IsAddInverse, IsMulInverse, paras); break;

            case FuncType.Cos:
                ret = new Cos(IsAddInverse, IsMulInverse, paras); break;

            case FuncType.Log:
                ret = new Logarithm(IsAddInverse, IsMulInverse, paras); break;

            case FuncType.Differentiate:
                ret = new Differentiate(IsAddInverse, IsMulInverse, paras); break;

            case FuncType.Integrate:
                ret = new Integrate(IsAddInverse, IsMulInverse, paras); break;
            }

            return(ret);
        }
コード例 #2
0
 public override Term CheckAddReduce(Term t)
 {
     if (t.GetType() == typeof(Logarithm))
     {
         Logarithm tAsLogarithm = t as Logarithm;
         if (Parameters.Length == 1 && tAsLogarithm.Parameters.Length == 1)
         {
             return(new Logarithm((Parameters[0] * tAsLogarithm.Parameters[0]).Reduce()));
         }
         else if (Parameters.Length == 2 && tAsLogarithm.Parameters.Length == 2 && Parameters[1] == tAsLogarithm.Parameters[1])
         {
             return(new Logarithm((Parameters[0] * tAsLogarithm.Parameters[0]).Reduce(), Parameters[1]));
         }
     }
     return(null);
 }