28 #include "DGtal/math/linalg/EigenSupport.h"
29 #include <Eigen/Eigenvalues>
31 #include "DGtal/dec/DiscreteExteriorCalculus.h"
32 #include "DGtal/dec/DiscreteExteriorCalculusSolver.h"
34 #include "DGtal/base/Common.h"
35 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/io/boards/Board2D.h"
37 #include "DGtal/math/linalg/EigenSupport.h"
38 #include "DGtal/dec/DiscreteExteriorCalculus.h"
39 #include "DGtal/dec/DiscreteExteriorCalculusSolver.h"
42 using namespace DGtal;
43 using namespace Eigen;
45 double standard_deviation(
const VectorXd& xx)
47 const double mean = xx.mean();
49 for (
int kk=0, kk_max=xx.rows(); kk<kk_max; kk++)
50 accum += (xx(kk)-mean)*(xx(kk)-mean);
51 return sqrt(accum)/(xx.size()-1);
66 for (
int kk=2; kk<=20; kk++)
71 for (
int kk=3; kk<=20; kk++)
74 for (
int kk=3; kk<20; kk++)
75 for (
int ll=3; ll<20; ll++)
77 if (kk==11 && ll==11)
continue;
88 const Calculus::DualIdentity0 laplace =
calculus.laplace<
DUAL>();
89 trace.
info() <<
"laplace=" << laplace << endl;
95 board.
saveSVG(
"chladni_calculus.svg");
102 typedef SelfAdjointEigenSolver<MatrixXd> EigenSolverMatrix;
103 const EigenSolverMatrix eigen_solver(laplace.myContainer);
105 const VectorXd eigen_values = eigen_solver.eigenvalues();
106 const MatrixXd eigen_vectors = eigen_solver.eigenvectors();
107 for (
int kk=0; kk<laplace.myContainer.rows(); kk++)
109 Calculus::Scalar eigen_value = eigen_values(kk, 0);
111 const VectorXd eigen_vector = eigen_vectors.col(kk);
112 const Calculus::DualForm0 eigen_form = Calculus::DualForm0(
calculus, eigen_vector);
113 std::stringstream ss;
114 ss <<
"chladni_eigen_" << kk <<
".svg";
115 const std::string filename = ss.str();
116 ss <<
"chladni_eigen_vector_" << kk <<
".svg";
117 trace.
info() << kk <<
" " << eigen_value <<
" " << sqrt(eigen_value) <<
" " << eigen_vector.minCoeff() <<
" " << eigen_vector.maxCoeff() <<
" " << standard_deviation(eigen_vector) << endl;
122 board <<
CustomStyle(
"KForm",
new KFormStyle2D(eigen_vectors.minCoeff(),eigen_vectors.maxCoeff()));
124 board.
saveSVG(filename.c_str());
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: DiscreteExteriorCalculus represents a calculus in the dec package. This is the main structure in...
void beginBlock(const std::string &keyword="")
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)