예제 #1
0
파일: Program.cs 프로젝트: RedMindZ/RedMath
        private static void TestCache()
        {
            Cache <string> cache = new Cache <string>();

            cache.AddCacheEntry("Det", 5, false, (Matrix <Real> mat) => mat.Determinant);
            cache.AddCacheEntry("Trans", null, false, (Matrix <Real> mat) => mat.Transposition);
            cache.AddCacheEntry("Inverse", null, false, (Matrix <Real> mat) => mat.Inverse);

            Console.WriteLine("Det:\n" + cache.RetrieveValue <Real, Matrix <Real> >("Det", m1));
            Console.WriteLine("Trans:\n" + cache.RetrieveValue <Matrix <Real>, Matrix <Real> >("Trans", m1));
            Console.WriteLine("Inverse:\n" + cache.RetrieveValue <Matrix <Real>, Matrix <Real> >("Inverse", m1));

            cache.SetAllUpdateStates(true);

            Console.WriteLine("Det:\n" + cache.RetrieveValue <Real, Matrix <Real> >("Det", m1));
            Console.WriteLine("Trans:\n" + cache.RetrieveValue <Matrix <Real>, Matrix <Real> >("Trans", m1));
            Console.WriteLine("Inverse:\n" + cache.RetrieveValue <Matrix <Real>, Matrix <Real> >("Inverse", m1));
        }
예제 #2
0
파일: Matrix.cs 프로젝트: RedMindZ/RedMath
 private void InitCache()
 {
     _computationCache.AddCacheEntry("determinant", null, true, (Matrix <T> mat) => mat.ComputeDeterminant());
     _computationCache.AddCacheEntry("echelonForm", null, true, (Matrix <T> mat) => mat.ComputeEchelonForm().Item1);
     _computationCache.AddCacheEntry("reducedEchelonForm", null, true, (Matrix <T> mat) => mat.ComputeReducedEchelonForm().Item1);
     _computationCache.AddCacheEntry("echelonFormOperations", null, true, (Matrix <T> mat) => mat.ComputeEchelonForm().Item2);
     _computationCache.AddCacheEntry("reducedEchelonFormOperations", null, true, (Matrix <T> mat) => mat.ComputeReducedEchelonForm().Item2);
     _computationCache.AddCacheEntry("decomposition", null, true, (Matrix <T> mat) => mat.ComputeDecomposition());
     _computationCache.AddCacheEntry("identity", false, true, (Matrix <T> mat) => mat.TestForIdentity());
     _computationCache.AddCacheEntry("cofactorMatrix", null, true, (Matrix <T> mat) => mat.ComputeCofactorMatrix());
     _computationCache.AddCacheEntry("inverse", null, true, (Matrix <T> mat) => mat.ComputeInverse());
     _computationCache.AddCacheEntry("rank", 0, true, (Matrix <T> mat) => mat.ComputeRank());
     _computationCache.AddCacheEntry("lowerTriangular", false, true, (Matrix <T> mat) => mat.TestForLowerTriangular());
     _computationCache.AddCacheEntry("upperTriangular", false, true, (Matrix <T> mat) => mat.TestForUpperTriangular());
 }