Changeset 8600


Ignore:
Timestamp:
Feb 7, 2020, 11:18:24 PM (2 years ago)
Author:
Sven Rech
Message:

Primes tutorial:

  • Optimized calculation for "number of primes" graph
  • Fixed problem with "number of prime heuristic" graphs being cut off
Location:
trunk/CrypPlugins/Primes/Primes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/Primes/Primes/Library/Function/FunctionPiX.cs

    r8109 r8600  
    5858        private long m_Counter = 0;
    5959
     60        private (long input, long output) lastCalc;
     61
    6062        public double Execute(double input)
    6163        {
     
    8991
    9092            if (PrimesBigInteger.ValueOf(m_LastNumber).IsPrime(10)) m_LastNumber++;
     93
     94            if (m_LastNumber < lastCalc.input && value > lastCalc.input)
     95            {
     96                //Reuse result of last calculation:
     97                m_LastNumber = lastCalc.input + 1;
     98                m_Counter = lastCalc.output;
     99            }
     100
    91101            while (m_LastNumber < value)
    92102            {
     
    106116            if (Executed != null) Executed(m_Counter);
    107117
     118            lastCalc = (value, m_Counter);
    108119            return m_Counter;
    109120        }
  • trunk/CrypPlugins/Primes/Primes/WpfControls/Threads/FunctionThread.cs

    r8109 r8600  
    7171
    7272                    PrimesBigInteger i = m_From;
    73                     while (i.CompareTo(fe.Range.To) <= 0 && !HasTerminateRequest())
     73                    while (i.CompareTo(fe.Range.To + inci - 1) <= 0 && !HasTerminateRequest())
    7474                    //for (long i = m_From; i <= fe.Range.To * factor || !HasTerminateRequest(); i += inci)
    7575                    {
Note: See TracChangeset for help on using the changeset viewer.