DGtal 1.3.0
Loading...
Searching...
No Matches
DiscreteExteriorCalculus.h
1
17#pragma once
18
31#if defined(DiscreteExteriorCalculus_RECURSES)
32#error Recursive header files inclusion detected in DiscreteExteriorCalculus.h
33#else // defined(DiscreteExteriorCalculus_RECURSES)
35#define DiscreteExteriorCalculus_RECURSES
36
37#if !defined DiscreteExteriorCalculus_h
39#define DiscreteExteriorCalculus_h
40
42// Inclusions
43#include <iostream>
44#include <vector>
45#include <map>
46#include <list>
47#include <boost/array.hpp>
48#include <boost/unordered_map.hpp>
49#include "DGtal/kernel/SpaceND.h"
50#include "DGtal/kernel/domains/HyperRectDomain.h"
51#include "DGtal/base/Common.h"
52#include "DGtal/topology/KhalimskySpaceND.h"
53#include "DGtal/dec/Duality.h"
54#include "DGtal/dec/KForm.h"
55#include "DGtal/dec/LinearOperator.h"
56#include "DGtal/dec/VectorField.h"
57#include "DGtal/base/ConstAlias.h"
58#include "DGtal/topology/CanonicSCellEmbedder.h"
59
60#include <DGtal/kernel/sets/CDigitalSet.h>
61#include <DGtal/math/linalg/CDynamicMatrix.h>
62#include <DGtal/math/linalg/CDynamicVector.h>
63#include <DGtal/math/linalg/CLinearAlgebra.h>
65
66namespace DGtal
67{
68 // forward factory declaration
69 template <typename TLinearAlgebraBackend, typename TInteger>
70 class DiscreteExteriorCalculusFactory;
71
77 template <Dimension dim, typename TInteger>
78 size_t
80
82 // template class DiscreteExteriorCalculus
96 template <Dimension dimEmbedded, Dimension dimAmbient, typename TLinearAlgebraBackend, typename TInteger = DGtal::int32_t>
98 {
99 // ----------------------- Standard services ------------------------------
100 public:
101
102 friend class DiscreteExteriorCalculusFactory<TLinearAlgebraBackend, TInteger>;
103
105
106 typedef TLinearAlgebraBackend LinearAlgebraBackend;
107 typedef typename LinearAlgebraBackend::DenseVector::Index Index;
108 typedef typename LinearAlgebraBackend::DenseVector::Scalar Scalar;
109 typedef typename LinearAlgebraBackend::DenseVector DenseVector;
110 typedef typename LinearAlgebraBackend::DenseMatrix DenseMatrix;
111 typedef typename LinearAlgebraBackend::SparseMatrix SparseMatrix;
112
114
120
121 BOOST_STATIC_ASSERT(( boost::is_same<Dimension, Order>::value ));
122
126 BOOST_STATIC_ASSERT(( dimAmbient >= dimEmbedded ));
127
128 BOOST_STATIC_CONSTANT( Dimension, dimensionEmbedded = dimEmbedded );
129 BOOST_STATIC_CONSTANT( Dimension, dimensionAmbient = dimAmbient );
130
132 typedef typename KSpace::Cell Cell;
133 typedef typename KSpace::SCell SCell;
134 typedef typename KSpace::Point Point;
135
152 struct Property
153 {
158 };
159
163 typedef boost::unordered_map<Cell, Property> Properties;
164
168 typedef std::vector<SCell> SCells;
169 typedef boost::array<SCells, dimEmbedded+1> IndexedSCells;
170
176
188
198
208
212 typedef LinearOperator<Self, 0, PRIMAL, dimEmbedded-0, DUAL> PrimalHodge0;
213 typedef LinearOperator<Self, 1, PRIMAL, dimEmbedded-1, DUAL> PrimalHodge1;
214 typedef LinearOperator<Self, 2, PRIMAL, dimEmbedded-2, DUAL> PrimalHodge2;
215 typedef LinearOperator<Self, 3, PRIMAL, dimEmbedded-3, DUAL> PrimalHodge3;
216 typedef LinearOperator<Self, 0, DUAL, dimEmbedded-0, PRIMAL> DualHodge0;
217 typedef LinearOperator<Self, 1, DUAL, dimEmbedded-1, PRIMAL> DualHodge1;
218 typedef LinearOperator<Self, 2, DUAL, dimEmbedded-2, PRIMAL> DualHodge2;
219 typedef LinearOperator<Self, 3, DUAL, dimEmbedded-3, PRIMAL> DualHodge3;
220
232
238
244 template <typename TDomain>
245 void
247
248 // ----------------------- Iterators on property map -----------------------
249
253 typedef typename Properties::const_iterator ConstIterator;
254
259
264
268 typedef typename Properties::iterator Iterator;
269
274
279
280 // ----------------------- Interface --------------------------------------
281 public:
282
287
292 void selfDisplay(std::ostream& out) const;
293
297 std::string className() const;
298
306 bool
307 insertSCell(const SCell& signed_cell);
308
318 bool
319 insertSCell(const SCell& signed_cell, const Scalar& primal_size, const Scalar& dual_size);
320
327 bool
328 eraseCell(const Cell& cell);
329
334 void
336
341 const Properties&
343
350 template <Order order, Duality duality>
351 const SCells&
353
362 template <Order order, Duality duality, typename TConstIterator>
364 reorder(const TConstIterator& begin_range, const TConstIterator& end_range) const;
365
372 template <Order order, Duality duality>
374 identity() const;
375
382 template <Order order, Duality duality>
384 derivative() const;
385
392 template <Order order, Duality duality>
393 LinearOperator<Self, order, duality, order-1, duality>
395
400 template <Duality duality>
402 laplace() const;
403
411 template <Duality duality>
413 heatLaplace(const typename DenseVector::Scalar& h, const typename DenseVector::Scalar& t, const typename DenseVector::Scalar& K) const;
414
421 template <Order order, Duality duality>
422 LinearOperator<Self, order, duality, dimEmbedded-order, OppositeDuality<duality>::duality>
423 hodge() const;
424
431 template <Duality duality>
433 flat(const VectorField<Self, duality>& vector_field) const;
434
442 template <Duality duality>
444 flatDirectional(const Dimension& dir) const;
445
452 template <Duality duality>
454 sharp(const KForm<Self, 1, duality>& one_form) const;
455
463 template <Duality duality>
465 sharpDirectional(const Dimension& dir) const;
466
474 SCell
475 getSCell(const Order& order, const Duality& duality, const Index& index) const;
476
481 bool
482 isCellFlipped(const Cell& cell) const;
483
488 bool
489 containsCell(const Cell& cell) const;
490
496 Index
497 getCellIndex(const Cell& cell) const;
498
504 Index
505 kFormLength(const Order& order, const Duality& duality) const;
506
514 Order
515 actualOrder(const Order& order, const Duality& duality) const;
516
523 Scalar
524 hodgeSign(const Cell& cell, const Duality& duality) const;
525
532 edgeDirection(const Cell& cell, const Duality& duality) const;
533
537 void
539
544 bool
545 isValid() const;
546
547 // ------------------------- Private Datas --------------------------------
548 private:
549
554
560
564 boost::array<boost::array<SparseMatrix, dimAmbient>, 2> myFlatOperatorMatrixes;
565
569 boost::array<boost::array<SparseMatrix, dimAmbient>, 2> mySharpOperatorMatrixes;
570
575
580
581
582 // ------------------------- Hidden services ------------------------------
583 protected:
584
585 // ------------------------- Internals ------------------------------------
586 private:
587
591 void
593
598 template <Duality duality>
599 void
601
606 template <Duality duality>
607 void
609
610 }; // end of class DiscreteExteriorCalculus
611
612
619 template <Dimension dimEmbedded, Dimension dimAmbient, typename TLinearAlgebraBackend, typename TInteger>
620 std::ostream&
622
623} // namespace DGtal
624
625
627// Includes inline functions.
628#include "DGtal/dec/DiscreteExteriorCalculus.ih"
629
630// //
632
633#endif // !defined DiscreteExteriorCalculus_h
634
635#undef DiscreteExteriorCalculus_RECURSES
636#endif // else defined(DiscreteExteriorCalculus_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: This class provides static members to create DEC structures from various other DGtal structures.
Aim: DiscreteExteriorCalculus represents a calculus in the dec package. This is the main structure in...
LinearOperator< Self, 2, DUAL, dimEmbedded-2, PRIMAL > DualHodge2
void selfDisplay(std::ostream &out) const
LinearOperator< Self, 0, PRIMAL, dimEmbedded-0, DUAL > PrimalHodge0
std::string className() const
const Properties & getProperties() const
Properties::const_iterator ConstIterator
KForm< Self, 1, duality > flat(const VectorField< Self, duality > &vector_field) const
LinearOperator< Self, 0, duality, 1, duality > flatDirectional(const Dimension &dir) const
ConstIterator begin() const
LinearAlgebraBackend::DenseMatrix DenseMatrix
BOOST_CONCEPT_ASSERT((concepts::CLinearAlgebra< DenseVector, DenseMatrix >))
BOOST_STATIC_CONSTANT(Dimension, dimensionAmbient=dimAmbient)
BOOST_CONCEPT_ASSERT((concepts::CDynamicMatrix< SparseMatrix >))
LinearOperator< Self, 3, PRIMAL, 2, PRIMAL > PrimalAntiderivative3
LinearOperator< Self, 1, duality, 0, duality > sharpDirectional(const Dimension &dir) const
LinearAlgebraBackend::DenseVector::Scalar Scalar
LinearOperator< Self, 1, DUAL, 2, DUAL > DualDerivative1
LinearOperator< Self, 3, PRIMAL, 3, PRIMAL > PrimalIdentity3
LinearOperator< Self, order, duality, dimEmbedded-order, OppositeDuality< duality >::duality > hodge() const
LinearOperator< Self, 3, DUAL, 3, DUAL > DualIdentity3
BOOST_STATIC_ASSERT((dimAmbient >=dimEmbedded))
LinearOperator< Self, 2, PRIMAL, 3, PRIMAL > PrimalDerivative2
LinearOperator< Self, 2, DUAL, 1, DUAL > DualAntiderivative2
DGtal::KhalimskySpaceND< dimAmbient, TInteger > KSpace
BOOST_STATIC_ASSERT((boost::is_same< Dimension, Order >::value))
LinearOperator< Self, 1, PRIMAL, 1, PRIMAL > PrimalIdentity1
Dimension edgeDirection(const Cell &cell, const Duality &duality) const
LinearOperator< Self, 0, duality, 0, duality > heatLaplace(const typename DenseVector::Scalar &h, const typename DenseVector::Scalar &t, const typename DenseVector::Scalar &K) const
void initKSpace(ConstAlias< TDomain > domain)
LinearOperator< Self, 0, PRIMAL, 0, PRIMAL > PrimalIdentity0
LinearOperator< Self, 3, DUAL, dimEmbedded-3, PRIMAL > DualHodge3
Index getCellIndex(const Cell &cell) const
LinearOperator< Self, 2, DUAL, 2, DUAL > DualIdentity2
SCell getSCell(const Order &order, const Duality &duality, const Index &index) const
BOOST_STATIC_CONSTANT(Dimension, dimensionEmbedded=dimEmbedded)
LinearOperator< Self, order, duality, order-1, duality > antiderivative() const
BOOST_CONCEPT_ASSERT((concepts::CInteger< TInteger >))
LinearOperator< Self, 2, PRIMAL, 1, PRIMAL > PrimalAntiderivative2
boost::array< SCells, dimEmbedded+1 > IndexedSCells
LinearOperator< Self, 1, PRIMAL, 0, PRIMAL > PrimalAntiderivative1
LinearAlgebraBackend::SparseMatrix SparseMatrix
LinearOperator< Self, 1, DUAL, dimEmbedded-1, PRIMAL > DualHodge1
Index kFormLength(const Order &order, const Duality &duality) const
bool eraseCell(const Cell &cell)
LinearAlgebraBackend::DenseVector DenseVector
bool insertSCell(const SCell &signed_cell)
boost::array< boost::array< SparseMatrix, dimAmbient >, 2 > mySharpOperatorMatrixes
DiscreteExteriorCalculus< dimEmbedded, dimAmbient, TLinearAlgebraBackend, TInteger > Self
bool isCellFlipped(const Cell &cell) const
LinearOperator< Self, 1, DUAL, 1, DUAL > DualIdentity1
LinearOperator< Self, 2, PRIMAL, 2, PRIMAL > PrimalIdentity2
LinearOperator< Self, 1, PRIMAL, dimEmbedded-1, DUAL > PrimalHodge1
BOOST_CONCEPT_ASSERT((concepts::CDynamicVector< DenseVector >))
LinearOperator< Self, order, duality, order, duality > identity() const
LinearAlgebraBackend::DenseVector::Index Index
LinearOperator< Self, 1, DUAL, 0, DUAL > DualAntiderivative1
LinearOperator< Self, order, duality, order+1, duality > derivative() const
boost::unordered_map< Cell, Property > Properties
LinearOperator< Self, 0, DUAL, dimEmbedded-0, PRIMAL > DualHodge0
LinearOperator< Self, 3, PRIMAL, dimEmbedded-3, DUAL > PrimalHodge3
LinearOperator< Self, 2, PRIMAL, dimEmbedded-2, DUAL > PrimalHodge2
VectorField< Self, DUAL > DualVectorField
LinearOperator< Self, 2, DUAL, 3, DUAL > DualDerivative2
Scalar hodgeSign(const Cell &cell, const Duality &duality) const
LinearOperator< Self, 0, DUAL, 0, DUAL > DualIdentity0
bool insertSCell(const SCell &signed_cell, const Scalar &primal_size, const Scalar &dual_size)
const SCells & getIndexedSCells() const
LinearOperator< Self, order, duality, order, duality > reorder(const TConstIterator &begin_range, const TConstIterator &end_range) const
BOOST_CONCEPT_ASSERT((concepts::CDynamicMatrix< DenseMatrix >))
Order actualOrder(const Order &order, const Duality &duality) const
LinearOperator< Self, 3, DUAL, 2, DUAL > DualAntiderivative3
LinearOperator< Self, 0, PRIMAL, 1, PRIMAL > PrimalDerivative0
VectorField< Self, duality > sharp(const KForm< Self, 1, duality > &one_form) const
LinearOperator< Self, 0, duality, 0, duality > laplace() const
boost::array< boost::array< SparseMatrix, dimAmbient >, 2 > myFlatOperatorMatrixes
LinearOperator< Self, 1, PRIMAL, 2, PRIMAL > PrimalDerivative1
ConstIterator end() const
LinearOperator< Self, 0, DUAL, 1, DUAL > DualDerivative0
BOOST_CONCEPT_ASSERT((concepts::CLinearAlgebra< DenseVector, SparseMatrix >))
bool containsCell(const Cell &cell) const
VectorField< Self, PRIMAL > PrimalVectorField
Aim: KForm represents discrete kforms in the dec package.
Definition: KForm.h:66
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: LinearOperator represents discrete linear operator between discrete kforms in the DEC package.
Aim: VectorField represents a discrete vector field in the dec package. Vector field values are attac...
Definition: VectorField.h:68
DGtal is the top-level namespace which contains all DGtal functions and types.
unsigned int Order
Aim: Order is used as template parameter for DEC classes.
Definition: Duality.h:89
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
size_t hash_value(const KhalimskyCell< dim, TInteger > &cell)
DGtal::uint32_t Dimension
Definition: Common.h:137
Duality
Aim: Duality enumerator tells if templated object lives in primal or dual space. Used as template par...
Definition: Duality.h:60
@ PRIMAL
Definition: Duality.h:61
@ DUAL
Definition: Duality.h:62
Holds size 'primal_size', 'dual_size', 'index' and 'flipped' for each cell of the DEC object....
Represents an (unsigned) cell in a cellular grid space by its Khalimsky coordinates.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: Represent any dynamic sized matrix having sparse or dense representation.
Aim: Represent any dynamic sized column vector having sparse or dense representation.
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
Aim: Check right multiplication between matrix and vector and internal matrix multiplication....
KSpace K
Domain domain