I would like to implement a matrix that satisfies the conditions shown in the image:
- The matrix is an
m * nmatrix - The
j, kth element will be 1 if either thekth index isj + 1orkth index is 2 or thejth index is 2
Here is my latest code:
self.ylmaxvect = [1, 2, 3, 4]
self.ylmax = int(input('inputylmax'))
self.An = sum(self.ylmaxvect)
self.Am = sum(self.ylmaxvect)
# -------------declare a zero matrix first------------------------ #
self.matAL = np.zeros((self.An, self.Am))
for i in range(self.An - 1):
if self.matAL[i][i + 1] == 0:
if i == self.ylmax:
self.matAL[i][i + 1] = 1
else:
self.matAL[i][i + 1] = 0
