mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 00:50:37 +08:00
Unify symbol visibility configuration for all compilers
This makes it possible to build unit tests with shared libraries on MSVC. Change-Id: I1db66a80b2c78c4f3d354e35235244d17bac9809
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#define CERES_INTERNAL_NUMERIC_DIFF_TEST_UTILS_H_
|
||||
|
||||
#include "ceres/cost_function.h"
|
||||
#include "ceres/internal/port.h"
|
||||
#include "ceres/sized_cost_function.h"
|
||||
#include "ceres/types.h"
|
||||
|
||||
@@ -47,7 +48,7 @@ static constexpr unsigned int kRandomSeed = 1234;
|
||||
// y1 = x1'x2 -> dy1/dx1 = x2, dy1/dx2 = x1
|
||||
// y2 = (x1'x2)^2 -> dy2/dx1 = 2 * x2 * (x1'x2), dy2/dx2 = 2 * x1 * (x1'x2)
|
||||
// y3 = x2'x2 -> dy3/dx1 = 0, dy3/dx2 = 2 * x2
|
||||
class EasyFunctor {
|
||||
class CERES_EXPORT_INTERNAL EasyFunctor {
|
||||
public:
|
||||
bool operator()(const double* x1, const double* x2, double* residuals) const;
|
||||
void ExpectCostFunctionEvaluationIsNearlyCorrect(
|
||||
@@ -71,14 +72,15 @@ class EasyCostFunction : public SizedCostFunction<3, 5, 5> {
|
||||
//
|
||||
// dy1/dx1 = x2 * cos(x1'x2), dy1/dx2 = x1 * cos(x1'x2)
|
||||
// dy2/dx1 = -x2 * exp(-x1'x2 / 10) / 10, dy2/dx2 = -x2 * exp(-x1'x2 / 10) / 10
|
||||
class TranscendentalFunctor {
|
||||
class CERES_EXPORT TranscendentalFunctor {
|
||||
public:
|
||||
bool operator()(const double* x1, const double* x2, double* residuals) const;
|
||||
void ExpectCostFunctionEvaluationIsNearlyCorrect(
|
||||
const CostFunction& cost_function, NumericDiffMethodType method) const;
|
||||
};
|
||||
|
||||
class TranscendentalCostFunction : public SizedCostFunction<2, 5, 5> {
|
||||
class CERES_EXPORT_INTERNAL TranscendentalCostFunction
|
||||
: public SizedCostFunction<2, 5, 5> {
|
||||
public:
|
||||
bool Evaluate(double const* const* parameters,
|
||||
double* residuals,
|
||||
@@ -91,7 +93,7 @@ class TranscendentalCostFunction : public SizedCostFunction<2, 5, 5> {
|
||||
};
|
||||
|
||||
// y = exp(x), dy/dx = exp(x)
|
||||
class ExponentialFunctor {
|
||||
class CERES_EXPORT_INTERNAL ExponentialFunctor {
|
||||
public:
|
||||
bool operator()(const double* x1, double* residuals) const;
|
||||
void ExpectCostFunctionEvaluationIsNearlyCorrect(
|
||||
@@ -113,7 +115,7 @@ class ExponentialCostFunction : public SizedCostFunction<1, 1> {
|
||||
// Test adaptive numeric differentiation by synthetically adding random noise
|
||||
// to a functor.
|
||||
// y = x^2 + [random noise], dy/dx ~ 2x
|
||||
class RandomizedFunctor {
|
||||
class CERES_EXPORT_INTERNAL RandomizedFunctor {
|
||||
public:
|
||||
RandomizedFunctor(double noise_factor, unsigned int random_seed)
|
||||
: noise_factor_(noise_factor), random_seed_(random_seed) {}
|
||||
@@ -127,7 +129,8 @@ class RandomizedFunctor {
|
||||
unsigned int random_seed_;
|
||||
};
|
||||
|
||||
class RandomizedCostFunction : public SizedCostFunction<1, 1> {
|
||||
class CERES_EXPORT_INTERNAL RandomizedCostFunction
|
||||
: public SizedCostFunction<1, 1> {
|
||||
public:
|
||||
RandomizedCostFunction(double noise_factor, unsigned int random_seed)
|
||||
: functor_(noise_factor, random_seed) {}
|
||||
|
||||
Reference in New Issue
Block a user