KrisLibrary  1.0.0
d/LinearlyDependent.h
1 #ifndef MATH3D_LINEARLY_DEPENDENT_H
2 #define MATH3D_LINEARLY_DEPENDENT_H
3 
4 #include "primitives.h"
5 
6 namespace Math3D {
7 
8 //Robust determination of linear dependence.
9 //Return true if the vectors are dependent.
10 //Single-vector versions:
11 // Returns a constant c s.t. they're linearly dependent within rel error eps
12 // and |c| <= 1.
13 // 2 cases, (1) a*c = b with maxabs(a*c-b)/|a| <= eps.
14 // (2) a = c*b with maxabs(a-c*b)/|b| <= eps.
15 // in case 1, cb = false, in case 2, cb=true.
16 // c is chosen by pseudoinverse
17 //Matrix versions:
18 // Returns a vector c s.t. A*c = 0. All coefficients |ci| <= 1
19 // At least one ci = 1.
20 
21 bool LinearlyDependent_Robust(const Vector2& a, const Vector2& b, Real& c, bool& cb, Real eps = Epsilon);
22 bool LinearlyDependent_Robust(const Vector3& a, const Vector3& b, Real& c, bool& cb, Real eps = Epsilon);
23 bool LinearlyDependent_Robust(const Vector4& a, const Vector4& b, Real& c, bool& cb, Real eps = Epsilon);
24 
25 }
26 
27 #endif
Class declarations for useful 3D math types.
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:12
bool LinearlyDependent_Robust(const VectorTemplate< T > &a, const VectorTemplate< T > &b, T &c, bool &cb, T eps)
Robust determination of linear dependence.
Definition: LinearlyDependent.cpp:6