Hi,
Suppose I have an array with dimensions (m*n, m*n), and I would like to
set certain size (n,n) blocks of this array to contain the same rows
(motivation: the matrix is a continuous-time Markov transition matrix).
What is the idiomatic loopless solution?
I came up with (toy example)
a = zeros(4,6)
broadcast!(identity, sub(a, 1:2, 1:3), [0.1 0.2 0.3])
broadcast!(identity, sub(a, 2+(1:2), 3+(1:3)), [0.1 0.2 0.3])
which does give me an
4x6 Array{Float64,2}:
0.1 0.2 0.3 0.0 0.0 0.0
0.1 0.2 0.3 0.0 0.0 0.0
0.0 0.0 0.0 0.1 0.2 0.3
0.0 0.0 0.0 0.1 0.2 0.3
array, so this works fine in practice and is not too convoluted either,
but I am wondering if I missed some syntax of the
a[1:n, 1:n] = ...
form that would do this (without repmat, of course; that would defeat
the purpose).
Best,
Tamas