#pragma once #include "./utils/matrix.h" namespace numerics{ template void inplace_matclip_high(utils::Matrix& A, T high){ uint64_t rows = A.rows(); uint64_t cols = A.cols(); for (uint64_t i = 0; i < rows; ++i){ for (uint64_t j = 0; j < cols; ++j){ if (A(i,j) > high){ A(i,j) = high; } } } } template void inplace_matclip_low(utils::Matrix& A, T low){ uint64_t rows = A.rows(); uint64_t cols = A.cols(); for (uint64_t i = 0; i < rows; ++i){ for (uint64_t j = 0; j < cols; ++j){ if (A(i,j) < low){ A(i,j) = low; } } } } template void inplace_matclip(utils::Matrix& A, T low, T high){ uint64_t rows = A.rows(); uint64_t cols = A.cols(); for (uint64_t i = 0; i < rows; ++i){ for (uint64_t j = 0; j < cols; ++j){ if (A(i,j) > high){ A(i,j) = high; }else if (A(i,j) < low){ A(i,j) = low; } } } } template utils::Matrix matclip_high(const utils::Matrix& A, Td high){ utils::Matrix B = A; inplace_matclip_high(B, high); return B; } template utils::Matrix matclip_low(const utils::Matrix& A, Td low){ utils::Matrix B = A; inplace_matclip_low(B, low); return B; } template utils::Matrix matclip(const utils::Matrix& A, Td low, Td high){ utils::Matrix B = A; inplace_matclip(B, low, high); return B; } } // namespace numerics