From 8806dc65922db8fa2dca68528701eefc011a4cbe Mon Sep 17 00:00:00 2001 From: dehnert Date: Sun, 25 Nov 2012 22:01:18 +0100 Subject: [PATCH] Performed renaming of static_sparse_matrix.h to SquareSparseMatrix.h, renamed the class accordingly and adapted the tests and includes. --- src/models/backward_transitions.h | 4 +- src/models/dtmc.h | 8 +- src/mrmc.cpp | 4 +- src/parser/read_tra_file.cpp | 6 +- src/parser/read_tra_file.h | 4 +- .../SquareSparseMatrix.h} | 40 +++---- src/utility/utility.cpp | 17 --- test/parser/read_tra_file_test.cpp | 4 +- .../BitVectorTest.cpp} | 0 .../SquareSparseMatrixTest.cpp} | 102 +++++++++--------- 10 files changed, 86 insertions(+), 103 deletions(-) rename src/{sparse/static_sparse_matrix.h => storage/SquareSparseMatrix.h} (93%) rename test/{vector/bitvector_test.cpp => storage/BitVectorTest.cpp} (100%) rename test/{sparse/static_sparse_matrix_test.cpp => storage/SquareSparseMatrixTest.cpp} (69%) diff --git a/src/models/backward_transitions.h b/src/models/backward_transitions.h index 52311d3f5..cc20c17e3 100644 --- a/src/models/backward_transitions.h +++ b/src/models/backward_transitions.h @@ -9,7 +9,7 @@ #define BACKWARD_TRANSITIONS_H_ #include -#include "src/sparse/static_sparse_matrix.h" +#include "src/storage/SquareSparseMatrix.h" namespace mrmc { @@ -35,7 +35,7 @@ public: * @param transition_matrix The (0-based) matrix representing the transition * relation. */ - BackwardTransitions(mrmc::sparse::StaticSparseMatrix* transitionMatrix) { + BackwardTransitions(mrmc::sparse::SquareSparseMatrix* transitionMatrix) { numberOfNonZeroTransitions = transitionMatrix->getNonZeroEntryCount(); this->predecessor_list = new uint_fast64_t[numberOfNonZeroTransitions]; diff --git a/src/models/dtmc.h b/src/models/dtmc.h index 4dd6e0da1..8a648a24e 100644 --- a/src/models/dtmc.h +++ b/src/models/dtmc.h @@ -12,7 +12,7 @@ #include "atomic_propositions_labeling.h" #include "backward_transitions.h" -#include "src/sparse/static_sparse_matrix.h" +#include "src/storage/SquareSparseMatrix.h" namespace mrmc { @@ -35,7 +35,7 @@ public: * @param state_labeling The labeling that assigns a set of atomic * propositions to each state. */ - Dtmc(mrmc::sparse::StaticSparseMatrix* probability_matrix, mrmc::models::AtomicPropositionsLabeling* state_labeling) + Dtmc(mrmc::sparse::SquareSparseMatrix* probability_matrix, mrmc::models::AtomicPropositionsLabeling* state_labeling) : backward_transitions(probability_matrix) { this->probability_matrix = probability_matrix; this->state_labeling = state_labeling; @@ -84,7 +84,7 @@ public: * @return A pointer to the matrix representing the transition probability * function. */ - mrmc::sparse::StaticSparseMatrix* getTransitionProbabilityMatrix() { + mrmc::sparse::SquareSparseMatrix* getTransitionProbabilityMatrix() { return this->probability_matrix; } @@ -111,7 +111,7 @@ public: private: /*! A matrix representing the transition probability function of the DTMC. */ - mrmc::sparse::StaticSparseMatrix* probability_matrix; + mrmc::sparse::SquareSparseMatrix* probability_matrix; /*! The labeling of the states of the DTMC. */ mrmc::models::AtomicPropositionsLabeling* state_labeling; diff --git a/src/mrmc.cpp b/src/mrmc.cpp index 98c4005dd..1dbf4b1f3 100644 --- a/src/mrmc.cpp +++ b/src/mrmc.cpp @@ -17,7 +17,7 @@ #include "mrmc-config.h" #include "src/models/dtmc.h" -#include "src/sparse/static_sparse_matrix.h" +#include "src/storage/SquareSparseMatrix.h" #include "src/models/atomic_propositions_labeling.h" #include "src/parser/read_lab_file.h" #include "src/parser/read_tra_file.h" @@ -77,7 +77,7 @@ int main(const int argc, const char* argv[]) { return 0; } - mrmc::sparse::StaticSparseMatrix* probMatrix = mrmc::parser::read_tra_file(s->getString("trafile").c_str()); + mrmc::sparse::SquareSparseMatrix* probMatrix = mrmc::parser::read_tra_file(s->getString("trafile").c_str()); mrmc::models::AtomicPropositionsLabeling* labeling = mrmc::parser::read_lab_file(probMatrix->getRowCount(), s->getString("labfile").c_str()); mrmc::models::Dtmc dtmc(probMatrix, labeling); diff --git a/src/parser/read_tra_file.cpp b/src/parser/read_tra_file.cpp index cc629a5b5..504269b3d 100644 --- a/src/parser/read_tra_file.cpp +++ b/src/parser/read_tra_file.cpp @@ -90,12 +90,12 @@ static uint_fast32_t make_first_pass(FILE* p) { * @return a pointer to the created sparse matrix. */ -sparse::StaticSparseMatrix * read_tra_file(const char * filename) { +sparse::SquareSparseMatrix * read_tra_file(const char * filename) { FILE *p = NULL; char s[BUFFER_SIZE]; uint_fast64_t non_zero = 0; int rows = 0; - sparse::StaticSparseMatrix *sp = NULL; + sparse::SquareSparseMatrix *sp = NULL; p = fopen(filename, "r"); if(p == NULL) { @@ -129,7 +129,7 @@ sparse::StaticSparseMatrix * read_tra_file(const char * filename) { * Memory for diagonal elements is automatically allocated, hence only the number of non-diagonal * non-zero elements has to be specified (which is non_zero, computed by make_first_pass) */ - sp = new sparse::StaticSparseMatrix(static_cast(rows) + 1); + sp = new sparse::SquareSparseMatrix(static_cast(rows) + 1); if ( NULL == sp ) { throw std::bad_alloc(); return NULL; diff --git a/src/parser/read_tra_file.h b/src/parser/read_tra_file.h index 20886d2f6..2b7cf6f32 100644 --- a/src/parser/read_tra_file.h +++ b/src/parser/read_tra_file.h @@ -7,11 +7,11 @@ #ifndef READ_TRA_FILE_H_ #define READ_TRA_FILE_H_ -#include "src/sparse/static_sparse_matrix.h" +#include "src/storage/SquareSparseMatrix.h" namespace mrmc{ namespace parser { -mrmc::sparse::StaticSparseMatrix * read_tra_file(const char * filename); +mrmc::sparse::SquareSparseMatrix * read_tra_file(const char * filename); } } diff --git a/src/sparse/static_sparse_matrix.h b/src/storage/SquareSparseMatrix.h similarity index 93% rename from src/sparse/static_sparse_matrix.h rename to src/storage/SquareSparseMatrix.h index ea0f0a59f..246ea0857 100644 --- a/src/sparse/static_sparse_matrix.h +++ b/src/storage/SquareSparseMatrix.h @@ -29,7 +29,7 @@ namespace sparse { * where rows is the first argument to the constructor. */ template -class StaticSparseMatrix { +class SquareSparseMatrix { public: /*! @@ -56,24 +56,24 @@ public: * Constructs a sparse matrix object with the given number of rows. * @param rows The number of rows of the matrix */ - StaticSparseMatrix(uint_fast64_t rows) - : rowCount(rows), nonZeroEntryCount(0), valueStorage(nullptr), diagonalStorage(nullptr), columnIndications(nullptr), rowIndications(nullptr), internalStatus(MatrixStatus::UnInitialized), currentSize(0), lastRow(0) { } + SquareSparseMatrix(uint_fast64_t rows) + : rowCount(rows), nonZeroEntryCount(0), valueStorage(nullptr), + diagonalStorage(nullptr),columnIndications(nullptr), rowIndications(nullptr), + internalStatus(MatrixStatus::UnInitialized), currentSize(0), lastRow(0) { } //! Copy Constructor /*! * Copy Constructor. Performs a deep copy of the given sparse matrix. * @param ssm A reference to the matrix to be copied. */ - StaticSparseMatrix(const StaticSparseMatrix &ssm) - : internalStatus(ssm.internalStatus), - currentSize(ssm.currentSize), lastRow(ssm.lastRow), - rowCount(ssm.rowCount), - nonZeroEntryCount(ssm.nonZeroEntryCount) { + SquareSparseMatrix(const SquareSparseMatrix &ssm) + : internalStatus(ssm.internalStatus), currentSize(ssm.currentSize), lastRow(ssm.lastRow), + rowCount(ssm.rowCount), nonZeroEntryCount(ssm.nonZeroEntryCount) { LOG4CPLUS_WARN(logger, "Invoking copy constructor."); // Check whether copying the matrix is safe. if (!ssm.hasError()) { LOG4CPLUS_ERROR(logger, "Trying to copy sparse matrix in error state."); - throw mrmc::exceptions::invalid_argument(); + throw mrmc::exceptions::invalid_argument("Trying to copy sparse matrix in error state."); } else { // Try to prepare the internal storage and throw an error in case // of a failure. @@ -107,7 +107,7 @@ public: /*! * Destructor. Performs deletion of the reserved storage arrays. */ - ~StaticSparseMatrix() { + ~SquareSparseMatrix() { setState(MatrixStatus::UnInitialized); if (valueStorage != NULL) { //free(value_storage); @@ -141,15 +141,15 @@ public: if (internalStatus != MatrixStatus::UnInitialized) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to initialize matrix that is not uninitialized."); - throw mrmc::exceptions::invalid_state("StaticSparseMatrix::initialize: Invalid state for status flag != 0 - Already initialized?"); + throw mrmc::exceptions::invalid_state("Trying to initialize matrix that is not uninitialized."); } else if (rowCount == 0) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to create initialize a matrix with 0 rows."); - throw mrmc::exceptions::invalid_argument("mrmc::StaticSparseMatrix::initialize: Matrix with 0 rows is not reasonable"); + throw mrmc::exceptions::invalid_argument("Trying to create initialize a matrix with 0 rows."); } else if (((rowCount * rowCount) - rowCount) < nonZeroEntries) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to initialize a matrix with more non-zero entries than there can be."); - throw mrmc::exceptions::invalid_argument("mrmc::StaticSparseMatrix::initialize: More non-zero entries than entries in target matrix"); + throw mrmc::exceptions::invalid_argument("Trying to initialize a matrix with more non-zero entries than there can be."); } else { // If it is safe, initialize necessary members and prepare the // internal storage. @@ -180,7 +180,7 @@ public: if (!eigenSparseMatrix.isCompressed()) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to initialize from an Eigen matrix that is not in compressed form."); - throw mrmc::exceptions::invalid_argument("StaticSparseMatrix::initialize: Throwing invalid_argument: eigen_sparse_matrix is not in Compressed form."); + throw mrmc::exceptions::invalid_argument("Trying to initialize from an Eigen matrix that is not in compressed form."); } // Compute the actual (i.e. non-diagonal) number of non-zero entries. @@ -273,7 +273,7 @@ public: if ((row > rowCount) || (col > rowCount)) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to add a value at illegal position (" << row << ", " << col << ")."); - throw mrmc::exceptions::out_of_range("StaticSparseMatrix::addNextValue: row or col not in 0 .. rows"); + throw mrmc::exceptions::out_of_range("Trying to add a value at illegal position."); } if (row == col) { // Set a diagonal element. @@ -306,11 +306,11 @@ public: if (!isInitialized()) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to finalize an uninitialized matrix."); - throw mrmc::exceptions::invalid_state("StaticSparseMatrix::finalize: Invalid state for internal state not Initialized - Already finalized?"); + throw mrmc::exceptions::invalid_state("Trying to finalize an uninitialized matrix."); } else if (currentSize != nonZeroEntryCount) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to finalize a matrix that was initialized with more non-zero entries than given."); - throw mrmc::exceptions::invalid_state("StaticSparseMatrix::finalize: Wrong call count for addNextValue"); + throw mrmc::exceptions::invalid_state("Trying to finalize a matrix that was initialized with more non-zero entries than given."); } else { // Fill in the missing entries in the row_indications array. // (Can happen because of empty rows at the end.) @@ -344,7 +344,7 @@ public: // Check for illegal access indices. if ((row > rowCount) || (col > rowCount)) { LOG4CPLUS_ERROR(logger, "Trying to read a value from illegal position (" << row << ", " << col << ")."); - throw mrmc::exceptions::out_of_range("StaticSparseMatrix::getValue: row or col not in 0 .. rows"); + throw mrmc::exceptions::out_of_range("Trying to read a value from illegal position."); return false; } @@ -468,7 +468,7 @@ public: if (!isReadReady()) { triggerErrorState(); LOG4CPLUS_ERROR(logger, "Trying to convert a matrix that is not in a readable state to an Eigen matrix."); - throw mrmc::exceptions::invalid_state("StaticSparseMatrix::toEigenSparseMatrix: Invalid state for internal state not ReadReady."); + throw mrmc::exceptions::invalid_state("Trying to convert a matrix that is not in a readable state to an Eigen matrix."); } else { // Create a int_fast32_t eigenRows = static_cast(rowCount); @@ -574,7 +574,7 @@ public: // Check whether the accessed state exists. if (row > rowCount) { LOG4CPLUS_ERROR(logger, "Trying to make an illegal row " << row << " absorbing."); - throw mrmc::exceptions::out_of_range("StaticSparseMatrix::makeStateFinal: state not in 0 .. rows"); + throw mrmc::exceptions::out_of_range("Trying to make an illegal row absorbing."); return false; } diff --git a/src/utility/utility.cpp b/src/utility/utility.cpp index 656e51ac1..90e298a67 100644 --- a/src/utility/utility.cpp +++ b/src/utility/utility.cpp @@ -9,10 +9,6 @@ #include "src/parser/read_tra_file.h" #include "src/parser/read_lab_file.h" -#include "src/sparse/static_sparse_matrix.h" -#include "src/models/dtmc.h" -#include "src/models/atomic_propositions_labeling.h" - namespace mrmc { namespace utility { @@ -77,19 +73,6 @@ void dtmcToDot(mrmc::models::Dtmc* dtmc, const char* filename) { fclose(P); */ } -mrmc::models::Dtmc* parseDTMC(const char* tra_file, const char* lab_file) { - mrmc::sparse::StaticSparseMatrix* transition_matrix = - mrmc::parser::read_tra_file(tra_file); - uint_fast64_t node_count = transition_matrix->getRowCount(); - - mrmc::models::AtomicPropositionsLabeling* labeling = - mrmc::parser::read_lab_file(node_count, lab_file); - - mrmc::models::Dtmc* result = - new mrmc::models::Dtmc(transition_matrix, labeling); - return result; -} - } } diff --git a/test/parser/read_tra_file_test.cpp b/test/parser/read_tra_file_test.cpp index 29fdc8dc7..4c2fce2bd 100644 --- a/test/parser/read_tra_file_test.cpp +++ b/test/parser/read_tra_file_test.cpp @@ -7,7 +7,7 @@ #include "gtest/gtest.h" #include "mrmc-config.h" -#include "src/sparse/static_sparse_matrix.h" +#include "src/storage/SquareSparseMatrix.h" #include "src/parser/read_tra_file.h" #include "src/exceptions/file_IO_exception.h" #include "src/exceptions/wrong_file_format.h" @@ -20,7 +20,7 @@ TEST(ReadTraFileTest, NonExistingFileTest) { /* The following test case is based on one of the original MRMC test cases */ TEST(ReadTraFileTest, ParseFileTest1) { - mrmc::sparse::StaticSparseMatrix *result = NULL; + mrmc::sparse::SquareSparseMatrix *result = NULL; ASSERT_NO_THROW(result = mrmc::parser::read_tra_file(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/csl_general_input_01.tra")); if (result != NULL) { diff --git a/test/vector/bitvector_test.cpp b/test/storage/BitVectorTest.cpp similarity index 100% rename from test/vector/bitvector_test.cpp rename to test/storage/BitVectorTest.cpp diff --git a/test/sparse/static_sparse_matrix_test.cpp b/test/storage/SquareSparseMatrixTest.cpp similarity index 69% rename from test/sparse/static_sparse_matrix_test.cpp rename to test/storage/SquareSparseMatrixTest.cpp index 552534a23..d7cfd537d 100644 --- a/test/sparse/static_sparse_matrix_test.cpp +++ b/test/storage/SquareSparseMatrixTest.cpp @@ -1,72 +1,72 @@ #include "gtest/gtest.h" -#include "src/sparse/static_sparse_matrix.h" +#include "src/storage/SquareSparseMatrix.h" #include "src/exceptions/invalid_argument.h" -TEST(StaticSparseMatrixTest, ZeroRowsTest) { - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(0); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); +TEST(SquareSparseMatrixTest, ZeroRowsTest) { + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(0); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); ASSERT_THROW(ssm->initialize(50), mrmc::exceptions::invalid_argument); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Error); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Error); delete ssm; } -TEST(StaticSparseMatrixTest, TooManyEntriesTest) { - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(2); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); +TEST(SquareSparseMatrixTest, TooManyEntriesTest) { + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(2); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); ASSERT_THROW(ssm->initialize(10), mrmc::exceptions::invalid_argument); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Error); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Error); delete ssm; } -TEST(StaticSparseMatrixTest, addNextValueTest) { - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(5); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); +TEST(SquareSparseMatrixTest, addNextValueTest) { + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(5); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); ASSERT_NO_THROW(ssm->initialize(1)); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Initialized); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Initialized); ASSERT_THROW(ssm->addNextValue(-1, 1, 1), mrmc::exceptions::out_of_range); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Error); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Error); ASSERT_THROW(ssm->addNextValue(1, -1, 1), mrmc::exceptions::out_of_range); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Error); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Error); ASSERT_THROW(ssm->addNextValue(6, 1, 1), mrmc::exceptions::out_of_range); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Error); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Error); ASSERT_THROW(ssm->addNextValue(1, 6, 1), mrmc::exceptions::out_of_range); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Error); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Error); delete ssm; } -TEST(StaticSparseMatrixTest, finalizeTest) { - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(5); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); +TEST(SquareSparseMatrixTest, finalizeTest) { + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(5); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); ASSERT_NO_THROW(ssm->initialize(5)); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Initialized); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Initialized); ASSERT_NO_THROW(ssm->addNextValue(1, 2, 1)); ASSERT_NO_THROW(ssm->addNextValue(1, 3, 1)); ASSERT_NO_THROW(ssm->addNextValue(1, 4, 1)); ASSERT_NO_THROW(ssm->addNextValue(1, 5, 1)); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Initialized); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Initialized); ASSERT_THROW(ssm->finalize(), mrmc::exceptions::invalid_state); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Error); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Error); delete ssm; } -TEST(StaticSparseMatrixTest, Test) { +TEST(SquareSparseMatrixTest, Test) { // 25 rows, 50 non zero entries - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(25); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(25); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); int values[50] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, @@ -95,15 +95,15 @@ TEST(StaticSparseMatrixTest, Test) { }; ASSERT_NO_THROW(ssm->initialize(50)); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Initialized); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Initialized); for (int i = 0; i < 50; ++i) { ASSERT_NO_THROW(ssm->addNextValue(position_row[i], position_col[i], values[i])); } - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Initialized); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Initialized); ASSERT_NO_THROW(ssm->finalize()); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::ReadReady); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::ReadReady); int target; for (int i = 0; i < 50; ++i) { @@ -124,15 +124,15 @@ TEST(StaticSparseMatrixTest, Test) { ASSERT_EQ(0, target); } } - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::ReadReady); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::ReadReady); delete ssm; } -TEST(StaticSparseMatrixTest, ConversionFromDenseEigen_ColMajor_SparseMatrixTest) { +TEST(SquareSparseMatrixTest, ConversionFromDenseEigen_ColMajor_SparseMatrixTest) { // 10 rows, 100 non zero entries - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(10); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(10); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); Eigen::SparseMatrix esm(10, 10); for (int row = 0; row < 10; ++row) { @@ -148,7 +148,7 @@ TEST(StaticSparseMatrixTest, ConversionFromDenseEigen_ColMajor_SparseMatrixTest) ASSERT_NO_THROW(ssm->finalize()); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::ReadReady); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::ReadReady); int target = -1; for (int row = 0; row < 10; ++row) { @@ -159,10 +159,10 @@ TEST(StaticSparseMatrixTest, ConversionFromDenseEigen_ColMajor_SparseMatrixTest) } } -TEST(StaticSparseMatrixTest, ConversionFromDenseEigen_RowMajor_SparseMatrixTest) { +TEST(SquareSparseMatrixTest, ConversionFromDenseEigen_RowMajor_SparseMatrixTest) { // 10 rows, 100 non zero entries - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(10); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(10); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); Eigen::SparseMatrix esm(10, 10); for (int row = 0; row < 10; ++row) { @@ -178,7 +178,7 @@ TEST(StaticSparseMatrixTest, ConversionFromDenseEigen_RowMajor_SparseMatrixTest) ASSERT_NO_THROW(ssm->finalize()); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::ReadReady); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::ReadReady); int target = -1; for (int row = 0; row < 10; ++row) { @@ -189,10 +189,10 @@ TEST(StaticSparseMatrixTest, ConversionFromDenseEigen_RowMajor_SparseMatrixTest) } } -TEST(StaticSparseMatrixTest, ConversionFromSparseEigen_ColMajor_SparseMatrixTest) { +TEST(SquareSparseMatrixTest, ConversionFromSparseEigen_ColMajor_SparseMatrixTest) { // 10 rows, 15 non zero entries - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(10); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(10); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); Eigen::SparseMatrix esm(10, 10); @@ -226,7 +226,7 @@ TEST(StaticSparseMatrixTest, ConversionFromSparseEigen_ColMajor_SparseMatrixTest ASSERT_NO_THROW(ssm->finalize()); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::ReadReady); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::ReadReady); int target = -1; @@ -236,10 +236,10 @@ TEST(StaticSparseMatrixTest, ConversionFromSparseEigen_ColMajor_SparseMatrixTest } } -TEST(StaticSparseMatrixTest, ConversionFromSparseEigen_RowMajor_SparseMatrixTest) { +TEST(SquareSparseMatrixTest, ConversionFromSparseEigen_RowMajor_SparseMatrixTest) { // 10 rows, 15 non zero entries - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(10); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::UnInitialized); + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(10); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::UnInitialized); Eigen::SparseMatrix esm(10, 10); @@ -273,7 +273,7 @@ TEST(StaticSparseMatrixTest, ConversionFromSparseEigen_RowMajor_SparseMatrixTest ASSERT_NO_THROW(ssm->finalize()); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::ReadReady); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::ReadReady); int target = -1; @@ -283,26 +283,26 @@ TEST(StaticSparseMatrixTest, ConversionFromSparseEigen_RowMajor_SparseMatrixTest } } -TEST(StaticSparseMatrixTest, ConversionToSparseEigen_RowMajor_SparseMatrixTest) { +TEST(SquareSparseMatrixTest, ConversionToSparseEigen_RowMajor_SparseMatrixTest) { int values[100]; - mrmc::sparse::StaticSparseMatrix *ssm = new mrmc::sparse::StaticSparseMatrix(10); + mrmc::sparse::SquareSparseMatrix *ssm = new mrmc::sparse::SquareSparseMatrix(10); for (uint_fast32_t i = 0; i < 100; ++i) { values[i] = i; } ASSERT_NO_THROW(ssm->initialize(100 - 10)); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Initialized); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Initialized); for (uint_fast32_t row = 0; row < 10; ++row) { for (uint_fast32_t col = 0; col < 10; ++col) { ASSERT_NO_THROW(ssm->addNextValue(row, col, values[row * 10 + col])); } } - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::Initialized); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::Initialized); ASSERT_NO_THROW(ssm->finalize()); - ASSERT_EQ(ssm->getState(), mrmc::sparse::StaticSparseMatrix::MatrixStatus::ReadReady); + ASSERT_EQ(ssm->getState(), mrmc::sparse::SquareSparseMatrix::MatrixStatus::ReadReady); Eigen::SparseMatrix* esm = ssm->toEigenSparseMatrix();