Thanks, that clears everything up completely. It might be worth adding your comment to the available documentation.
On 6/17/13, William Dunlap <wdun...@tibco.com> wrote: > All operators of the form %<something>% have the same precedence, > that of %*%. R does not look at the <something> between the percent > signs to determine the precedence. Hence you must use parentheses > to get the order of operations that you want. > > (I think that %<something>% operators are overused - providing the same > functionality in a standard functional form is often more convenient. It > certainly would eliminate your problem.) > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > >> -----Original Message----- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] >> On Behalf >> Of Rainer Sachs >> Sent: Monday, June 17, 2013 1:20 PM >> To: r-help@r-project.org >> Subject: [R] package expm: matrix powers within a product of matrices: >> operation >> precedence >> >> >> package expm: matrix powers within a product of matrices: operation >> precedence >> >> I want to double check that for M and N kxk mtrices and v a k-vector >> M%^%2%*%N%*%v is not automatically read as (M%^%2)%*%N%*%v or >> M%*%N%^%2%*%v is not automatically read as M%*%(N%^%2)%*%v or >> both >> >> I had been assuming the usual precedence (powers first, then >> multiplication) applies for matrix powers and multiplication in expm. I >> was >> getting unexpected results. In desperation I tried putting in the >> parentheses and seem to be getting much more reasonable answers. But I am >> so >> surprised that the matrix power operation is, apparently, not >> automatically >> given precedence over the matrix multiplication operation that I do not >> trust that adding parentheses has cured my bug. Maybe I am still making >> some >> other mistake instead. Can anyone confirm that in fact the parentheses >> are >> (sometimes?) essential? I could not find any documentation, one way or >> the >> other, just definitions of the power operator and of matrix exponentials. >> >> TIA Rainer K. Sachs, Prof emertitus of math >> >> >> >> >> >> -- >> View this message in context: >> http://r.789695.n4.nabble.com/package-expm-matrix- >> powers-within-a-product-of-matrices-operation-precedence-tp4669733.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.