/// <summary>
 /// This will release references to the cached ConcatVectors created by cacheVectors(), so that they can be cleaned
 /// up by the GC.
 /// </summary>
 /// <remarks>
 /// This will release references to the cached ConcatVectors created by cacheVectors(), so that they can be cleaned
 /// up by the GC. If no cache was constructed, this is a no-op.
 /// </remarks>
 public virtual void ReleaseCache()
 {
     if (originalThunks != null)
     {
         // OPTIMIZATION:
         // Rather than use the standard iterator, which creates lots of int[] arrays on the heap, which need to be GC'd,
         // we use the fast version that just mutates one array. Since this is read once for us here, this is ideal.
         IEnumerator <int[]> fastPassByReferenceIterator = FastPassByReferenceIterator();
         int[] assignment = fastPassByReferenceIterator.Current;
         while (true)
         {
             SetAssignmentValue(assignment, originalThunks.GetAssignmentValue(assignment));
             // Set the assignment arrays correctly
             if (fastPassByReferenceIterator.MoveNext())
             {
                 fastPassByReferenceIterator.Current;
             }
             else
             {
                 break;
             }
         }
         // Release our replicated set of original thunks
         originalThunks = null;
     }
 }
Exemplo n.º 2
0
        public virtual void TestClone(NDArrayTest.NDArrayWithGold <double> testPair)
        {
            NDArray <double> clone = testPair.array.CloneArray();

            foreach (int[] assignment in testPair.gold.Keys)
            {
                NUnit.Framework.Assert.AreEqual(clone.GetAssignmentValue(assignment), 1.0e-5, testPair.gold[assignment]);
            }
        }