/* * call-seq: * dtable.reverse_rows -> a_dtable * * Returns a copy of _dtable_ with the order of rows reversed. */ VALUE dtable_reverse_rows(VALUE ary) { Dtable *d = Get_Dtable(ary); int i, j, num_cols = d->num_cols, num_rows = d->num_rows, last_row = num_rows - 1; VALUE new = dtable_init(dtable_alloc(cDtable), num_cols, num_rows); Dtable *d2 = Get_Dtable(new); double **src, **dest; src = d->ptr; dest = d2->ptr; for (i = 0; i < num_rows; i++) { for (j = 0; j < num_cols; j++) { dest[last_row-i][j] = src[i][j]; } } return new; }