Multiplication of matrix in to a vector in R -


i have matrix m , vector v. multiply matrix m vetcor vand matrix whith same dimension m means multiply first element of m v , .... how can in r?

    m = matrix(c(1, 2, 3, 4, 5), ncol=1)     v = c(1, 2, 3, 4, 5)     > z       [,1]  [1,]    1  [2,]    4  [3,]    9  [4,]   16  [5,]   25 

cross products can obtained using %*% operator:

> m = matrix(c(1, 2, 3, 4, 5), ncol=1) >     v = c(1, 2, 3, 4, 5)  > m %*% v      [,1] [,2] [,3] [,4] [,5] [1,]    1    2    3    4    5 [2,]    2    4    6    8   10 [3,]    3    6    9   12   15 [4,]    4    8   12   16   20 [5,]    5   10   15   20   25 > m * v      [,1] [1,]    1 [2,]    4 [3,]    9 [4,]   16 [5,]   25 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -