vector and matrix version completed