I'm working the same problem for sparse matrices, so having a dense solution is my first step. As with the matrix * vector example, where a "temporary matrix" is formed by duplicating the vector and then multiplying coincident elements and add_reduce() to form the answer, our goal is to multiply coincident elements of a 3-D container and add_reduce() to obtainthe2-D matrix answer.

Example: A . B = C

My first cut is to duplicate B as n pages, n = B.num_rows(). This is our first cube. Then we need A duplicated as n pages, n = B.num_cols(), but unfortunately these pagesneed to benormal to the column axis so we have to form this cube another way. I chose to serialize the entries, duplicate itwithout collating, and reshape intoa cube. Then multiply the cubes' entiries and add_reduce() along the row axis. Example code...

dense A = dense::parse("{{1.,2.},{3.,4.}}");

dense B = dense::parse("{{1.,2.,3.},{4.,5.,6.}}");

dense B3 = repeat_page(B, B.num_rows());

dense A3 = reshape(repeat(A.flatten(), B.num_cols(), false), B.num_cols(), B.num_rows(), B.num_rows());

dense ans = add_reduce(A3*B3, 1); //should be{{9,12,15},{19,26,33}}

Anyone else? Note,the quotes around "temporary matrix" (above) are to indicate ArBB optimizes such that usuallyonly part of theconceptual matrix is realized in memory at any time.

- paul

## Multiplying dense matricies

What is the recommended (optimised) way of multiplying 2 matrices?I've seen the matrix * vector example - not sure how to extend that to the full matrix *matrix case.thanks.....