I understand that this is convenient, but it creates seven temporary vectors. A while loop might be better. Also, you need to put a comment on what this line does and explain the formula.