implementation of matlab-style max and min methods