# R/sensitivity.R In gripp: General Inverse Problem Platform

#### Documented in sensitivity

```# Function to calculate the sensitivity matrix
#
#' @export
sensitivity <- function(parm_s)
{
nn <- length(.GlobalEnv\$file_name)
#
#
change_parm(.GlobalEnv\$folder_name,.GlobalEnv\$file_name,.GlobalEnv\$parm_name,.GlobalEnv\$line_number,.GlobalEnv\$parm_type,.GlobalEnv\$parm_vector,parm_s,.GlobalEnv\$attrib_str,.GlobalEnv\$isitR)
#
# running the command
if(.GlobalEnv\$command_folder!='wd')
{
if (.GlobalEnv\$isitR==TRUE)
{my<-eval(parse(text=paste(".GlobalEnv\$my",.GlobalEnv\$command,sep='')))
eval(parse(text=my))
}else{system(paste(.GlobalEnv\$command_folder,'/',.GlobalEnv\$command,sep=''))}
}else{
if (.GlobalEnv\$isitR==TRUE)
{my<-eval(parse(text=paste(".GlobalEnv\$my",.GlobalEnv\$command,sep='')))
eval(parse(text=my))
}else{system(.GlobalEnv\$command)}
}
#
# reading the results after running the command
# only needed if the function is not a R routine
if (.GlobalEnv\$isitR==FALSE)
{if(.GlobalEnv\$result_folder!='wd')
}
sensitivity <- matrix(ncol=nn,nrow=mm)
parm_dif <- .GlobalEnv\$parm_max - .GlobalEnv\$parm_min
parm_max1 <- parm_s + (.GlobalEnv\$ppdif / 100) * parm_dif
parm_min1 <- parm_s - (.GlobalEnv\$ppdif / 100) * parm_dif
i_sn <- 1
while(i_sn<=nn)
{
auxi<-parm_s
# change all parameters and auxi[i_sn] to parm_max1[i_sn]
auxi[i_sn] <- parm_max1[i_sn]
change_parm(.GlobalEnv\$folder_name,.GlobalEnv\$file_name,.GlobalEnv\$parm_name,.GlobalEnv\$line_number,.GlobalEnv\$parm_type,.GlobalEnv\$parm_vector,auxi,.GlobalEnv\$attrib_str,.GlobalEnv\$isitR)
# running the command
if(.GlobalEnv\$command_folder!='wd')
{
if (.GlobalEnv\$isitR==TRUE)
{my<-eval(parse(text=paste(".GlobalEnv\$my",.GlobalEnv\$command,sep='')))
eval(parse(text=my))
}else{system(paste(.GlobalEnv\$command_folder,'/',.GlobalEnv\$command,sep=''))}
}else{
if (.GlobalEnv\$isitR==TRUE)
{my<-eval(parse(text=paste(".GlobalEnv\$my",.GlobalEnv\$command,sep='')))
eval(parse(text=my))
}else{system(.GlobalEnv\$command)}
}
#
# reading the results after running the command
# only needed if the function is not a R routine
if (.GlobalEnv\$isitR==FALSE)
{if(.GlobalEnv\$result_folder!='wd')
}
# change all parameters and auxi[i_sn] to parm_min[i_sn]
auxi[i_sn] <- parm_min1[i_sn]
change_parm(.GlobalEnv\$folder_name,.GlobalEnv\$file_name,.GlobalEnv\$parm_name,.GlobalEnv\$line_number,.GlobalEnv\$parm_type,.GlobalEnv\$parm_vector,auxi,.GlobalEnv\$attrib_str,.GlobalEnv\$isitR)
# running the command
if(.GlobalEnv\$command_folder!='wd')
{
if (.GlobalEnv\$isitR==TRUE)
{my<-eval(parse(text=paste(".GlobalEnv\$my",.GlobalEnv\$command,sep='')))
eval(parse(text=my))
}else{system(paste(.GlobalEnv\$command_folder,'/',.GlobalEnv\$command,sep=''))}
}else{
if (.GlobalEnv\$isitR==TRUE)
{my<-eval(parse(text=paste(".GlobalEnv\$my",.GlobalEnv\$command,sep='')))
eval(parse(text=my))
}else{system(.GlobalEnv\$command)}
}
#
# reading the results after running the command
# only needed if the function is not a R routine
if (.GlobalEnv\$isitR==FALSE)
{if(.GlobalEnv\$result_folder!='wd')
}
#
# change everything back to original value (parm[i_sn])
change_parm(.GlobalEnv\$folder_name,.GlobalEnv\$file_name,.GlobalEnv\$parm_name,.GlobalEnv\$line_number,.GlobalEnv\$parm_type,.GlobalEnv\$parm_vector,parm_s,.GlobalEnv\$attrib_str,.GlobalEnv\$isitR)
j_sn <- 1
while(j_sn<=mm)
{