Hi Brandy,
I'm not sure I haven't misunderstood your question, but its pretty straightforward to put together code in R which illustrates the underlying arithmetic operations for matrix multiplication:
# This function takes row and column dims and creates character
# matrices. Start allows for (row) lettering to pick up from
# where the last ended
symb_mat = function(nrow, ncol, start = 1){
r = letters[start:(nrow+start-1)]
c = 1:ncol
int = interaction(expand.grid(r, c), sep = '')
noquote(matrix(int, ncol = ncol))
}
# This generates another text matrix, pasting in multiplication
# and addition symbols as appropriate
symb_mat_mult = function(a, b){
if (ncol(a) != nrow(b)) {stop('Rows in A must equal columns in B')}
m = matrix(nrow = nrow(a), ncol = ncol(b))
for (r in 1:nrow(a)){
for (c in 1:ncol(b)){
m[r, c] = paste0(mapply(paste0, a[r, ], '*', b[, c]), collapse = '+')
}
}
return(noquote(m))
}
# Demo, as per your example:
A = symb_mat(2, 3)
B = symb_mat(3, 3, start = 3)
print(A)
print(B)
C = symb_mat_mult(A, B)
print(C)
Hope it helps!
------------------------------
Simon Riley
Graduate Assistant (PhD)
University of Florida
------------------------------
Original Message:
Sent: 06-03-2020 09:30
From: Brandy Sinco
Subject: Symbolic Matrix Calculator
Does anyone have recommendations for a reliable online symbolic matrix calculator? For the time being, just matrix multiplication is all I need.
Something that will multiply matrices, such as the example below (commas indicate separate rows):
[a1 a2 a3, b1 b2 b3] * [c1 c2 c3, d1 d2 d3, e1 e2 e3]
Is there an R or Python package that can do this? SAS Proc IML is great for numerical matrices, but doesn't have the capability to multiple symbolic matrices.
------------------------------
Brandy Sinco, BS, MA, MS
Statistician Senior
Michigan Medicine
------------------------------