diff --git a/libs/geom/include/psemek/geom/matrix.hpp b/libs/geom/include/psemek/geom/matrix.hpp index 0d2a6d4b..83606b4a 100644 --- a/libs/geom/include/psemek/geom/matrix.hpp +++ b/libs/geom/include/psemek/geom/matrix.hpp @@ -235,4 +235,28 @@ namespace psemek::geom return r; } + template + auto by_rows(vector const & v, Rows const & ... rows) + { + vector m[] = {v, rows...}; + + matrix result; + for (std::size_t i = 0; i < result.rows; ++i) + for (std::size_t j = 0; j < result.columns; ++j) + result[i][j] = m[i][j]; + return result; + } + + template + auto by_columns(vector const & v, Columns const & ... columns) + { + vector m[] = {v, columns...}; + + matrix result; + for (std::size_t i = 0; i < result.rows; ++i) + for (std::size_t j = 0; j < result.columns; ++j) + result[i][j] = m[j][i]; + return result; + } + }