title: composing numpy array with strides
body: <p>I have an array <code>A1_ijk</code> and want to broadcast it to <code>A2_ijmnk</code>, but only for the case when <code>m=n</code>. Otherwise <code>A2</code> should be filled with zeros. Of course i can create new empty array and fill it with <code>A1</code> like this:</p>
  
  <pre><code>import numpy as np
  A1 = np.random.rand(100, 5, 3)
  A2 = np.zeros((100, 5, 2, 2, 3))
  A2[..., 0, 0, :] = A1
  A2[..., 1, 1, :] = A1
  </code></pre>
  
  <p>I feel however that this can be done in more efficient way. I tried <code>as_strided</code>:</p>
  
  <pre><code>as_strided = np.lib.stride_tricks.as_strided
  sz = A1.itemsize
  A2 = as_strided(A1, shape=(100,5,2,2,3), strides=(5*3*sz, 3*sz, 0, 0, sz))
  </code></pre>
  
  <p>and also <code>broadcast_to</code>:</p>
  
  <pre><code>broadcast_to = np.lib.stride_tricks.broadcast_to
  A2=broadcast_to(A1[...,None,None,:], (100,5,2,2,3))
  </code></pre>
  
  <p>Unfortunately both methods fill all <code>m, n</code> pairs with <code>A1</code> values. </p>
  
  <p>My question is if this is possible to create the array of the shape i need using strides and without actual copying data?</p>