# generate x, a
x = list(matrix(rnorm(100), nrow = 10),
matrix(rnorm(100), nrow = 10))
a = matrix(rnorm(100), nrow = 10)
# three equivalent forms
rhs1 = rh.seq(x, a)
rhs2 = rh(x[[2]], rh(x[[1]], a))
rhs3 = x[[1]] %*% a %*% t(x[[2]])
# check equality
all.equal(rhs1, rhs2)
all.equal(rhs1, rhs3)
Run the code above in your browser using DataLab