From 6e39d531ed36d043e6f6fee6befca2be00fd3f57 Mon Sep 17 00:00:00 2001 From: ancarola Date: Sun, 30 Jun 2019 22:21:54 +0200 Subject: Optimized matrix section - Vector iterators: allow to iterate on rows, columns or diagonals - Transposition doesn't affect allocated space, O(1) --- include/mm/experiments/old.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 include/mm/experiments/old.hpp (limited to 'include/mm/experiments/old.hpp') diff --git a/include/mm/experiments/old.hpp b/include/mm/experiments/old.hpp new file mode 100644 index 0000000..939f335 --- /dev/null +++ b/include/mm/experiments/old.hpp @@ -0,0 +1,58 @@ +#pragma once + + +/* + +template +mm::basic_matrix::basic_matrix( + const mm::basic_matrix& other +) : data(other.data) {} + +template +mm::basic_matrix::basic_matrix( + mm::basic_matrix&& other +) : data(std::forward(other.data)) {}*/ + + +/* member functions */ + +/*template +T& mm::basic_matrix::at(std::size_t row, std::size_t col) { + assert(row < Rows); // "out of row bound" + assert(col < Cols); // "out of column bound" + + return data[row * Cols + col]; +} + +template +const T& mm::basic_matrix::at(std::size_t row, std::size_t col) const { + assert(row < Rows); // "out of row bound" + assert(col < Cols); // "out of column bound" + + return data[row * Cols + col]; +} + +template +auto mm::basic_matrix::operator[](std::size_t index) { + if constexpr (is_row_vec() || is_col_vec()) { + return data.at(index); + } else { + return mm::row_iterator(*this, static_cast(index)); + + //return row_vec( + // data.cbegin() + (index * Cols), + // data.cbegin() + ((index + 1) * Cols) + 1 + ); + } +}*/ + +/*template +mm::basic_matrix mm::basic_matrix::transposed() const { + mm::basic_matrix result; + + for (unsigned row = 0; row < M; row++) + for (unsigned col = 0; col < N; col++) + result.at(col, row) = this->at(row, col); + + return result; +}*/ -- cgit v1.2.1