diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-27 18:24:38 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-27 18:24:38 +0800 |
commit | 40acf9ddc8f700b45d05bb2098be23a93c3bfa6a (patch) | |
tree | 8ef3481d1f08c91eb6d7bb302dbcd3a3c0f18411 /meowpp/math/Matrix.h | |
parent | fa36aaf4f89f4deb5889bf76cfaf3debea5ed55c (diff) | |
download | meow-40acf9ddc8f700b45d05bb2098be23a93c3bfa6a.tar.gz meow-40acf9ddc8f700b45d05bb2098be23a93c3bfa6a.tar.zst meow-40acf9ddc8f700b45d05bb2098be23a93c3bfa6a.zip |
fix dimension size error
Diffstat (limited to 'meowpp/math/Matrix.h')
-rw-r--r-- | meowpp/math/Matrix.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/meowpp/math/Matrix.h b/meowpp/math/Matrix.h index 94f23a3..c50a910 100644 --- a/meowpp/math/Matrix.h +++ b/meowpp/math/Matrix.h @@ -43,6 +43,11 @@ private: size_t index(size_t r, size_t c) const { return r * cols_ + c; } + + void realSize() { + std::vector<Entry> tmp(entries_); + entries_.swap(tmp); + } }; Self<Myself> const self; @@ -192,6 +197,16 @@ public: return rows() * cols(); } + /*! + * @brief free the memory + */ + void clear() { + self()->rows_ = 0; + self()->cols_ = 0; + self()->entries_.clear(); + self()->realSize(); + } + //! @brief Access the entry at \a r x \a c Entry entry(size_t r, size_t c) const { return self->entries_[self->index(r, c)]; |