Performance tuning (don't set matrix each time and avoid to create extra
array for result vector)