int main(int argc, char** argv) {
  int n, dim;
  double **a;
  double *b;

  if (argc < 2) {
    fprintf(stderr, "Usage: %s n\n", argv[0]);
    exit(1);
  }
  n = atoi(argv[1]);

  dim = matrix_dimension(n);
  a = alloc_dmatrix(dim, dim);
  generate_dense(n, 1.0/n, a);
  b = alloc_dvector(dim);
  generate_rhs(n, 1.0/n, b);

  printf("Matrix A:\n");
  fprint_dmatrix(stdout, dim, dim, a);
  printf("Vector B (transposed):\n");
  fprint_dvector(stdout, dim, b);
  
  free_dmatrix(a);
  free_dvector(b);
}
/**********************************************************************
 * free_matrix
 *
 * Deallocate the memory taken up by a matrix of match ratings.
 *********************************************************************/
void free_matrix(MATRIX matrix) {
  int x;
  int y;
  int dimension = matrix_dimension (matrix);
  CHOICES matrix_cell;

  for (x = 0; x < dimension; x++) {
    for (y = 0; y < dimension; y++) {
      matrix_cell = matrix_get (matrix, x, y);
      if (matrix_cell != NOT_CLASSIFIED)
        free_choices(matrix_cell);
    }
  }
  memfree(matrix);
}
/**********************************************************************
 * print_matrix
 *
 * Print the best guesses out of the match rating matrix.
 **********************************************************************/
void print_matrix(MATRIX rating_matrix) {
  int x;
  int dimension;
  int spread;
  CHOICES rating;

  cprintf ("Ratings Matrix (top choices)\n");

  dimension = matrix_dimension (rating_matrix);
  /* Do each diagonal */
  for (spread = 0; spread < dimension; spread++) {
    /* For each spot */
    for (x = 0; x < dimension - spread; x++) {
      /* Process one square */
      rating = matrix_get (rating_matrix, x, x + spread);

      if (rating != NOT_CLASSIFIED) {
        cprintf ("\t[%d,%d] : ", x, x + spread);
        if (first_node (rating))
          cprintf ("%-10s%4.0f\t|\t",
            class_string (first_node (rating)),
            class_probability (first_node (rating)));
        if (second_node (rating))
          cprintf ("%-10s%4.0f\t|\t",
            class_string (second_node (rating)),
            class_probability (second_node (rating)));
        if (third (rating))
          cprintf ("%-10s%4.0f\n",
            class_string (third (rating)),
            class_probability (third (rating)));
        else
          new_line();
      }
    }
  }
}