Hello, I have a problem with arrays. R generates almost identical C matrices from a certain point when I try to compare the elements of B and D matrices. The code seems to work correctly. Could this be a problem with numbers that are too large? Here is the code
#Matrix B
k_1<-6
n_1<-175
B<-matrix(rep(0,n_1*k_1), nrow = k_1)
for (k in 1:k_1) {
for (n in 1:n_1) {
if (n<=(max(2,k-1)+1)) {
B[k,n]<-1
} else {
B[k,n]<-B[k,n-3]+B[k,n-k]
}
}
}
#Matrix D
l<-list()
s<-1
D<-matrix(rep(0,25*k_1), nrow = k_1)
for (j in 1:6) {
for (i in 1:6) {
for (k in 1:k_1) {
for (n in 1:25) {
if (n==1){
D[k,n]<-B[k,i]
} else {
D[k,n]<-B[k,(1+j)*n-(2*j+1)+i+j]+D[k,n-1]
}
}
}
l[[s]]<-D
s<-s+1
}
}
# Matrix C
C<-matrix(rep(0,25*k_1), nrow = k_1)
l1<-list()
for (i in 1:(length(l))) {
D1<-l[[i]]
for (k in 1:k_1) {
for (n in 1:25) {
for (t in 1:n_1) {
if (n<=t) {
if (D1[k,n]==B[k,t]-1){
C[k,n]<-t
}
}
}
}
}
l1[[i]]<-C
}