The R Project SVN R

Rev

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

Rev 48574 Rev 50989
Line 372... Line 372...
372
    SEXP ans;
372
    SEXP ans;
373
    R_len_t len;
373
    R_len_t len;
374
 
374
 
375
    checkArity(op, args);
375
    checkArity(op, args);
376
 
376
 
377
    if( isObject(CAR(args)) && DispatchOrEval(call, op, "length", args,
377
    if(isObject(CAR(args)) && DispatchOrEval(call, op, "length", args,
378
					      rho, &ans, 0, 1))
378
					     rho, &ans, 0, 1))
379
      return(ans);
379
      return(ans);
380
 
380
 
381
    len = length(CAR(args));
381
    len = length(CAR(args));
382
    return ScalarInteger((len <= INT_MAX) ? len : NA_INTEGER);
382
    return ScalarInteger((len <= INT_MAX) ? len : NA_INTEGER);
383
}
383
}
Line 639... Line 639...
639
	else if (PRIMVAL(op) == 1) { /* crossprod() */
639
	else if (PRIMVAL(op) == 1) { /* crossprod() */
640
	    if (LENGTH(x) == nry) {	/* x is a col vector */
640
	    if (LENGTH(x) == nry) {	/* x is a col vector */
641
		nrx = nry; /* == LENGTH(x) */
641
		nrx = nry; /* == LENGTH(x) */
642
		ncx = 1;
642
		ncx = 1;
643
	    }
643
	    }
-
 
644
	    /* else if (nry == 1) ... not being too tolerant
-
 
645
	       to treat x as row vector, as t(x) *is* row vector */
644
	}
646
	}
645
	else { /* tcrossprod */
647
	else { /* tcrossprod */
646
	    if (LENGTH(x) == ncy) {	/* x as row vector */
648
	    if (LENGTH(x) == ncy) {	/* x as row vector */
647
		nrx = 1;
649
		nrx = 1;
648
		ncx = ncy; /* == LENGTH(x) */
650
		ncx = ncy; /* == LENGTH(x) */
649
	    }
651
	    }
-
 
652
	    else if (ncy == 1) {	/* x as col vector */
-
 
653
		nrx = LENGTH(x);
-
 
654
		ncx = 1;
-
 
655
	    }
650
	}
656
	}
651
    }
657
    }
652
    else if (ldy != 2) {		/* y not a matrix */
658
    else if (ldy != 2) {		/* y not a matrix */
653
	nrx = INTEGER(xdims)[0];
659
	nrx = INTEGER(xdims)[0];
654
	ncx = INTEGER(xdims)[1];
660
	ncx = INTEGER(xdims)[1];
655
	nry = 0;
661
	nry = 0;
656
	ncy = 0;
662
	ncy = 0;
657
	if (PRIMVAL(op) == 0) {
663
	if (PRIMVAL(op) == 0) {
658
	    if (LENGTH(y) == ncx) {	/* y as col vector */
664
	    if (LENGTH(y) == ncx) {	/* y as col vector */
659
		nry = ncx; /* == LENGTH(y) */
665
		nry = ncx;
660
		ncy = 1;
666
		ncy = 1;
661
	    }
667
	    }
662
	    else if (ncx == 1) {	/* y as row vector */
668
	    else if (ncx == 1) {	/* y as row vector */
663
		nry = 1;
669
		nry = 1;
664
		ncy = LENGTH(y);
670
		ncy = LENGTH(y);
665
	    }
671
	    }
666
	}
672
	}
667
	else { /* (t)crossprod */
673
	else if (PRIMVAL(op) == 1) { /* crossprod() */
668
	    if (LENGTH(y) == nrx) {	/* y is a col vector */
674
	    if (LENGTH(y) == nrx) {	/* y is a col vector */
669
		nry = nrx; /* == LENGTH(y) */
675
		nry = nrx;
670
		ncy = 1;
676
		ncy = 1;
671
	    }
677
	    }
672
	}
678
	}
-
 
679
	else { /* tcrossprod --		y is a col vector */
-
 
680
	    nry = LENGTH(y);
-
 
681
	    ncy = 1;
-
 
682
	}
673
    }
683
    }
674
    else {				/* x and y matrices */
684
    else {				/* x and y matrices */
675
	nrx = INTEGER(xdims)[0];
685
	nrx = INTEGER(xdims)[0];
676
	ncx = INTEGER(xdims)[1];
686
	ncx = INTEGER(xdims)[1];
677
	nry = INTEGER(ydims)[0];
687
	nry = INTEGER(ydims)[0];