PeriodicDummies { public Matrix matrix(int len) { Matrix m = new Matrix(len, period); DataBlockIterator columns = m.columns(); DataBlock col = columns.getData(); int pos = 0; do { int beg=(pos++)-start; if (beg<0) beg+=period; col.extract(beg, -1, period).set(1); } while (columns.next()); return m; } PeriodicDummies(int period);  PeriodicDummies(int period, int start); Matrix matrix(int len);  }
@Test public void testMatrix() { PeriodicDummies dummies = new PeriodicDummies(5); for (int len = 3; len < 12; ++len) { Matrix matrix = dummies.matrix(len); for (DataBlock row : matrix.rowList()) { assertTrue(row.sum() == 1); }; } }
@Ignore @Test public void testDisplay() { System.out.println(new PeriodicDummies(5).matrix(13)); }