The R Project SVN R

Rev

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

Rev 41937 Rev 42077
Line 49... Line 49...
49
{
49
{
50
    div_t div_res = div(a, b);
50
    div_t div_res = div(a, b);
51
    return div_res.quot + ((div_res.rem != 0) ? 1 : 0);
51
    return div_res.quot + ((div_res.rem != 0) ? 1 : 0);
52
}
52
}
53
 
53
 
-
 
54
/* moved from printutils.c */
-
 
55
 
-
 
56
static void MatrixColumnLabel(SEXP cl, int j, int w)
-
 
57
{
-
 
58
    int l;
-
 
59
    SEXP tmp;
-
 
60
 
-
 
61
    if (!isNull(cl)) {
-
 
62
        tmp = STRING_ELT(cl, j);
-
 
63
	if(tmp == NA_STRING) l = R_print.na_width_noquote;
-
 
64
	else l = Rstrlen(tmp, 0);
-
 
65
	Rprintf("%*s%s", w-l, "",
-
 
66
		EncodeString(tmp, l, 0, Rprt_adj_left));
-
 
67
    }
-
 
68
    else {
-
 
69
	Rprintf("%*s[,%ld]", w-IndexWidth(j+1)-3, "", j+1);
-
 
70
    }
-
 
71
}
-
 
72
 
-
 
73
static void RightMatrixColumnLabel(SEXP cl, int j, int w)
-
 
74
{
-
 
75
    int l;
-
 
76
    SEXP tmp;
-
 
77
 
-
 
78
    if (!isNull(cl)) {
-
 
79
        tmp = STRING_ELT(cl, j);
-
 
80
	if(tmp == NA_STRING) l = R_print.na_width_noquote;
-
 
81
	else l = Rstrlen(tmp, 0);
-
 
82
	/* This does not work correctly at least on FC3
-
 
83
	Rprintf("%*s", R_print.gap+w,
-
 
84
		EncodeString(tmp, l, 0, Rprt_adj_right)); */
-
 
85
	Rprintf("%*s%s", R_print.gap+w-l, "",
-
 
86
	        EncodeString(tmp, l, 0, Rprt_adj_right));
-
 
87
    }
-
 
88
    else {
-
 
89
	Rprintf("%*s[,%ld]%*s", R_print.gap, "", j+1, w-IndexWidth(j+1)-3, "");
-
 
90
    }
-
 
91
}
-
 
92
 
-
 
93
static void LeftMatrixColumnLabel(SEXP cl, int j, int w)
-
 
94
{
-
 
95
    int l;
-
 
96
    SEXP tmp;
-
 
97
 
-
 
98
    if (!isNull(cl)) {
-
 
99
        tmp= STRING_ELT(cl, j);
-
 
100
	if(tmp == NA_STRING) l = R_print.na_width_noquote;
-
 
101
	else l = Rstrlen(tmp, 0);
-
 
102
	Rprintf("%*s%s%*s", R_print.gap, "",
-
 
103
		EncodeString(tmp, l, 0, Rprt_adj_left), w-l, "");
-
 
104
    }
-
 
105
    else {
-
 
106
	Rprintf("%*s[,%ld]%*s", R_print.gap, "", j+1, w-IndexWidth(j+1)-3, "");
-
 
107
    }
-
 
108
}
-
 
109
 
-
 
110
static void MatrixRowLabel(SEXP rl, int i, int rlabw, int lbloff)
-
 
111
{
-
 
112
    int l;
-
 
113
    SEXP tmp;
-
 
114
 
-
 
115
    if (!isNull(rl)) {
-
 
116
        tmp= STRING_ELT(rl, i);
-
 
117
	if(tmp == NA_STRING) l = R_print.na_width_noquote;
-
 
118
	else l = Rstrlen(tmp, 0);
-
 
119
	Rprintf("\n%*s%s%*s", lbloff, "",
-
 
120
		EncodeString(tmp, l, 0, Rprt_adj_left),
-
 
121
		rlabw-l-lbloff, "");
-
 
122
    }
-
 
123
    else {
-
 
124
	Rprintf("\n%*s[%ld,]", rlabw-3-IndexWidth(i + 1), "", i+1);
-
 
125
    }
-
 
126
}
-
 
127
 
-
 
128
 
54
 
129
 
55
/* This is the first (of 6)  print<TYPE>Matrix()  functions.
130
/* This is the first (of 6)  print<TYPE>Matrix()  functions.
56
 * We define macros that will be re-used in the other functions,
131
 * We define macros that will be re-used in the other functions,
57
 * and comment the common code here (only):
132
 * and comment the common code here (only):
58
*/
133
*/