Added _vectorized decorator to handle scalars and multi-dimensional element-wise calculations.