1 #ifndef math_methods_H__
2 #define math_methods_H__
57 template<
class Data,
class WeightingClass>
58 inline std::vector<Data>
ransac(std::vector<Data>
const& data,
59 WeightingClass
const& w,
61 double p0,
double P) {
62 if (data.size() < N) {
63 return std::vector<Data>();
66 std::vector<Data> ret;
67 for (
double count = ceil(log(1.0 - P) / log(1.0 - pow(p0, N)));
68 count > 0.0; count -= 1.0) {
69 std::vector<Data> sample;
70 std::vector<int> index(N);
71 for (
size_t i = 0; i < N; i++) {
72 for (
bool ok =
false; !ok; ) {
73 index[i] = rand() % data.size();
75 for (
size_t j = 0; ok && j < i; j++)
76 if (index[i] == index[j])
79 sample.push_back(data[index[i]]);
81 double w_now = w(sample, data);
162 template<
class Scalar,
class F,
class J,
class I,
class Stop>
171 !stop((rv = func(ans)).length2()) && counter != 0; counter--) {
174 ans = ans -
Vector<Scalar>((jt * j + i).inverse() * jt * rv.matrix());
181 #endif // math_methods_H__