diff --git a/quicktex/Matrix.h b/quicktex/Matrix.h index 5eb0ac6..2c99b62 100644 --- a/quicktex/Matrix.h +++ b/quicktex/Matrix.h @@ -20,6 +20,7 @@ #pragma once #include +#include #include "Vec.h" @@ -43,8 +44,27 @@ template class Matrix : Vec, M> { std::array get_column_ptrs(size_t index) const { std::array ptrs; - for (unsigned i = 0; i < M; i++) { ptrs[i] = &(row(i)[index]); } + for (unsigned m = 0; m < M; m++) { ptrs[m] = &(row(m)[index]); } return ptrs; } + + Matrix transpose() { + Matrix res; + for (unsigned m = 0; m < M; m++) { res.set_column(m, row(m)); } + return res; + } }; + +/** + * Extension of Matrix with some helper aliases for use as a vector of channels + */ +template class ChannelSet : Matrix { + Vec &channel(size_t m) { return this->row(m); } + const Vec &channel(size_t m) const { return this->row(m); } + + Vec get_pixel(size_t n) { return this->get_column(n); } + + void set_pixel(size_t n, const Vec &pixel) { this->set_column(n, pixel); } +}; + } // namespace quicktex \ No newline at end of file