added new test-cases added flexible dijkstra calculation added debugging log modified: plotting, grid-generation, grid-importance, refactoring
37 lines
621 B
C++
37 lines
621 B
C++
#ifndef MINIMAT2_H
|
|
#define MINIMAT2_H
|
|
|
|
/**
|
|
* very simple 2x2 matrix
|
|
*/
|
|
struct MiniMat2 {
|
|
|
|
/** store eigenvalues */
|
|
struct EV {float e1,e2;};
|
|
|
|
/** data */
|
|
float a,b,c,d;
|
|
|
|
/** ctor */
|
|
MiniMat2() : a(0), b(0), c(0), d(0) {;}
|
|
|
|
/** get the matrix' eigenvalues */
|
|
EV getEigenvalues() const {
|
|
const float T = a+d;
|
|
const float D = a*d - b*c;
|
|
EV res;
|
|
res.e1 = T/2 + std::sqrt(T*T/4-D);
|
|
res.e2 = T/2 - std::sqrt(T*T/4-D);
|
|
return res;
|
|
}
|
|
|
|
/** add (x,y) * (x,y)T to the matrix */
|
|
void addSquared(const float x, const float y) {
|
|
a += (x*x); b += (x*y);
|
|
c += (x*y); d += (y*y);
|
|
}
|
|
|
|
};
|
|
|
|
#endif // MINIMAT2_H
|