The R Project SVN R

Rev

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

Rev 48092 Rev 48574
Line 587... Line 587...
587
{
587
{
588
    int ldx, ldy, nrx, ncx, nry, ncy, mode;
588
    int ldx, ldy, nrx, ncx, nry, ncy, mode;
589
    SEXP x = CAR(args), y = CADR(args), xdims, ydims, ans;
589
    SEXP x = CAR(args), y = CADR(args), xdims, ydims, ans;
590
    Rboolean sym;
590
    Rboolean sym;
591
 
591
 
592
    if(PRIMVAL(op) == 0 &&
592
    if(PRIMVAL(op) == 0 && /* %*% is primitive, the others are .Internal() */
593
       (IS_S4_OBJECT(x) || IS_S4_OBJECT(y))
593
       (IS_S4_OBJECT(x) || IS_S4_OBJECT(y))
594
       && R_has_methods(op)) {
594
       && R_has_methods(op)) {
595
	SEXP s, value;
595
	SEXP s, value;
596
	/* Remove argument names to ensure positional matching */
596
	/* Remove argument names to ensure positional matching */
597
	for(s = args; s != R_NilValue; s = CDR(s)) SET_TAG(s, R_NilValue);
597
	for(s = args; s != R_NilValue; s = CDR(s)) SET_TAG(s, R_NilValue);
Line 634... Line 634...
634
	    else if (nry == 1) {	/* x as col vector */
634
	    else if (nry == 1) {	/* x as col vector */
635
		nrx = LENGTH(x);
635
		nrx = LENGTH(x);
636
		ncx = 1;
636
		ncx = 1;
637
	    }
637
	    }
638
	}
638
	}
639
	else { /* 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
	}
644
	}
-
 
645
	else { /* tcrossprod */
-
 
646
	    if (LENGTH(x) == ncy) {	/* x as row vector */
-
 
647
		nrx = 1;
-
 
648
		ncx = ncy; /* == LENGTH(x) */
-
 
649
	    }
-
 
650
	}
645
    }
651
    }
646
    else if (ldy != 2) {		/* y not a matrix */
652
    else if (ldy != 2) {		/* y not a matrix */
647
	nrx = INTEGER(xdims)[0];
653
	nrx = INTEGER(xdims)[0];
648
	ncx = INTEGER(xdims)[1];
654
	ncx = INTEGER(xdims)[1];
649
	nry = 0;
655
	nry = 0;
Line 656... Line 662...
656
	    else if (ncx == 1) {	/* y as row vector */
662
	    else if (ncx == 1) {	/* y as row vector */
657
		nry = 1;
663
		nry = 1;
658
		ncy = LENGTH(y);
664
		ncy = LENGTH(y);
659
	    }
665
	    }
660
	}
666
	}
661
	else {
667
	else { /* (t)crossprod */
662
	    if (LENGTH(y) == nrx) {	/* y is a col vector */
668
	    if (LENGTH(y) == nrx) {	/* y is a col vector */
663
		nry = nrx; /* == LENGTH(y) */
669
		nry = nrx; /* == LENGTH(y) */
664
		ncy = 1;
670
		ncy = 1;
665
	    }
671
	    }
666
	}
672
	}