R-beta: R-0.62.1 under Digital Unix
Albrecht Gebhardt
agebhard at zidsrv.sci.uni-klu.ac.at
Fri Jul 3 13:07:35 CEST 1998
With gdb I get now (breakpoint in seq(), R command was "> 1:3") some
variables:
Note the value of "n" !
################### gdb display: ######################################
(gdb)
10: n = 1079069593
9: *s2 = {sxpinfo = {type = 14, obj = 0, named = 0, gp = 0, mark = 0,
debug = 0, trace = 0, = 0}, attrib = 0x14005a8a0, u = {vecsxp = {
length = 1, type = {c = 0x1408362a0 "", i = 0x1408362a0,
f = 0x1408362a0, z = 0x1408362a0, s = 0x1408362a0}}, primsxp = {
offset = 1}, symsxp = {pname = 0x100000001, value = 0x1408362a0,
internal = 0x14005a8a0}, listsxp = {carval = 0x100000001,
cdrval = 0x1408362a0, tagval = 0x14005a8a0}, envsxp = {
frame = 0x100000001, enclos = 0x1408362a0}, closxp = {
formals = 0x100000001, body = 0x1408362a0, env = 0x14005a8a0},
promsxp = {value = 0x100000001, expr = 0x1408362a0, env =
0x14005a8a0}}}
8: *s1 = {sxpinfo = {type = 14, obj = 0, named = 0, gp = 0, mark = 0,
debug = 0, trace = 0, = 0}, attrib = 0x14005a8a0, u = {vecsxp = {
length = 1, type = {c = 0x140836290 "", i = 0x140836290,
f = 0x140836290, z = 0x140836290, s = 0x140836290}}, primsxp = {
offset = 1}, symsxp = {pname = 0x100000001, value = 0x140836290,
internal = 0x14005a8a0}, listsxp = {carval = 0x100000001,
cdrval = 0x140836290, tagval = 0x14005a8a0}, envsxp = {
frame = 0x100000001, enclos = 0x140836290}, closxp = {
formals = 0x100000001, body = 0x140836290, env = 0x14005a8a0},
promsxp = {value = 0x100000001, expr = 0x140836290, env =
0x14005a8a0}}}
7: n2 = 3
6: n1 = 1
################### end of gdb display ###################################
The display above is the state AFTER the line marked with "--->>"
################### part of src/main/seq.c ###########################
static SEXP seq(SEXP call, SEXP s1, SEXP s2)
{
int i, n, in1;
double n1, n2;
SEXP ans;
n1 = length(s1);
n2 = length(s1);
if(n1 > 1 || n2 > 1) {
n = (n1 > n2) ? n1 : n2;
warningcall(call, "Numerical expression has %d elements:
only the first used\n", n);
}
n1 = asReal(s1);
n2 = asReal(s2);
if (ISNAN(n1) || ISNAN(n2))
errorcall(call, "NA/NaN argument\n");
if (n1 <= INT_MIN || n2 <= INT_MIN || n1 > INT_MAX || n2 > INT_MAX
|| abs(n2 - n1) >= INT_MAX)
errorcall(call, "argument too large in magnitude\n");
--->> n = abs(n2 - n1) + 1 + FLT_EPSILON;
if (n1 == (in1 = (int)(n1))) {
ans = allocVector(INTSXP, n);
if (n1 <= n2)
...
###########################################################################
When the R-Prompt reappears, I get "Error: memory exhausted".
I tried to replace "abs" with "dabs", but the same errors occur.
Then I introduced a double variable "nd" and replaced the above line
with:
nd = abs(n2 - n1) + 1 + FLT_EPSILON;
n = (int)nd;
but nothing changed (nd gets evaluated as 1079069553).
Now I changed "abs" to "fabs", ... and it works !!
The dummy variable "nd" ist not needed at all.
> 1:4
[1] 1 2 3 4
> 2:8
[1] 2 3 4 5 6 7 8
> seq(1,5,length=10)
[1] 1.000000 1.444444 1.888889 2.333333 2.777778 3.222222 3.666667
4.111111
[9] 4.555556 5.000000
Albrecht
------------------------------------------------------------------------------
Albrecht Gebhardt email: albrecht.gebhardt at uni-klu.ac.at
Institut fuer Mathematik Tel. : (++43 463) 2700/837
Universitaet Klagenfurt Fax : (++43 463) 2700/834
Villacher Str. 161 WWW : http://www-stat.uni-klu.ac.at/~agebhard
A-9020 Klagenfurt, Austria
------------------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list