From ded88c5ade91abc187cc2210e8e35f705094f38d Mon Sep 17 00:00:00 2001 From: kocotom Date: Thu, 28 Mar 2024 20:21:25 +0100 Subject: [PATCH] Ordinary functions marked as inline, definitions of the methods of the ExtendableSquareMatrix placed after the definition of the class --- include/mata/utils/partition-relation-pair.hh | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/include/mata/utils/partition-relation-pair.hh b/include/mata/utils/partition-relation-pair.hh index 3f8c5b13b..680330f25 100644 --- a/include/mata/utils/partition-relation-pair.hh +++ b/include/mata/utils/partition-relation-pair.hh @@ -871,6 +871,65 @@ class ExtendableSquareMatrix { }; // ExtendableSquareMatrix +/** This function checks whether the matrix is reflexive. In this +* context, the matrix is reflexive iff none of the elements on the main +* diagonal is the zero element of the type T +* @brief checks whether the Extendable square matrix is reflexive +* @return true iff the matrix is reflexive +*/ +template +bool ExtendableSquareMatrix::is_reflexive(void) { + size_t size = this->size(); + for(size_t i = 0; i < size; ++i) { + if(!get(i, i)) { return false; } + } + return true; +} + +/** This function checks whether the matrix is antisymetric. In this +* context, the matrix is antisymetric iff there are no indices i, j +* where i != j and both matrix[i][j], matrix[j][i] contain nonzero elementes +* of the type T +* @brief checks whether the Extendable square matrix is antisymetric +* @return true iff the matrix is antisymetric +*/ +template +bool ExtendableSquareMatrix::is_antisymetric(void) { + size_t size = this->size(); + for(size_t i = 0; i < size; ++i) { + for(size_t j = 0; j < size; ++j) { + if(i == j) { continue; } + if(get(i, j) && get(j, i)) { return false; } + } + } + return true; +} + +/** This function checks whether the matrix is transitive. In this +* context, the matrix is transitive iff it holds that the input matrix +* casted to the matrix of booleans (false for zero values of type T, otherwise +* true) remains the same if it is multiplied by itself. +* @brief checks whether the Extendable square matrix is transitive +* @return true iff the matrix is transitive +*/ +template +bool ExtendableSquareMatrix::is_transitive(void) { + size_t size = this->size(); + for(size_t i = 0; i < size; ++i) { + for(size_t j = 0; j < size; ++j) { + bool found = false; + for(size_t k = 0; k < size; ++k) { + if(get(i, k) && get(k, j)) { + found = true; + break; + } + } + if(!found == static_cast(get(i, j))) { return false; } + } + } + return true; +} + /************************************* * * CASCADE SQUARE MATRIX @@ -1297,7 +1356,7 @@ void HashedSquareMatrix::extend(T placeholder) { * @return pointer to the newly created matrix */ template -ExtendableSquareMatrix *create(MatrixType type, +inline ExtendableSquareMatrix *create(MatrixType type, size_t capacity, size_t size = 0) { switch(type) { @@ -1315,7 +1374,7 @@ ExtendableSquareMatrix *create(MatrixType type, // debugging function which allows us to print text representation of // the Extendable square matrix template -std::ostream& operator<<(std::ostream& os, +inline std::ostream& operator<<(std::ostream& os, const ExtendableSquareMatrix& matrix) { size_t size = matrix.size(); @@ -1332,65 +1391,6 @@ std::ostream& operator<<(std::ostream& os, return os << result; } -/** This function checks whether the matrix is reflexive. In this -* context, the matrix is reflexive iff none of the elements on the main -* diagonal is the zero element of the type T -* @brief checks whether the Extendable square matrix is reflexive -* @return true iff the matrix is reflexive -*/ -template -bool ExtendableSquareMatrix::is_reflexive(void) { - size_t size = this->size(); - for(size_t i = 0; i < size; ++i) { - if(!get(i, i)) { return false; } - } - return true; -} - -/** This function checks whether the matrix is antisymetric. In this -* context, the matrix is antisymetric iff there are no indices i, j -* where i != j and both matrix[i][j], matrix[j][i] contain nonzero elementes -* of the type T -* @brief checks whether the Extendable square matrix is antisymetric -* @return true iff the matrix is antisymetric -*/ -template -bool ExtendableSquareMatrix::is_antisymetric(void) { - size_t size = this->size(); - for(size_t i = 0; i < size; ++i) { - for(size_t j = 0; j < size; ++j) { - if(i == j) { continue; } - if(get(i, j) && get(j, i)) { return false; } - } - } - return true; -} - -/** This function checks whether the matrix is transitive. In this -* context, the matrix is transitive iff it holds that the input matrix -* casted to the matrix of booleans (false for zero values of type T, otherwise -* true) remains the same if it is multiplied by itself. -* @brief checks whether the Extendable square matrix is transitive -* @return true iff the matrix is transitive -*/ -template -bool ExtendableSquareMatrix::is_transitive(void) { - size_t size = this->size(); - for(size_t i = 0; i < size; ++i) { - for(size_t j = 0; j < size; ++j) { - bool found = false; - for(size_t k = 0; k < size; ++k) { - if(get(i, k) && get(k, j)) { - found = true; - break; - } - } - if(!found == static_cast(get(i, j))) { return false; } - } - } - return true; -} - } #endif