title: Apply a function to every row of a matrix or a data frame
body: <p>Suppose I have a n by 2 matrix and a function that takes a 2-vector as one of its arguments. I would like to apply the function to each row of the matrix and get a n-vector. How to do this in R?</p>
  
  <p>For example, I would like to compute the density of a 2D standard Normal distribution on three points:</p>
  
  <pre><code>bivariate.density(x = c(0, 0), mu = c(0, 0), sigma = c(1, 1), rho = 0){
      exp(-1/(2*(1-rho^2))*(x[1]^2/sigma[1]^2+x[2]^2/sigma[2]^2-2*rho*x[1]*x[2]/(sigma[1]*sigma[2]))) * 1/(2*pi*sigma[1]*sigma[2]*sqrt(1-rho^2))
  }
  
  out &lt;- rbind(c(1, 2), c(3, 4), c(5, 6))
  </code></pre>
  
  <p>How to apply the function to each row of <code>out</code>?</p>
  
  <p>How to pass values for the other arguments besides the points to the function in the way you specify? </p>