The R Project SVN R

Rev

Rev 70352 | Rev 73750 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70352 Rev 73728
Line 209... Line 209...
209
#   define STD_ColumnLabels			\
209
#   define STD_ColumnLabels			\
210
	for (j = jmin; j < jmax ; j++)		\
210
	for (j = jmin; j < jmax ; j++)		\
211
	    MatrixColumnLabel(cl, j, w[j])
211
	    MatrixColumnLabel(cl, j, w[j])
212
 
212
 
213
    _PRINT_INIT_rl_rn;
213
    _PRINT_INIT_rl_rn;
214
    int *x = LOGICAL(sx) + offset;
214
    const int *x = LOGICAL_RO(sx) + offset;
215
 
215
 
216
    _COMPUTE_W_(formatLogical(&x[j * r], (R_xlen_t) r, &w[j]));
216
    _COMPUTE_W_(formatLogical(&x[j * r], (R_xlen_t) r, &w[j]));
217
 
217
 
218
    _PRINT_MATRIX_( , STD_ColumnLabels,
218
    _PRINT_MATRIX_( , STD_ColumnLabels,
219
		   Rprintf("%s", EncodeLogical(x[i + j * r], w[j])));
219
		   Rprintf("%s", EncodeLogical(x[i + j * r], w[j])));
Line 223... Line 223...
223
static void printIntegerMatrix(SEXP sx, int offset, int r_pr, int r, int c,
223
static void printIntegerMatrix(SEXP sx, int offset, int r_pr, int r, int c,
224
			       SEXP rl, SEXP cl, const char *rn, const char *cn,
224
			       SEXP rl, SEXP cl, const char *rn, const char *cn,
225
			       Rboolean print_ij)
225
			       Rboolean print_ij)
