This question is related to a question I asked before
Matrix and vector multiplication operation in R
Specifically, I feel painful to do some matrix operations in R. For example, for the following code, there are couple of additional steps for me to make it run.
e=A %*% x - b
v=t(e) %*% e
I'm not optimistic that you're going to find you what you want, and trying to work around the idiom of a language - rather than sucking it up/adapting to it - is often a recipe for continuing pain. A few thoughts:
drop(v)have the same effect
c(v)is terser and
drop(v)is (perhaps) semantically clearer
optimx::optimx) doesn't complain about being handed a column vector (in R terms, a 1-column matrix), and works the same as in your example
crossprod(e)is equivalent to (and faster than)
t(e) %*% e
You could use MATLAB (you haven't told us why you're using R), or (if you can't afford it) try Octave ...