diff --git a/resolve/matrix/MatrixHandler.cpp b/resolve/matrix/MatrixHandler.cpp index 6ebadfa7..c605ce5a 100644 --- a/resolve/matrix/MatrixHandler.cpp +++ b/resolve/matrix/MatrixHandler.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "MatrixHandler.hpp" #include "MatrixHandlerCpu.hpp" #include "MatrixHandlerCuda.hpp" @@ -14,39 +15,6 @@ namespace ReSolve { // Create a shortcut name for Logger static class using out = io::Logger; - //helper class - indexPlusValue::indexPlusValue() - { - idx_ = 0; - value_ = 0.0; - } - - - indexPlusValue::~indexPlusValue() - { - } - - void indexPlusValue::setIdx(index_type new_idx) - { - idx_ = new_idx; - } - - void indexPlusValue::setValue(real_type new_value) - { - value_ = new_value; - } - - index_type indexPlusValue::getIdx() - { - return idx_; - } - - real_type indexPlusValue::getValue() - { - return value_; - } - //end of helper class - MatrixHandler::MatrixHandler() { this->new_matrix_ = true; @@ -131,7 +99,7 @@ namespace ReSolve { index_type* nnz_shifts = new index_type[n]; std::fill_n(nnz_shifts, n , 0); - indexPlusValue* tmp = new indexPlusValue[nnz_unpacked]; + IndexValuePair* tmp = new IndexValuePair[nnz_unpacked]; csr_ia[0] = 0; diff --git a/resolve/matrix/MatrixHandler.hpp b/resolve/matrix/MatrixHandler.hpp index 59ace249..7ba01a08 100644 --- a/resolve/matrix/MatrixHandler.hpp +++ b/resolve/matrix/MatrixHandler.hpp @@ -28,28 +28,6 @@ namespace ReSolve namespace ReSolve { - //helper class - class indexPlusValue - { - public: - indexPlusValue(); - ~indexPlusValue(); - void setIdx (index_type new_idx); - void setValue (real_type new_value); - - index_type getIdx(); - real_type getValue(); - - bool operator < (const indexPlusValue& str) const - { - return (idx_ < str.idx_); - } - - private: - index_type idx_; - real_type value_; - }; - class MatrixHandler { using vector_type = vector::Vector; diff --git a/resolve/matrix/MatrixHandlerCpu.cpp b/resolve/matrix/MatrixHandlerCpu.cpp index 522d2a1b..cc211f5f 100644 --- a/resolve/matrix/MatrixHandlerCpu.cpp +++ b/resolve/matrix/MatrixHandlerCpu.cpp @@ -12,39 +12,6 @@ namespace ReSolve { // Create a shortcut name for Logger static class using out = io::Logger; - // //helper class - // indexPlusValue::indexPlusValue() - // { - // idx_ = 0; - // value_ = 0.0; - // } - - - // indexPlusValue::~indexPlusValue() - // { - // } - - // void indexPlusValue::setIdx(index_type new_idx) - // { - // idx_ = new_idx; - // } - - // void indexPlusValue::setValue(real_type new_value) - // { - // value_ = new_value; - // } - - // index_type indexPlusValue::getIdx() - // { - // return idx_; - // } - - // real_type indexPlusValue::getValue() - // { - // return value_; - // } - // //end of helper class - MatrixHandlerCpu::MatrixHandlerCpu() { // new_matrix_ = true; @@ -125,7 +92,7 @@ namespace ReSolve { // index_type* nnz_shifts = new index_type[n]; // std::fill_n(nnz_shifts, n , 0); -// indexPlusValue* tmp = new indexPlusValue[nnz_unpacked]; +// IndexValuePair* tmp = new IndexValuePair[nnz_unpacked]; // csr_ia[0] = 0; diff --git a/resolve/matrix/MatrixHandlerCuda.cpp b/resolve/matrix/MatrixHandlerCuda.cpp index f40de0d8..deb09180 100644 --- a/resolve/matrix/MatrixHandlerCuda.cpp +++ b/resolve/matrix/MatrixHandlerCuda.cpp @@ -12,39 +12,6 @@ namespace ReSolve { // Create a shortcut name for Logger static class using out = io::Logger; - // //helper class - // indexPlusValue::indexPlusValue() - // { - // idx_ = 0; - // value_ = 0.0; - // } - - - // indexPlusValue::~indexPlusValue() - // { - // } - - // void indexPlusValue::setIdx(index_type new_idx) - // { - // idx_ = new_idx; - // } - - // void indexPlusValue::setValue(real_type new_value) - // { - // value_ = new_value; - // } - - // index_type indexPlusValue::getIdx() - // { - // return idx_; - // } - - // real_type indexPlusValue::getValue() - // { - // return value_; - // } - // //end of helper class - MatrixHandlerCuda::MatrixHandlerCuda() { // new_matrix_ = true; @@ -125,7 +92,7 @@ namespace ReSolve { // index_type* nnz_shifts = new index_type[n]; // std::fill_n(nnz_shifts, n , 0); -// indexPlusValue* tmp = new indexPlusValue[nnz_unpacked]; +// IndexValuePair* tmp = new IndexValuePair[nnz_unpacked]; // csr_ia[0] = 0; diff --git a/resolve/utilities/misc/IndexValuePair.hpp b/resolve/utilities/misc/IndexValuePair.hpp new file mode 100644 index 00000000..b09ccf97 --- /dev/null +++ b/resolve/utilities/misc/IndexValuePair.hpp @@ -0,0 +1,43 @@ +#pragma once + + +namespace ReSolve { + + /// @brief Helper class for COO matrix sorting + class IndexValuePair + { + public: + IndexValuePair() : idx_(0), value_(0.0) + {} + ~IndexValuePair() + {} + void setIdx (index_type new_idx) + { + idx_ = new_idx; + } + void setValue (real_type new_value) + { + value_ = new_value; + } + + index_type getIdx() + { + return idx_; + } + real_type getValue() + { + return value_; + } + + bool operator < (const IndexValuePair& str) const + { + return (idx_ < str.idx_); + } + + private: + index_type idx_; + real_type value_; + }; + +} // namespace ReSolve +