Allow enabling sqrt optimizations while computing

This commit is contained in:
ItsDrike 2025-02-26 16:21:52 +01:00
parent d54c6743e7
commit c62f027656
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
2 changed files with 15 additions and 3 deletions

View file

@ -58,7 +58,17 @@ void FactorizationController::setUseSqrtOptimization(bool value) {
m_useSqrtOptimization = value;
emit useSqrtOptimizationChanged();
reset();
// We're in a reset state
if (m_originalNumber == 0)
return;
if (m_useSqrtOptimization)
m_stopFactor = static_cast<unsigned long long>(std::sqrt(m_currentFactNumber));
else
m_stopFactor = m_currentFactNumber - 1;
emit stopFactorChanged();
emit progressChanged();
}
bool FactorizationController::pauseOnFound() const {

View file

@ -167,8 +167,10 @@ class FactorizationController : public QObject {
* Generally, there's no reason to disable this optimization, however, if you wish to
* perform a slower search, it is a way to achieve that.
*
* Note that changing this value while the computation is in progress will reset the
* computation.
* This value can be changed even as a computation is ongoing; if you do so, the stop factor
* will change immediately, which will very likely cause the progress bar to rapidly change.
* It is possible that after enabling, the computation will immediately finish, as the stop
* factor will be less than the sqrt(x).
*/
void setUseSqrtOptimization(bool value);