예제 #1
0
 public override void DeleteTermsOperation()
 {
     foreach (var item in Terms)
     {
         if (item != null)
         {
             Terms.Variable x = item as Terms.Variable;
             x.Clean();
         }
     }
     Terms.Clear();
 }
예제 #2
0
        public virtual unsafe Term GetTerm(Index time)
        {
            if (time.N != OuterShape.N)
            {
                throw new Exception("");
            }

            int index = 0;
            int mult  = 1;

            for (int i = time.N - 1; i >= 0; i--)
            {
                index += time[i] * mult;
                mult  *= OuterShape[i];
                if (time[i] < 0 || time[i] >= OuterShape[i])
                {
                    if (EmptyVariable == null)
                    {
                        EmptyVariable = new Terms.Variable(InnerShape.Clone())
                        {
                            Trainable = false
                        };
                        EmptyVariable.Weights.SetFloat(0);
                    }
                    else if (!EmptyVariable.Shape.EqualShape(InnerShape))
                    {
                        EmptyVariable.Clean();
                        EmptyVariable = new Terms.Variable(InnerShape.Clone())
                        {
                            Trainable = false
                        };
                        EmptyVariable.Weights.SetFloat(0);
                    }

                    return(EmptyVariable);
                }
            }

            while (Terms.Count <= index)
            {
                Terms.Add(null);
            }

            if (Terms[index] == null)
            {
                return(Terms[index] = CreateTerm(time));
            }

            return(Terms[index]);
        }