/* * call-seq: * dtable.reverse_cols -> a_dtable * * Returns a copy of _dtable_ with the order of columns reversed. */ VALUE dtable_reverse_cols(VALUE ary) { Dtable *d = Get_Dtable(ary); int i, j, num_cols = d->num_cols, num_rows = d->num_rows, last_col = num_cols - 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[i][last_col-j] = src[i][j]; } } return new; }