A vectorized function is a basic MATLAB coding concept. It refers to a function that operates on each element of an array independently, rather than treating the array as a matrix and using matrix math.
All user-supplied function in Rave must be vectorized. When Rave needs to evaluate multiple points using your functions, it sends all of those points to your function as an array in which each row of the array represents one point to be evaluated.
Vectorizing a simple function in MATLAB usually entails replacing:
- * with .*
- / with ./
- ^ with .^
The . in front of these operators tells MATLAB to apply the operator to each element of the array instead of treating the array like a matrix and using matrix math operations. Note that the + and - operators do not require a . since matrix addition and subtraction already operates on each element individually. Similarly, most other built-in MATLAB functions do not require special vectorization. Examples include exp(), log(), and all the trig functions.
For example, the function y = sin(x1)*x2^2 would be coded in MATLAB as y = sin(x1).*x2.^2
See the MATLAB Documentation for more details.