sumEval {lazy.symbolic} | R Documentation |
This function converts the summation to sum and evaluates it.
s(exp[i],{i,1,3}) -> exp[1]+exp[2]+exp[3]
sumEval(sexp, values = NULL, eval = 1, debug = 0)
sexp |
An expression containing summation: s( body, sub,from,to ) |
values |
replacement pattern for the ranges of subscripts |
eval |
= 0 to leave Sigma notation |
debug |
= 1 to print the intermediate result |
For each summation found, replace it by its expansion as Sum. The replacement proceeds from the bottom to top levels.
sumEval( "s(s(a[i,j],{i,1,ni}),{j,1,nj})" , values="ni=2; nj=3")
( sexp=mat2sum("A%*%v",simple=0) )
sumEval( sexp, values="ncol(A)=3" )