Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X3 [33X[0;0YCaches[133X[101X234[1X3.1 [33X[0;0YObject constructors[133X[101X56[33X[0;0YCaches are objects which store for a fixed number of keys a value, so they7are a map Obj^k -> Obj, while the k is fixed. A cache ususally stores the8result in a weak pointer list, which means that if the value which the cache9should store is not referenced in the system anymore, it will not be10remembered by the cache. However, caches can be set to store the value11permanently (crisp), or not to store any new value at all (inaktive). In12that case, already stored values are still in the cache and can be accessed13once the cache is set active again.[133X1415[1X3.1-1 CachingObject[101X1617[29X[2XCachingObject[102X( [[3Xk[103X, ][[3Xis_crisp[103X] ) [32X operation18[29X[2XCachingObject[102X( [3Xarg[103X ) [32X operation19[29X[2XCachingObject[102X( [3Xarg1[103X, [3Xarg2[103X ) [32X operation20[6XReturns:[106X [33X[0;10Ya cache[133X2122[33X[0;0YIf no argument is given, the function returns a weak cache with key length23one, if an integer k is given, a weak cache with key length k, and if the24bool is_crisp is true, a crisp cache with the corresponding length.[133X2526[1X3.1-2 CachingObject[101X2728[29X[2XCachingObject[102X( [3Xobject[103X, [3Xcache_name[103X, [3Xlength[103X[, [3Xis_crisp[103X] ) [32X operation29[29X[2XCachingObject[102X( [3Xarg1[103X, [3Xarg2[103X, [3Xarg3[103X, [3Xarg4[103X ) [32X operation3031[33X[0;0YThis methods are not installed, they serve as an interface for32InstallMethodWithCacheFromObject.[133X333435[1X3.2 [33X[0;0YSetters, getters[133X[101X3637[1X3.2-1 CacheValue[101X3839[29X[2XCacheValue[102X( [3Xcache[103X, [3Xkey[103X ) [32X operation40[6XReturns:[106X [33X[0;10Ystored value[133X4142[33X[0;0YIf there is a value stored in the cache for key, which can be a single key43for caches with key length one or a list of keys depending on the key length44of the cache, this method returns a list only contraining the value,45otherwise an empty list.[133X4647[1X3.2-2 SetCacheValue[101X4849[29X[2XSetCacheValue[102X( [3Xcache[103X, [3Xkey[103X, [3Xvalue[103X ) [32X operation5051[33X[0;0YSets the value of key of the cache to value.[133X5253[1X3.2-3 IsEqualForCache[101X5455[29X[2XIsEqualForCache[102X( [3Xobj1[103X, [3Xobj2[103X ) [32X operation56[6XReturns:[106X [33X[0;10Ytrue or false[133X5758[33X[0;0YThis function is used to compare objects for the caches. The standard way is59IsIdenticalObj, and lists are compared recursive with this function. It is60possible and recommended to overload this function as needed.[133X616263[1X3.3 [33X[0;0YManaging functions[133X[101X6465[1X3.3-1 SetCachingObjectCrisp[101X6667[29X[2XSetCachingObjectCrisp[102X( [3Xcache[103X ) [32X function68[6XReturns:[106X [33X[0;10Ynothing[133X6970[33X[0;0YSets the caching to crisp, weak, or deativates the cache completely.[133X7172[1X3.3-2 SetCachingObjectWeak[101X7374[29X[2XSetCachingObjectWeak[102X( [3Xarg[103X ) [32X function7576[1X3.3-3 DeactivateCachingObject[101X7778[29X[2XDeactivateCachingObject[102X( [3Xarg[103X ) [32X function798081[1X3.4 [33X[0;0YInstall functions[133X[101X8283[1X3.4-1 InstallMethodWithCache[101X8485[29X[2XInstallMethodWithCache[102X( [3XLike[103X, [3XInstallMethod[103X ) [32X function8687[33X[0;0YInstalls a method like InstallMethod, but additionally puts a cache layer88around it so that the result is cached. It is possible to give the cache as89the option Cache, to use the same cache for more than one method or store it90somewhere to have access to the cache.[133X9192[1X3.4-2 InstallMethodWithCrispCache[101X9394[29X[2XInstallMethodWithCrispCache[102X( [3Xarg[103X ) [32X function9596[33X[0;0YLike InstallMethodWithCache, but with a crisp cache.[133X9798[1X3.4-3 InstallMethodWithCacheFromObject[101X99100[29X[2XInstallMethodWithCacheFromObject[102X( [3XLike[103X, [3XInstallMethod[103X ) [32X function101102[33X[0;0YThis works just like InstallMethodWithCache, but it extracts the cache via103the CachingObject method from one of its arguments. The CachingObject must104then be implemented for one of the arguments, and the option ArgumentNumber105can specify which option to be used. As second argument for CachingObject a106string is used, which can identify the cache. Standard is the name of the107operation, for which the method is installed, but it can be specified using108the CacheName option.[133X109110[1X3.4-4 FunctionWithCache[101X111112[29X[2XFunctionWithCache[102X( [3Xfunc[103X ) [32X function113[6XReturns:[106X [33X[0;10Ya function[133X114115[33X[0;0YCreates a cached function out of a given function [3Xfunc[103X. If the option Cache116is a cache, this cache is used. If the option Cache is the string crisp, a117crisp cache is used. All other values for this option lead to a single weak118cache.[133X119120121122