Apply a function to each row of a matrix. If the function returns a scalar, then return a vector. If the function returns a vector, return a matrix with the same number of rows.
apply_rowwise(A, .f, ...)A matrix.
A function taking a vector as a first argument. This function should preferably return a vector of the same length as the first argument.
Other arguments passed to .f.
In case .f returns a vector of length n, a matrix with
nrow(A) rows and n columns is returned. If .f returns
a scalar, a vector with nrow(A) elements is returned.