Vectorise min max

See tracker item 3731 (https://tracker.physiomeproject.org/show_bug.cgi?id=3731).