457 Calculus primal_calculus;
462 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(2,2)) );
463 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(4,2)) );
464 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(2,4)) );
465 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(4,4)) );
466 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(2,6)) );
467 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(4,6)) );
469 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(1,2)) );
472 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(3,2), Calculus::KSpace::NEG) );
473 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(3,2), Calculus::KSpace::POS) );
474 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(2,3), Calculus::KSpace::NEG) );
475 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(4,3), Calculus::KSpace::POS) );
476 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(3,4), Calculus::KSpace::NEG) );
477 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(2,5), Calculus::KSpace::POS) );
478 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(4,5), Calculus::KSpace::NEG) );
479 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(3,6), Calculus::KSpace::POS) );
481 primal_calculus.eraseCell( primal_calculus.myKSpace.uCell(
Point(1,2)) );
484 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(3,3)) );
485 primal_calculus.insertSCell( primal_calculus.myKSpace.sCell(
Point(3,5)) );
487 primal_calculus.updateIndexes();
491 for (
Calculus::ConstIterator iter_property=primal_calculus.begin(), iter_property_end=primal_calculus.end(); iter_property!=iter_property_end; iter_property++)
494 const Calculus::Property
property = iter_property->second;
495 const Dimension dim = primal_calculus.myKSpace.uDim(cell);
496 const Calculus::SCell signed_cell = primal_calculus.myKSpace.signs(cell, property.flipped ? Calculus::KSpace::NEG : Calculus::KSpace::POS);
498 ASSERT( signed_cell == primal_calculus.getSCell(
dim, PRIMAL, property.index) );
502 <<
" " << signed_cell
503 <<
" " <<
property.primal_size
504 <<
" " <<
property.dual_size
505 <<
" " <<
property.index
506 <<
" " << (
property.flipped ?
"negative" :
"positive")
513 Calculus dual_calculus;
518 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(7,3)) );
519 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(9,3)) );
520 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(7,5)) );
521 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(9,5)) );
522 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(7,7)) );
523 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(9,7)) );
525 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(6,3)) );
528 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(8,3), Calculus::KSpace::NEG) );
529 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(8,3), Calculus::KSpace::POS) );
530 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(7,4), Calculus::KSpace::POS) );
531 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(9,4), Calculus::KSpace::NEG) );
532 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(8,5), Calculus::KSpace::NEG) );
533 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(7,6), Calculus::KSpace::NEG) );
534 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(9,6), Calculus::KSpace::POS) );
535 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(8,7), Calculus::KSpace::POS) );
537 dual_calculus.eraseCell( dual_calculus.myKSpace.uCell(
Point(6,3)) );
540 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(8,4)) );
541 dual_calculus.insertSCell( dual_calculus.myKSpace.sCell(
Point(8,6)) );
543 dual_calculus.updateIndexes();
547 for (
Calculus::ConstIterator iter_property=dual_calculus.begin(), iter_property_end=dual_calculus.end(); iter_property!=iter_property_end; iter_property++)
550 const Calculus::Property
property = iter_property->second;
551 const Dimension dim = dual_calculus.myKSpace.uDim(cell);
552 const Calculus::SCell signed_cell = dual_calculus.myKSpace.signs(cell, property.flipped ? Calculus::KSpace::NEG : Calculus::KSpace::POS);
554 ASSERT( signed_cell == dual_calculus.getSCell(
dim, PRIMAL, property.index) );
558 <<
" " << signed_cell
559 <<
" " <<
property.primal_size
560 <<
" " <<
property.dual_size
561 <<
" " <<
property.index
562 <<
" " << (
property.flipped ?
"negative" :
"positive")
571 board << primal_calculus;
572 board << dual_calculus;
573 board.
saveSVG(
"operators_structure.svg");
578 const Calculus::PrimalDerivative0 primal_d0 = primal_calculus.derivative<0,
PRIMAL>();
579 const Calculus::DualDerivative0 dual_d0p = dual_calculus.derivative<0,
DUAL>();
584 #if defined(TEST_HARDCODED_ORDER)
585 Eigen::MatrixXd d0_th(7, 6);
594 FATAL_ERROR( Eigen::MatrixXd(primal_d0.myContainer) == d0_th );
596 Eigen::MatrixXd d0p_th(7, 6);
605 FATAL_ERROR( Eigen::MatrixXd(dual_d0p.myContainer) == d0p_th );
609 const Calculus::PrimalDerivative1 primal_d1 = primal_calculus.derivative<1,
PRIMAL>();
610 const Calculus::DualDerivative1 dual_d1p = dual_calculus.derivative<1,
DUAL>();
615 #if defined(TEST_HARDCODED_ORDER)
616 Eigen::MatrixXd d1_th(2, 7);
619 0, 0, -1, -1, 0, -1, -1;
620 FATAL_ERROR( Eigen::MatrixXd(primal_d1.myContainer) == d1_th );
622 Eigen::MatrixXd d1p_th(2, 7);
624 -1, -1, -1, 0, 0, -1, 0,
626 FATAL_ERROR( Eigen::MatrixXd(dual_d1p.myContainer) == d1p_th );
634 FATAL_ERROR( Eigen::MatrixXd((primal_d1*primal_d0).myContainer) == Eigen::MatrixXd::Zero(2,6) );
635 FATAL_ERROR( Eigen::MatrixXd((dual_d1p*dual_d0p).myContainer) == Eigen::MatrixXd::Zero(2,6) );
638 const Calculus::PrimalHodge0 primal_h0 = primal_calculus.hodge<0,
PRIMAL>();
639 const Calculus::DualHodge0 dual_h0p = dual_calculus.hodge<0,
DUAL>();
640 const Calculus::DualHodge2 primal_h2p = primal_calculus.hodge<2,
DUAL>();
641 const Calculus::PrimalHodge2 dual_h2 = dual_calculus.hodge<2,
PRIMAL>();
648 FATAL_ERROR( Eigen::MatrixXd(primal_h0.myContainer) == Eigen::MatrixXd::Identity(6,6) );
649 FATAL_ERROR( Eigen::MatrixXd(dual_h0p.myContainer) == Eigen::MatrixXd::Identity(6,6) );
650 FATAL_ERROR( Eigen::MatrixXd(primal_h2p.myContainer) == Eigen::MatrixXd::Identity(6,6) );
651 FATAL_ERROR( Eigen::MatrixXd(dual_h2.myContainer) == Eigen::MatrixXd::Identity(6,6) );
654 const Calculus::PrimalHodge2 primal_h2 = primal_calculus.hodge<2,
PRIMAL>();
655 const Calculus::DualHodge2 dual_h2p = dual_calculus.hodge<2,
DUAL>();
656 const Calculus::DualHodge0 primal_h0p = primal_calculus.hodge<0,
DUAL>();
657 const Calculus::PrimalHodge0 dual_h0 = dual_calculus.hodge<0,
PRIMAL>();
664 FATAL_ERROR( Eigen::MatrixXd(primal_h2.myContainer) == Eigen::MatrixXd::Identity(2,2) );
665 FATAL_ERROR( Eigen::MatrixXd(dual_h2p.myContainer) == Eigen::MatrixXd::Identity(2,2) );
666 FATAL_ERROR( Eigen::MatrixXd(primal_h0p.myContainer) == Eigen::MatrixXd::Identity(2,2) );
667 FATAL_ERROR( Eigen::MatrixXd(dual_h0.myContainer) == Eigen::MatrixXd::Identity(2,2) );
670 const Calculus::DualDerivative0 primal_d0p = primal_calculus.derivative<0,
DUAL>();
671 const Calculus::PrimalDerivative0 dual_d0 = dual_calculus.derivative<0,
PRIMAL>();
676 #if defined(TEST_HARDCODED_ORDER)
677 Eigen::MatrixXd d0p_th_transpose(2, 7);
680 0, 0, -1, -1, 0, -1, -1;
681 FATAL_ERROR( Eigen::MatrixXd(primal_d0p.myContainer) == d0p_th_transpose.transpose() );
683 Eigen::MatrixXd minus_d0_th_transpose(2, 7);
684 minus_d0_th_transpose <<
685 -1, -1, -1, 0, 0, -1, 0,
687 FATAL_ERROR( Eigen::MatrixXd(dual_d0.myContainer) == -minus_d0_th_transpose.transpose() );
691 const Calculus::DualDerivative1 primal_d1p = primal_calculus.derivative<1,
DUAL>();
692 const Calculus::PrimalDerivative1 dual_d1 = dual_calculus.derivative<1,
PRIMAL>();
697 #if defined(TEST_HARDCODED_ORDER)
698 Eigen::MatrixXd minus_d1p_th_transpose(7, 6);
699 minus_d1p_th_transpose <<
707 FATAL_ERROR( Eigen::MatrixXd(primal_d1p.myContainer) == -minus_d1p_th_transpose.transpose() );
709 Eigen::MatrixXd d1_th_transpose(7, 6);
718 FATAL_ERROR( Eigen::MatrixXd(dual_d1.myContainer) == d1_th_transpose.transpose() );
722 const Calculus::PrimalHodge1 primal_h1 = primal_calculus.hodge<1,
PRIMAL>();
723 const Calculus::DualHodge1 dual_h1p = dual_calculus.hodge<1,
DUAL>();
724 const Calculus::DualHodge1 primal_h1p = primal_calculus.hodge<1,
DUAL>();
725 const Calculus::PrimalHodge1 dual_h1 = dual_calculus.hodge<1,
PRIMAL>();
732 FATAL_ERROR( Eigen::MatrixXd(primal_h1.myContainer) == Eigen::MatrixXd::Identity(7,7) );
733 FATAL_ERROR( Eigen::MatrixXd(dual_h1p.myContainer) == -Eigen::MatrixXd::Identity(7,7) );
734 FATAL_ERROR( Eigen::MatrixXd((primal_h1p*primal_h1).myContainer) == -Eigen::MatrixXd::Identity(7,7) );
735 FATAL_ERROR( Eigen::MatrixXd((dual_h1*dual_h1p).myContainer) == -Eigen::MatrixXd::Identity(7,7) );
736 FATAL_ERROR( Eigen::MatrixXd((primal_h1*primal_h1p).myContainer) == -Eigen::MatrixXd::Identity(7,7) );
737 FATAL_ERROR( Eigen::MatrixXd((dual_h1p*dual_h1).myContainer) == -Eigen::MatrixXd::Identity(7,7) );
758 Calculus::PrimalForm1::Container dx_container(7);
759 dx_container << -1, 0, 0, -1, 0, 1, 0;
760 const Calculus::PrimalForm1 primal_dx(primal_calculus, dx_container);
761 const Calculus::PrimalVectorField primal_dx_field = primal_calculus.sharp(primal_dx);
763 Calculus::PrimalForm1::Container dxp_container(7);
764 dxp_container << 1, -1, 0, 0, 1, 0, 0;
765 const Calculus::DualForm1 dual_dx(dual_calculus, dxp_container);
766 const Calculus::DualVectorField dual_dx_field = dual_calculus.sharp(dual_dx);
771 board << primal_calculus;
772 board << primal_dx << primal_dx_field;
773 board << dual_calculus;
774 board << dual_dx << dual_dx_field;
775 board.
saveSVG(
"operators_sharp_dx_primal.svg");
778 #if defined(TEST_HARDCODED_ORDER)
779 FATAL_ERROR( primal_dx_field.myCoordinates.col(0) == Eigen::VectorXd::Ones(6) );
780 FATAL_ERROR( primal_dx_field.myCoordinates.col(1) == Eigen::VectorXd::Zero(6) );
781 FATAL_ERROR( dual_dx_field.myCoordinates.col(0) == Eigen::VectorXd::Ones(6) );
782 FATAL_ERROR( dual_dx_field.myCoordinates.col(1) == Eigen::VectorXd::Zero(6) );
787 Calculus::PrimalForm1::Container dy_container(7);
788 dy_container << 0, 1, 1, 0, -1, 0, -1;
789 const Calculus::PrimalForm1 primal_dy(primal_calculus, dy_container);
790 const Calculus::PrimalVectorField primal_dy_field = primal_calculus.sharp(primal_dy);
792 Calculus::PrimalForm1::Container dyp_container(7);
793 dyp_container << 0, 0, 1, 1, 0, -1, -1;
794 const Calculus::DualForm1 dual_dy(dual_calculus, dyp_container);
795 const Calculus::DualVectorField dual_dy_field = dual_calculus.sharp(dual_dy);
800 board << primal_calculus;
801 board << primal_dy << primal_dy_field;
802 board << dual_calculus;
803 board << dual_dy << dual_dy_field;
804 board.
saveSVG(
"operators_sharp_dy_primal.svg");
807 #if defined(TEST_HARDCODED_ORDER)
808 FATAL_ERROR( primal_dy_field.myCoordinates.col(0) == Eigen::VectorXd::Zero(6) );
809 FATAL_ERROR( primal_dy_field.myCoordinates.col(1) == Eigen::VectorXd::Ones(6) );
810 FATAL_ERROR( dual_dy_field.myCoordinates.col(0) == Eigen::VectorXd::Zero(6) );
811 FATAL_ERROR( dual_dy_field.myCoordinates.col(1) == Eigen::VectorXd::Ones(6) );
823 Calculus::DualForm1::Container dx_container(7);
824 dx_container << 0, -1, -1, 0, 1, 0, 1;
825 const Calculus::DualForm1 primal_dx(primal_calculus, dx_container);
826 const Calculus::DualVectorField primal_dx_field = primal_calculus.sharp(primal_dx);
828 Calculus::DualForm1::Container dxp_container(7);
829 dxp_container << 0, 0, 1, 1, 0, -1, -1;
830 const Calculus::PrimalForm1 dual_dx(dual_calculus, dxp_container);
831 const Calculus::PrimalVectorField dual_dx_field = dual_calculus.sharp(dual_dx);
836 board << primal_calculus;
837 board << primal_dx << primal_dx_field;
838 board << dual_calculus;
839 board << dual_dx << dual_dx_field;
840 board.
saveSVG(
"operators_sharp_dx_dual.svg");
843 #if defined(TEST_HARDCODED_ORDER)
844 FATAL_ERROR( primal_dx_field.myCoordinates.col(0) == Eigen::VectorXd::Ones(2) );
845 FATAL_ERROR( primal_dx_field.myCoordinates.col(1) == Eigen::VectorXd::Zero(2) );
846 FATAL_ERROR( dual_dx_field.myCoordinates.col(0) == Eigen::VectorXd::Ones(2) );
847 FATAL_ERROR( dual_dx_field.myCoordinates.col(1) == Eigen::VectorXd::Zero(2) );
852 Calculus::DualForm1::Container dy_container(7);
853 dy_container << -1, 0, 0, -1, 0 , 1, 0;
854 const Calculus::DualForm1 primal_dy(primal_calculus, dy_container);
855 const Calculus::DualVectorField primal_dy_field = primal_calculus.sharp(primal_dy);
857 Calculus::DualForm1::Container dyp_container(7);
858 dyp_container << -1, 1, 0, 0, -1, 0, 0;
859 const Calculus::PrimalForm1 dual_dy(dual_calculus, dyp_container);
860 const Calculus::PrimalVectorField dual_dy_field = dual_calculus.sharp(dual_dy);
865 board << primal_calculus;
866 board << primal_dy << primal_dy_field;
867 board << dual_calculus;
868 board << dual_dy << dual_dy_field;
869 board.
saveSVG(
"operators_sharp_dy_dual.svg");
872 #if defined(TEST_HARDCODED_ORDER)
873 FATAL_ERROR( primal_dy_field.myCoordinates.col(0) == Eigen::VectorXd::Zero(2) );
874 FATAL_ERROR( primal_dy_field.myCoordinates.col(1) == Eigen::VectorXd::Ones(2) );
875 FATAL_ERROR( dual_dy_field.myCoordinates.col(0) == Eigen::VectorXd::Zero(2) );
876 FATAL_ERROR( dual_dy_field.myCoordinates.col(1) == Eigen::VectorXd::Ones(2) );
891 Calculus::PrimalVectorField::Coordinates dx_coords(6,2);
892 dx_coords.col(0) = Eigen::VectorXd::Ones(6);
893 dx_coords.col(1) = Eigen::VectorXd::Zero(6);
895 Calculus::PrimalVectorField::Coordinates dy_coords(6,2);
896 dy_coords.col(0) = Eigen::VectorXd::Zero(6);
897 dy_coords.col(1) = Eigen::VectorXd::Ones(6);
899 const Calculus::PrimalVectorField primal_dx_field(primal_calculus, dx_coords);
900 const Calculus::PrimalForm1 primal_dx = primal_calculus.flat(primal_dx_field);
901 const Calculus::DualVectorField dual_dx_field(dual_calculus, dx_coords);
902 const Calculus::DualForm1 dual_dx = dual_calculus.flat(dual_dx_field);
907 board << primal_calculus;
908 board << primal_dx << primal_dx_field;
909 board << dual_calculus;
910 board << dual_dx << dual_dx_field;
911 board.
saveSVG(
"operators_flat_dx_primal.svg");
914 const Calculus::PrimalVectorField primal_dy_field(primal_calculus, dy_coords);
915 const Calculus::PrimalForm1 primal_dy = primal_calculus.flat(primal_dy_field);
916 const Calculus::DualVectorField dual_dy_field(dual_calculus, dy_coords);
917 const Calculus::DualForm1 dual_dy = dual_calculus.flat(dual_dy_field);
922 board << primal_calculus;
923 board << primal_dy << primal_dy_field;
924 board << dual_calculus;
925 board << dual_dy << dual_dy_field;
926 board.
saveSVG(
"operators_flat_dy_primal.svg");
929 #if defined(TEST_HARDCODED_ORDER)
930 Calculus::PrimalForm1::Container dx_container(7);
931 dx_container << -1, 0, 0, -1, 0, 1, 0;
932 Calculus::PrimalForm1::Container dxp_container(7);
933 dxp_container << 1, -1, 0, 0, 1, 0, 0;
934 FATAL_ERROR( primal_dx.myContainer == dx_container );
935 FATAL_ERROR( dual_dx.myContainer == dxp_container );
937 Calculus::PrimalForm1::Container dy_container(7);
938 dy_container << 0, 1, 1, 0, -1, 0, -1;
939 Calculus::PrimalForm1::Container dyp_container(7);
940 dyp_container << 0, 0, 1, 1, 0, -1, -1;
941 FATAL_ERROR( primal_dy.myContainer == dy_container );
942 FATAL_ERROR( dual_dy.myContainer == dyp_container );
952 Calculus::PrimalVectorField::Coordinates dx_coords(2,2);
953 dx_coords.col(0) = Eigen::VectorXd::Ones(2);
954 dx_coords.col(1) = Eigen::VectorXd::Zero(2);
956 Calculus::PrimalVectorField::Coordinates dy_coords(2,2);
957 dy_coords.col(0) = Eigen::VectorXd::Zero(2);
958 dy_coords.col(1) = Eigen::VectorXd::Ones(2);
960 const Calculus::DualVectorField primal_dx_field(primal_calculus, dx_coords);
961 const Calculus::DualForm1 primal_dx = primal_calculus.flat(primal_dx_field);
962 const Calculus::PrimalVectorField dual_dx_field(dual_calculus, dx_coords);
963 const Calculus::PrimalForm1 dual_dx = dual_calculus.flat(dual_dx_field);
968 board << primal_calculus;
969 board << primal_dx << primal_dx_field;
970 board << dual_calculus;
971 board << dual_dx << dual_dx_field;
972 board.
saveSVG(
"operators_flat_dx_dual.svg");
975 const Calculus::DualVectorField primal_dy_field(primal_calculus, dy_coords);
976 const Calculus::DualForm1 primal_dy = primal_calculus.flat(primal_dy_field);
977 const Calculus::PrimalVectorField dual_dy_field(dual_calculus, dy_coords);
978 const Calculus::PrimalForm1 dual_dy = dual_calculus.flat(dual_dy_field);
983 board << primal_calculus;
984 board << primal_dy << primal_dy_field;
985 board << dual_calculus;
986 board << dual_dy << dual_dy_field;
987 board.
saveSVG(
"operators_flat_dy_dual.svg");
990 #if defined(TEST_HARDCODED_ORDER)
991 Calculus::PrimalForm1::Container dx_container(7);
992 dx_container << 0, -1, -1, 0, 1, 0, 1;
993 Calculus::PrimalForm1::Container dxp_container(7);
994 dxp_container << 0, 0, 1, 1, 0, -1, -1;
995 FATAL_ERROR( primal_dx.myContainer == dx_container );
996 FATAL_ERROR( dual_dx.myContainer == dxp_container );
998 Calculus::PrimalForm1::Container dy_container(7);
999 dy_container << -1, 0, 0, -1, 0, 1, 0;
1000 Calculus::PrimalForm1::Container dyp_container(7);
1001 dyp_container << -1, 1, 0, 0, -1, 0, 0;
1002 FATAL_ERROR( primal_dy.myContainer == dy_container );
1003 FATAL_ERROR( dual_dy.myContainer == dyp_container );
void initKSpace(ConstAlias< TDomain > domain)
MyDigitalSurface::ConstIterator ConstIterator
DGtal::uint32_t Dimension
unsigned int dim(const Vector &z)