title: How to initialize NumPy array with different default value for each column?
body: <p>I'm trying to initialize a NumPy matrix of size (x,y) where y is very large. </p>
  
  <p>The first column of the matrix is an ID (integer), and the rest are triplets (int8), where each member of the triplet should have a different default value.</p>
  
  <p>i.e. assuming the default values are <code>[2,5,9]</code> I'd like to initialize the following matrix:</p>
  
  <pre><code>0 2 5 9 2 5 9 2 5 9 ...
  0 2 5 9 2 5 9 2 5 9 ...
  0 2 5 9 2 5 9 2 5 9 ...
  0 2 5 9 2 5 9 2 5 9 ...
  ...
  </code></pre>
  
  <p>The fastest way I could think of initializing the matrix is:</p>
  
  <pre><code>defaults = [2, 5, 9]
  mat = numpy.zeros(shape=(x,y),
                    dtype=['i'] + ['int8'] * (y - 1))
  # fill the triplets with default values
  for i in range(1, y/3):
      j = i * 3
      mat[:, j]   = defaults[0]
      mat[:, j+1] = defaults[1]
      mat[:, j+2] = defaults[2]
  </code></pre>
  
  <p>What is the fastest way to initialize such a matrix?</p>
  
  <p>Thanks!</p>