Changeset 1055


Ignore:
Timestamp:
12/27/20 19:39:44 (4 years ago)
Author:
Maciej Komosinski
Message:

Added a workaround (potentially incorrect) for numerical instability in SVD calculation and the embarcadero compiler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/similarity/SVD/lapack.cpp

    r389 r1055  
    5959#include <stdint.h> //uint8_t
    6060#include "lapack.h"
     61#include <common/log.h>
    6162
    6263
     
    296297                        else
    297298                        {
    298                                 c = (_Tp)std::sqrt((gamma + beta) / (gamma * 2));
    299                                 s = (_Tp)(p / (gamma * c * 2));
     299                                if (gamma == 0) //MK 2020-12: workaround for embarcadero compiler
     300                                {
     301#ifndef __BORLANDC__ //It happens so often in embarcadero-produced executables that don't even bother the user with messages. Visual c++ and gcc/clang do not experience this problem.
     302                                        logPrintf("Lapack", "JacobiSVD", LOG_ERROR, "Numerical instability in JacobiSVDImpl_(), likely 0.0/0.0, specific to floating point handling by this particular compiler. p=%.17g, gamma=%.17g, beta=%.17g. Recovering with bogus results.", p, gamma, beta);
     303#endif
     304                                        c = s = 0;
     305                                }
     306                                else
     307                                {
     308                                        c = (_Tp)std::sqrt((gamma + beta) / (gamma * 2));
     309                                        s = (_Tp)(p / (gamma * c * 2));
     310                                }
    300311                        }
    301312
Note: See TracChangeset for help on using the changeset viewer.