From 320d6c81cb015a548efe84859358d5d1c6af6ea9 Mon Sep 17 00:00:00 2001 From: kradchen Date: Mon, 29 May 2023 09:37:04 +0800 Subject: [PATCH] Add sparse matrix. --- src/Sparse.cpp | 29 +++++++++++++++++++++++++++++ src/Sparse.h | 26 ++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/Sparse.cpp create mode 100644 src/Sparse.h diff --git a/src/Sparse.cpp b/src/Sparse.cpp new file mode 100644 index 0000000..ad76baf --- /dev/null +++ b/src/Sparse.cpp @@ -0,0 +1,29 @@ +#include "Sparse.h" +#include "Matrix.h" +namespace Aurora +{ + Sparse::Sparse() + { + } + + Sparse::~Sparse() + { + } + + Sparse::Sparse(Matrix& Cols, Matrix& Rows, Matrix& Values,size_t M, size_t N) + : mColIdxVector(Cols), + mRowIdxVector(Rows), + mValueVector(Values), + mM(M), + mN(N) + { + + } + + bool Sparse::isValid() const + { + return mColIdxVector.isVector() && mRowIdxVector.isVector() && mValueVector.isVector() + && mColIdxVector.getDataSize() == mRowIdxVector.getDataSize() + && mColIdxVector.getDataSize() == mValueVector.getDataSize(); + } +} \ No newline at end of file diff --git a/src/Sparse.h b/src/Sparse.h new file mode 100644 index 0000000..0844b20 --- /dev/null +++ b/src/Sparse.h @@ -0,0 +1,26 @@ +#ifndef __SPARSE_H__ +#define __SPARSE_H__ +#include "Matrix.h" +#include +namespace Aurora { + class Sparse + { + public: + Sparse(); + Sparse(Matrix& Cols, Matrix& Rows, Matrix& Values,size_t M, size_t N); + ~Sparse(); + bool isValid() const; + // TODO:add operators + private: + Matrix mColIdxVector; + Matrix mRowIdxVector; + Matrix mValueVector; + std::size_t mM;//row count + std::size_t mN;//col count + }; +} + + + + +#endif // __SPARSE_H__ \ No newline at end of file