trind_generator {dsfa}R Documentation

Trind_generator function

Description

Generates index matrices for upper triangular storage up to order four.

Usage

trind_generator(K)

Arguments

K

integer; determines the number of parameters.

Details

Useful when working with higher order derivatives, which generate symmetric arrays. Mainly intended for internal use. Similar to 'mgcv::trind.generator'. Mostly internal function.

Value

Returns a list with index matrices for the first to fourth derivative, which can be accessed via the function trind(). The numerical vectors i_start and i_end hold the starting and ending indexes, which are required by trind() for derivatives greater than two.

See Also

Other derivs: chainrule(), derivs_transform(), differencerule(), ind2joint(), list2derivs(), productrule(), quotientrule(), sumrule(), trind()

Examples

tri<-trind_generator(3)
tri_mgcv<-mgcv::trind.generator(3)

for(i in 1:3){
  print(i==trind(tri, part_deriv_var=c(i)-1)+1)
  for(j in i:3){
    print(tri_mgcv$i2[i,j]==trind(tri, part_deriv_var=c(i,j)-1)+1)
    for(k in j:3){
      print(tri_mgcv$i3[i,j,k]==trind(tri, part_deriv_var=c(i,j,k)-1)+1)
      for(l in k:3){
        print(tri_mgcv$i4[i,j,k,l]==trind(tri, part_deriv_var=c(i,j,k,l)-1)+1)
      } 
    } 
  }
}


[Package dsfa version 2.0.1 Index]