#pragma once #include "./utils/matrix.h" namespace numerics{ template void inplace_matargmax_row(const utils::Matrix& A, utils::Vector& b){ if (b.size() != A.rows()){ b.resize(A.rows(), Ti{0}); } Td value; for (uint64_t i = 0; i < A.rows(); ++i){ value = Td{0}; for (uint64_t j = 0; j < A.cols(); ++j){ if (value < A(i,j)){ value = A(i,j); b[i] = j; } } } } template void inplace_matargmax_col(const utils::Matrix& A, utils::Vector& b){ if (b.size() != A.cols()){ b(A.cols(), Ti{0}); } Td value; for (uint64_t j = 0; j < A.cols(); ++j){ value = Td{0}; for (uint64_t i = 0; i < A.cols(); ++i){ if (value < A(i,j)){ value = A(i,j); b[j] = i; } } } } template utils::Vector matargmax_row(const utils::Matrix& A){ utils::Vector b(A.rows(), Ti{0}); inplace_matargmax_row(A, b); return b; } template utils::Vector matargmax_col(const utils::Matrix& A){ utils::Vector b(A.rows(), Ti{0}); inplace_matargmax_col(A, b); return b; } } // namespace numerics