#pragma once #include "./utils/matrix.h" namespace numerics{ template T matmax(const utils::Matrix& A){ const uint64_t rows = A.rows(); const uint64_t cols = A.cols(); T max_value(T{0}); for (uint64_t i = 0; i < rows; ++i){ for (uint64_t j = 0; j < cols; ++j){ max_value = numerics::max(max_value, A(i,j)); } } return max_value; } template utils::Vector matmax(const utils::Matrix& A, std::string method){ utils::Vector b; if (method == "cols"){ b.resize(A.cols(), T{0}); for (uint64_t i = 0; i < A.cols(); ++i){ for (uint64_t j = 0; j < A.rows(); ++j){ b[i] = numerics::max(A(j, i), b[i]); } } }else if (method == "rows"){ b.resize(A.rows(), T{0}); for (uint64_t i = 0; i < A.rows(); ++i){ for (uint64_t j = 0; j < A.cols(); ++j){ b[i] = numerics::max(A(i, j), b[i]); } } }else{ throw std::runtime_error("max: choose 'rows or 'cols'"); } return b; } } // namespace numerics