226
{
226
{
227
    _PRINT_INIT_rl_rn;
227
    _PRINT_INIT_rl_rn;
228
    int *x = INTEGER(sx) + offset;
228
    const int *x = INTEGER_RO(sx) + offset;
229
 
229
 
230
    _COMPUTE_W_( formatInteger(&x[j * r], (R_xlen_t) r, &w[j]) );
230
    _COMPUTE_W_( formatInteger(&x[j * r], (R_xlen_t) r, &w[j]) );
231
 
231
 
232
    _PRINT_MATRIX_( , STD_ColumnLabels,
232
    _PRINT_MATRIX_( , STD_ColumnLabels,
233
		   Rprintf("%s", EncodeInteger(x[i + j * r], w[j])));
233
		   Rprintf("%s", EncodeInteger(x[i + j * r], w[j])));
Line 236... Line 236...
236
static void printRealMatrix(SEXP sx, int offset, int r_pr, int r, int c,
236
static void printRealMatrix(SEXP sx, int offset, int r_pr, int r, int c,
237
			    SEXP rl, SEXP cl, const char *rn, const char *cn,
237
			    SEXP rl, SEXP cl, const char *rn, const char *cn,
238
			    Rboolean print_ij)
238
			    Rboolean print_ij)
239
{
239
{
240
    _PRINT_INIT_rl_rn;
240
    _PRINT_INIT_rl_rn;
241
    double *x = REAL(sx) + offset;
241
    const double *x = REAL_RO(sx) + offset;
242
    int *d = (int *) R_alloc(c, sizeof(int)),
242
    int *d = (int *) R_alloc(c, sizeof(int)),
243
	*e = (int *) R_alloc(c, sizeof(int));
243
	*e = (int *) R_alloc(c, sizeof(int));
244
 
244
 
245
    _COMPUTE_W_( formatReal(&x[j * r], (R_xlen_t) r, &w[j], &d[j], &e[j], 0) );
245
    _COMPUTE_W_( formatReal(&x[j * r], (R_xlen_t) r, &w[j], &d[j], &e[j], 0) );
246
 
246
 
Line 251... Line 251...
251
static void printComplexMatrix(SEXP sx, int offset, int r_pr, int r, int c,
251
static void printComplexMatrix(SEXP sx, int offset, int r_pr, int r, int c,
252
			       SEXP rl, SEXP cl, const char *rn, const char *cn,
252
			       SEXP rl, SEXP cl, const char *rn, const char *cn,
253
			       Rboolean print_ij)
253
			       Rboolean print_ij)
254
{
254
{
255
    _PRINT_INIT_rl_rn;
255
    _PRINT_INIT_rl_rn;
256
    Rcomplex *x = COMPLEX(sx) + offset;
256
    const Rcomplex *x = COMPLEX_RO(sx) + offset;
257
    int *dr = (int *) R_alloc(c, sizeof(int)),
257
    int *dr = (int *) R_alloc(c, sizeof(int)),
258
	*er = (int *) R_alloc(c, sizeof(int)),
258
	*er = (int *) R_alloc(c, sizeof(int)),
259
	*wr = (int *) R_alloc(c, sizeof(int)),
259
	*wr = (int *) R_alloc(c, sizeof(int)),
260
	*di = (int *) R_alloc(c, sizeof(int)),
260
	*di = (int *) R_alloc(c, sizeof(int)),
261
	*ei = (int *) R_alloc(c, sizeof(int)),
261
	*ei = (int *) R_alloc(c, sizeof(int)),
Line 306... Line 306...
306
static void printRawMatrix(SEXP sx, int offset, int r_pr, int r, int c,
306
static void printRawMatrix(SEXP sx, int offset, int r_pr, int r, int c,
307
			   SEXP rl, SEXP cl, const char *rn, const char *cn,
307
			   SEXP rl, SEXP cl, const char *rn, const char *cn,
308
			   Rboolean print_ij)
308
			   Rboolean print_ij)
309
{
309
{
310
    _PRINT_INIT_rl_rn;
310
    _PRINT_INIT_rl_rn;
311
    Rbyte *x = RAW(sx) + offset;
311
    const Rbyte *x = RAW_RO(sx) + offset;
312
 
312
 
313
    _COMPUTE_W_( formatRaw(&x[j * r], (R_xlen_t) r, &w[j]) )
313
    _COMPUTE_W_( formatRaw(&x[j * r], (R_xlen_t) r, &w[j]) )
314
 
314
 
315
    _PRINT_MATRIX_( , STD_ColumnLabels,
315
    _PRINT_MATRIX_( , STD_ColumnLabels,
316
		   Rprintf("%*s%s", w[j]-2, "", EncodeRaw(x[i + j * r], "")) );
316
		   Rprintf("%*s%s", w[j]-2, "", EncodeRaw(x[i + j * r], "")) );
Line 323... Line 323...
323
{
323
{
324
/* 'rl' and 'cl' are dimnames(.)[[1]] and dimnames(.)[[2]]  whereas
324
/* 'rl' and 'cl' are dimnames(.)[[1]] and dimnames(.)[[2]]  whereas
325
 * 'rn' and 'cn' are the  names(dimnames(.))
325
 * 'rn' and 'cn' are the  names(dimnames(.))
326
 */
326
 */
327
    const void *vmax = vmaxget();
327
    const void *vmax = vmaxget();
-
 
328
    const int *pdim = INTEGER_RO(dim);
328
    int r = INTEGER(dim)[0];
329
    int r = pdim[0];
329
    int c = INTEGER(dim)[1], r_pr;
330
    int c = pdim[1], r_pr;
330
    /* PR#850 */
331
    /* PR#850 */
331
    if ((rl != R_NilValue) && (r > length(rl)))
332
    if ((rl != R_NilValue) && (r > length(rl)))
332
	error(_("too few row labels"));
333
	error(_("too few row labels"));
333
    if ((cl != R_NilValue) && (c > length(cl)))
334
    if ((cl != R_NilValue) && (c > length(cl)))
334
	error(_("too few column labels"));
335
	error(_("too few column labels"));
Line 392... Line 393...
392
	GetMatrixDimnames(x, &rl, &cl, &rn, &cn);
393
	GetMatrixDimnames(x, &rl, &cl, &rn, &cn);
393
	printMatrix(x, 0, dim, quote, 0, rl, cl, rn, cn);
394
	printMatrix(x, 0, dim, quote, 0, rl, cl, rn, cn);
394
    }
395
    }
395
    else { /* ndim >= 3 */
396
    else { /* ndim >= 3 */
396
	SEXP dn, dnn, dn0, dn1;
397
	SEXP dn, dnn, dn0, dn1;
-
 
398
	const int *dims = INTEGER_RO(dim);
397
	int i, j, nb, nb_pr, nr_last,
399
	int i, j, nb, nb_pr, nr_last,
398
	    *dims = INTEGER(dim), nr = dims[0], nc = dims[1],
400
	    nr = dims[0], nc = dims[1],
399
	    b = nr * nc;
401
	    b = nr * nc;
400
	Rboolean max_reached, has_dimnames = (dimnames != R_NilValue),
402
	Rboolean max_reached, has_dimnames = (dimnames != R_NilValue),
401
	    has_dnn = has_dimnames;
403
	    has_dnn = has_dimnames;
402
 
404
 
403
	if (!has_dimnames) {
405
	if (!has_dimnames) {