Multiplication Operation on Matrices

Learn how to multiply matrices using R, Rcpp, Armadillo, and Eigen.

Matrix multiplication is defined element by element as:

𝐢=π΄βˆ—π΅πΆ = π΄βˆ—π΅

cij=βˆ‘k=1pπ‘Žπ‘–π‘˜π‘π‘˜π‘—c_{ij} = \displaystyle\sum_{k=1}^pπ‘Ž_{π‘–π‘˜}𝑏_{π‘˜π‘—}

In this equation:

  • 𝐴𝐴 has (π‘šΓ—π‘)(π‘š \times 𝑝) dimensions
  • 𝐡𝐡 has (𝑝×𝑛)(𝑝 \times 𝑛) dimensions

Note: The inner dimensions of matrix multiplicationβ€”the number of columns in the first matrix and the number of rows in the second oneβ€”must be equal.

Get hands-on with 1400+ tech skills courses.