#pragma once

#include "./utils/matrix.h"

namespace numerics{
	
	template <typename T>
	T matmax(const utils::Matrix<T>& 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 <typename T>
	utils::Vector<T> matmax(const utils::Matrix<T>& A, std::string method){

		utils::Vector<T> 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

