/**
   * Converts this matrix formated trifocal into a 27 element vector:<br>
   * m.data[ i*9 + j*3 + k ] = T_i(j,k)
   *
   * @param m Output: Trifocal tensor encoded in a vector
   */
  public void convertTo(DenseMatrix64F m) {
    if (m.getNumElements() != 27)
      throw new IllegalArgumentException("Input matrix/vector must have 27 elements");

    for (int i = 0; i < 9; i++) {
      m.data[i] = T1.data[i];
      m.data[i + 9] = T2.data[i];
      m.data[i + 18] = T3.data[i];
    }
  }
  public static long fillArrays(DenseMatrix64F mat, int numTrials) {
    long prev = System.currentTimeMillis();

    for (int i = 0; i < numTrials; i++) {
      Arrays.fill(mat.data, 0, mat.getNumElements(), 2);
    }

    long curr = System.currentTimeMillis();
    return curr - prev;
  }
  public static long fillManual(DenseMatrix64F mat, int numTrials) {
    long prev = System.currentTimeMillis();

    for (int i = 0; i < numTrials; i++) {
      final int size = mat.getNumElements();

      for (int j = 0; j < size; j++) {
        mat.set(j, 2);
      }
    }

    long curr = System.currentTimeMillis();
    return curr - prev;
  }
 /**
  * Returns the number of elements in this matrix, which is equal to the number of rows times the
  * number of columns.
  *
  * @return The number of elements in the matrix.
  */
 public int getNumElements() {
   return mat.getNumElements();
 }