30 #ifndef _CHAINCON_SNF_H_ 31 #define _CHAINCON_SNF_H_ 38 #include "chomp/system/config.h" 58 template <
class MatrixT>
61 using chomp::homology::sout;
62 using chomp::homology::timeused;
64 typedef typename MatrixT::ChainType AlgChainType;
69 sout <<
"Change of basis check: ";
71 for (
int q = 0; q < maxDim; ++ q)
73 int_t nColumns = matrix. getNumCols (q);
74 for (int_t n = 0; n < nColumns; ++ n)
76 AlgChainType ch (matrix. getNewChain (q, n));
78 int_t size = ch. size ();
79 for (int_t i = 0; i < size; ++ i)
81 AlgChainType part (matrix. getOldChain
82 (q, ch. getCell (i). getId ()));
83 part *= ch. getCoef (i);
86 if (!(result. size () == 1) ||
87 !(result. getCell (0). getId () == n) ||
88 !(result. getCoef (0) == 1))
90 throw "Wrong change of basis (1).";
93 for (int_t n = 0; n < nColumns; ++ n)
95 AlgChainType ch (matrix. getOldChain (q, n));
97 int_t size = ch. size ();
98 for (int_t i = 0; i < size; ++ i)
100 AlgChainType part (matrix. getNewChain
101 (q, ch. getCell (i). getId ()));
102 part *= ch. getCoef (i);
105 if (!(result. size () == 1) ||
106 !(result. getCell (0). getId () == n) ||
107 !(result. getCoef (0) == 1))
109 throw "Wrong change of basis (2).";
113 sout <<
"Completed in " << verifTime <<
".\n";
119 #endif // _CHAINCON_SNF_H_ An interface to the SNF computation using the CHomP software package.
A chain with coefficients in an arbitrary commutative ring.
void verifyChangeOfBasisSNF(const MatrixT &matrix, int maxDim)
Verifies if the change of basis matrices match each other.