BigInteger Extensions BigInteger Extensions
BigInteger Extensions BigInteger Extensions
DocFX + Singulink = ♥

Search Results for

    Class BigIntegerPowCache

    Provides caching of BigInteger powers for a given basis (from 3 to 10). Exponents that are bigger than the size of the cache are calculated each time they are requested.

    Inheritance
    object
    BigIntegerPowCache
    Namespace: Singulink.Numerics
    Assembly: Singulink.Numerics.BigIntegerExtensions.dll
    Syntax
    public sealed class BigIntegerPowCache
    Remarks

    Caching powers of 2 is not supported - use left/right shifting for a more memory and CPU efficient means of multiplying/dividing values by powers of 2.

    You can safely get a cache instance without risking using large amounts of unnecessary memory in the event that the cache is not needed since it is empty when it is first created. The cache is populated on the first request for a value. Only 1 instance of a cache exists for a given basis.

    When an exponent is requested that is larger than the current cache size, the cache is expanded by a minimum of 64 entries or as needed to ensure it includes the requested exponent. This involves creating a new array to hold the expanded cache, copying previously cached values over, and calculating all the rest of the missing values. Since caching results of a power function is already exponential in nature, a linear approach is used to expand the size of the cache instead of doubling its size.

    Properties

    Name Description
    Basis

    Gets the base of the exponent for this cache.

    MaxSize

    Gets the maximum cache size. The largest cached exponent is one less than this value.

    Methods

    Name Description
    Get(int)

    Gets the cache's basis raised to the power of the given exponent value.

    GetCache(int, int)

    If there is an existing cache for the given basis then get it and increase its maximum size to meet the specified required max size, otherwise create a new cache with the given parameters.

    © Singulink. All rights reserved.