I have 2 function in R, the first is :
cyii=function(a,b,L)
{
d=outer(a,b,`-`);I=outer(a,b,`==`)
d=d[upper.tri(d,diag=T)];I=I[upper.tri(I,diag=T)]
L[1]^2*exp(-0.25*d^2/L[2]^2) + I*L[3]^2
}
The second function called the first function many time
zii=list()
for(i in 1:(n-1))
{
zii[[i]]=cyii(v1,v1,H[c(5*i-4,5*i-3,5*n-3+i)])
}
Where v1 is any vector of numbers and H is a vector of parameters. Below is a reproducable example.
dput(v1)=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
dput(H)=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
n=3
Is there a possible way to use the apply function or any other in order to avoid using the for loop, given that for every n I need to provide the first function with diffrent values from H