mat2sum {lazy.symbolic} R Documentation

## Express the i-j element of an Matrix Expression using Summation Operators

### Description

Express the i-j element of an Matrix Expression using Summation Operators

### Usage

```mat2sum(
exp,
row = "i",
col = "j",
root = "s",
simple = 1,
expand = 1,
print = 0,
debug = 0
)
```

### Arguments

 `exp` An full symbplic matrix expression `row` row subscript name `col` column subscript name `root` root of the intermediate subscripts `simple` = 0 to use full spec: subscript, from , to `expand` = 0 not to expand (A+B) or (A*B) etc. `print` = 1 to print the result `debug` = 1 to print the intermediate result

### Details

The summation of an expression over subscript k is expressed as
` s( exp, {k} )`
or
` s( exp, {k, from, to} ) `

The lowercase object is treated as a column vector. (See examples below.)

When row="i" and col="j":

``` mat2sum( "A %*% B" ) -> s(A[i,s1]*B[s1,j], {s1})
mat2sum( "A %*% B", root="z" ) -> s(A[ij,z1]*B[z1,j], {z1})
mat2sum( "A %*% B", simple=0 ) -> s(A[i,s1]*B[s1,j], {s1,1,ncol(A)})
mat2sum( "t(A) %*% B" ) -> s(A[s1,i]*B[s1,j], {s1})
mat2sum( "A %*% t(B)" ) -> s(A[i,s1]*B[j,s1], {s1})
mat2sum( "A %*%Diag(B)%*%C" ) -> s(A[i,s1]*B[s1,s1]*C[s1,j],{s1})
mat2sum( "A %*% b" ) -> s(A[i,s1]*b[s1],{s1})
mat2sum( "t(a) %*% B" ) -> s(a[s1]*B[s1,j],{s1})
```

Use paremtheses to mark Hadamar and Kronecker products.

The resulting summation expression can be expanded and evaluated by ExlandSum function. (lazy.symbolic2 package is required.)

### Examples

```mat2sum( "A %*% B" )
mat2sum( "A %*% B", root="z" )
mat2sum( "A %*% B", simple=0 )
mat2sum( "t(A) %*% B" )
mat2sum( "A %*% t(B)" )
mat2sum( "A %*%Diag(B)%*%C" )
mat2sum( "A %*% b" )
mat2sum( "t(a) %*% B" )
mat2sum( "a %*% t(b)" )
mat2sum( "A%*%(B+C)" )
mat2sum( "A%*%(B+C)", expand=0 )

exp="t(A)%*%t(B)%*%C - D%*%t(E)"
mat2sum( exp )
exp="A%*%diag(B)%*%C - diag(D)%*%E%*%diag(F)%*%G + diag(H)"
mat2sum( exp )

sexp0=mat2sum( "A%*%(B+C)", expand=0 )
sexp=mat2sum( "A%*%(B+C)" )
sexpe=Expand(c(sexp0,sexp))
Print(sexp0,sexp,sexpe)

```

[Package lazy.symbolic version 0.1.3 Index]