Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to multiply an array by each element of another array, and am having a lot of trouble finding a built-in or automated method of doing.

Here is an example of what I'd like to achieve:

a = 0.5;
b = 4.0;

mat = {{0, 1}, {a, b}};
Rmat = RandomInteger[10, {4, 4}]
m11 = mat[[1, 1]]*Rmat;
m12 = mat[[1, 2]]*Rmat;
m21 = mat[[2, 1]]*Rmat;
m22 = mat[[2, 2]]*Rmat;

fmat = ArrayFlatten[{{m11, m12}, {m21, m22}}]

As you can see, the first matrix mat is multiplied by each individual element of Rmat. I feel like this should be easy, but I'm not finding a built-in function that works?


share|improve this question

2 Answers 2

ArrayFlatten[Outer[Times, mat, Rmat]]
share|improve this answer
Those both work thanks! –  gKirkland Mar 7 '14 at 4:16
@rasher...good old Outer,+1 –  ubpdqn Mar 7 '14 at 4:45

Try this:

ArrayFlatten[Map[Rmat*# &, mat, {2}]]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.