aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/math/Matrix.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/math/Matrix.h')
-rw-r--r--meowpp/math/Matrix.h15
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)];