矩阵乘法实现获取第i行,第j列值,矩阵大小不变

    1. 获取第i行,第j列值,矩阵大小不变
    1. 将第i行,第j列置为零
  • 代码:
python 复制代码
import numpy as np

np.set_printoptions(suppress=True, precision=3)


class GetRowColumn(object):
    def __init__(self, in_row, in_column, in_matrix):
        self.row = in_row
        self.column = in_column
        self.matrix = in_matrix
        self.m_row, self.m_column = np.shape(self.matrix)
        self._result = np.zeros_like(self.matrix)
        self._set_zeros = np.zeros_like(self.matrix)

    @property
    def result(self):
        my_zeros_row = np.zeros((self.m_row, self.m_row))
        my_zeros_row[self.row, self.row] = 1
        my_rows = my_zeros_row @ self.matrix

        my_zeros_column = np.zeros((self.m_column, self.m_column))
        my_zeros_column[self.column, self.column] = 1
        my_columns = self.matrix @ my_zeros_column

        my_one = np.zeros_like(self.matrix)
        my_one[self.row, self.column] = self.matrix[self.row, self.column]
        my_result = my_rows + my_columns - my_one
        self._result = my_result
        return self._result

    @property
    def set_zeros(self):
        my_matrix = self.matrix
        my_result = self.result
        my_set_zeros = my_matrix - my_result
        self._set_zeros = my_set_zeros
        return self._set_zeros


if __name__ == "__main__":
    my_code = 0
    test_row = 5
    test_column = 8
    test_range = test_row * test_column
    my_array = np.arange(test_range).reshape(test_row, test_column)
    for i in range(1, test_row):
        for j in range(1, test_column):
            my_test = GetRowColumn(i, j, my_array)
            result = my_test.result
            set_zeros = my_test.set_zeros
            print(f"*" * 50)
            print(f"my_array = \n{my_array}")
            print(f"result[{i},{j}]=\n{result}")
            print(f"set_zeros[{i},{j}]=\n{set_zeros}")
            print(f"*" * 50)
  • 结果:
python 复制代码
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[1,1]=
[[ 0.  1.  0.  0.  0.  0.  0.  0.]
 [ 8.  9. 10. 11. 12. 13. 14. 15.]
 [ 0. 17.  0.  0.  0.  0.  0.  0.]
 [ 0. 25.  0.  0.  0.  0.  0.  0.]
 [ 0. 33.  0.  0.  0.  0.  0.  0.]]
set_zeros[1,1]=
[[ 0.  0.  2.  3.  4.  5.  6.  7.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [16.  0. 18. 19. 20. 21. 22. 23.]
 [24.  0. 26. 27. 28. 29. 30. 31.]
 [32.  0. 34. 35. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[1,2]=
[[ 0.  0.  2.  0.  0.  0.  0.  0.]
 [ 8.  9. 10. 11. 12. 13. 14. 15.]
 [ 0.  0. 18.  0.  0.  0.  0.  0.]
 [ 0.  0. 26.  0.  0.  0.  0.  0.]
 [ 0.  0. 34.  0.  0.  0.  0.  0.]]
set_zeros[1,2]=
[[ 0.  1.  0.  3.  4.  5.  6.  7.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [16. 17.  0. 19. 20. 21. 22. 23.]
 [24. 25.  0. 27. 28. 29. 30. 31.]
 [32. 33.  0. 35. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[1,3]=
[[ 0.  0.  0.  3.  0.  0.  0.  0.]
 [ 8.  9. 10. 11. 12. 13. 14. 15.]
 [ 0.  0.  0. 19.  0.  0.  0.  0.]
 [ 0.  0.  0. 27.  0.  0.  0.  0.]
 [ 0.  0.  0. 35.  0.  0.  0.  0.]]
set_zeros[1,3]=
[[ 0.  1.  2.  0.  4.  5.  6.  7.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [16. 17. 18.  0. 20. 21. 22. 23.]
 [24. 25. 26.  0. 28. 29. 30. 31.]
 [32. 33. 34.  0. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[1,4]=
[[ 0.  0.  0.  0.  4.  0.  0.  0.]
 [ 8.  9. 10. 11. 12. 13. 14. 15.]
 [ 0.  0.  0.  0. 20.  0.  0.  0.]
 [ 0.  0.  0.  0. 28.  0.  0.  0.]
 [ 0.  0.  0.  0. 36.  0.  0.  0.]]
set_zeros[1,4]=
[[ 0.  1.  2.  3.  0.  5.  6.  7.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [16. 17. 18. 19.  0. 21. 22. 23.]
 [24. 25. 26. 27.  0. 29. 30. 31.]
 [32. 33. 34. 35.  0. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[1,5]=
[[ 0.  0.  0.  0.  0.  5.  0.  0.]
 [ 8.  9. 10. 11. 12. 13. 14. 15.]
 [ 0.  0.  0.  0.  0. 21.  0.  0.]
 [ 0.  0.  0.  0.  0. 29.  0.  0.]
 [ 0.  0.  0.  0.  0. 37.  0.  0.]]
set_zeros[1,5]=
[[ 0.  1.  2.  3.  4.  0.  6.  7.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [16. 17. 18. 19. 20.  0. 22. 23.]
 [24. 25. 26. 27. 28.  0. 30. 31.]
 [32. 33. 34. 35. 36.  0. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[1,6]=
[[ 0.  0.  0.  0.  0.  0.  6.  0.]
 [ 8.  9. 10. 11. 12. 13. 14. 15.]
 [ 0.  0.  0.  0.  0.  0. 22.  0.]
 [ 0.  0.  0.  0.  0.  0. 30.  0.]
 [ 0.  0.  0.  0.  0.  0. 38.  0.]]
set_zeros[1,6]=
[[ 0.  1.  2.  3.  4.  5.  0.  7.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [16. 17. 18. 19. 20. 21.  0. 23.]
 [24. 25. 26. 27. 28. 29.  0. 31.]
 [32. 33. 34. 35. 36. 37.  0. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[1,7]=
[[ 0.  0.  0.  0.  0.  0.  0.  7.]
 [ 8.  9. 10. 11. 12. 13. 14. 15.]
 [ 0.  0.  0.  0.  0.  0.  0. 23.]
 [ 0.  0.  0.  0.  0.  0.  0. 31.]
 [ 0.  0.  0.  0.  0.  0.  0. 39.]]
set_zeros[1,7]=
[[ 0.  1.  2.  3.  4.  5.  6.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [16. 17. 18. 19. 20. 21. 22.  0.]
 [24. 25. 26. 27. 28. 29. 30.  0.]
 [32. 33. 34. 35. 36. 37. 38.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[2,1]=
[[ 0.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  9.  0.  0.  0.  0.  0.  0.]
 [16. 17. 18. 19. 20. 21. 22. 23.]
 [ 0. 25.  0.  0.  0.  0.  0.  0.]
 [ 0. 33.  0.  0.  0.  0.  0.  0.]]
set_zeros[2,1]=
[[ 0.  0.  2.  3.  4.  5.  6.  7.]
 [ 8.  0. 10. 11. 12. 13. 14. 15.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [24.  0. 26. 27. 28. 29. 30. 31.]
 [32.  0. 34. 35. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[2,2]=
[[ 0.  0.  2.  0.  0.  0.  0.  0.]
 [ 0.  0. 10.  0.  0.  0.  0.  0.]
 [16. 17. 18. 19. 20. 21. 22. 23.]
 [ 0.  0. 26.  0.  0.  0.  0.  0.]
 [ 0.  0. 34.  0.  0.  0.  0.  0.]]
set_zeros[2,2]=
[[ 0.  1.  0.  3.  4.  5.  6.  7.]
 [ 8.  9.  0. 11. 12. 13. 14. 15.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [24. 25.  0. 27. 28. 29. 30. 31.]
 [32. 33.  0. 35. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[2,3]=
[[ 0.  0.  0.  3.  0.  0.  0.  0.]
 [ 0.  0.  0. 11.  0.  0.  0.  0.]
 [16. 17. 18. 19. 20. 21. 22. 23.]
 [ 0.  0.  0. 27.  0.  0.  0.  0.]
 [ 0.  0.  0. 35.  0.  0.  0.  0.]]
set_zeros[2,3]=
[[ 0.  1.  2.  0.  4.  5.  6.  7.]
 [ 8.  9. 10.  0. 12. 13. 14. 15.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [24. 25. 26.  0. 28. 29. 30. 31.]
 [32. 33. 34.  0. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[2,4]=
[[ 0.  0.  0.  0.  4.  0.  0.  0.]
 [ 0.  0.  0.  0. 12.  0.  0.  0.]
 [16. 17. 18. 19. 20. 21. 22. 23.]
 [ 0.  0.  0.  0. 28.  0.  0.  0.]
 [ 0.  0.  0.  0. 36.  0.  0.  0.]]
set_zeros[2,4]=
[[ 0.  1.  2.  3.  0.  5.  6.  7.]
 [ 8.  9. 10. 11.  0. 13. 14. 15.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [24. 25. 26. 27.  0. 29. 30. 31.]
 [32. 33. 34. 35.  0. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[2,5]=
[[ 0.  0.  0.  0.  0.  5.  0.  0.]
 [ 0.  0.  0.  0.  0. 13.  0.  0.]
 [16. 17. 18. 19. 20. 21. 22. 23.]
 [ 0.  0.  0.  0.  0. 29.  0.  0.]
 [ 0.  0.  0.  0.  0. 37.  0.  0.]]
set_zeros[2,5]=
[[ 0.  1.  2.  3.  4.  0.  6.  7.]
 [ 8.  9. 10. 11. 12.  0. 14. 15.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [24. 25. 26. 27. 28.  0. 30. 31.]
 [32. 33. 34. 35. 36.  0. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[2,6]=
[[ 0.  0.  0.  0.  0.  0.  6.  0.]
 [ 0.  0.  0.  0.  0.  0. 14.  0.]
 [16. 17. 18. 19. 20. 21. 22. 23.]
 [ 0.  0.  0.  0.  0.  0. 30.  0.]
 [ 0.  0.  0.  0.  0.  0. 38.  0.]]
set_zeros[2,6]=
[[ 0.  1.  2.  3.  4.  5.  0.  7.]
 [ 8.  9. 10. 11. 12. 13.  0. 15.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [24. 25. 26. 27. 28. 29.  0. 31.]
 [32. 33. 34. 35. 36. 37.  0. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[2,7]=
[[ 0.  0.  0.  0.  0.  0.  0.  7.]
 [ 0.  0.  0.  0.  0.  0.  0. 15.]
 [16. 17. 18. 19. 20. 21. 22. 23.]
 [ 0.  0.  0.  0.  0.  0.  0. 31.]
 [ 0.  0.  0.  0.  0.  0.  0. 39.]]
set_zeros[2,7]=
[[ 0.  1.  2.  3.  4.  5.  6.  0.]
 [ 8.  9. 10. 11. 12. 13. 14.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [24. 25. 26. 27. 28. 29. 30.  0.]
 [32. 33. 34. 35. 36. 37. 38.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[3,1]=
[[ 0.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  9.  0.  0.  0.  0.  0.  0.]
 [ 0. 17.  0.  0.  0.  0.  0.  0.]
 [24. 25. 26. 27. 28. 29. 30. 31.]
 [ 0. 33.  0.  0.  0.  0.  0.  0.]]
set_zeros[3,1]=
[[ 0.  0.  2.  3.  4.  5.  6.  7.]
 [ 8.  0. 10. 11. 12. 13. 14. 15.]
 [16.  0. 18. 19. 20. 21. 22. 23.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [32.  0. 34. 35. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[3,2]=
[[ 0.  0.  2.  0.  0.  0.  0.  0.]
 [ 0.  0. 10.  0.  0.  0.  0.  0.]
 [ 0.  0. 18.  0.  0.  0.  0.  0.]
 [24. 25. 26. 27. 28. 29. 30. 31.]
 [ 0.  0. 34.  0.  0.  0.  0.  0.]]
set_zeros[3,2]=
[[ 0.  1.  0.  3.  4.  5.  6.  7.]
 [ 8.  9.  0. 11. 12. 13. 14. 15.]
 [16. 17.  0. 19. 20. 21. 22. 23.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [32. 33.  0. 35. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[3,3]=
[[ 0.  0.  0.  3.  0.  0.  0.  0.]
 [ 0.  0.  0. 11.  0.  0.  0.  0.]
 [ 0.  0.  0. 19.  0.  0.  0.  0.]
 [24. 25. 26. 27. 28. 29. 30. 31.]
 [ 0.  0.  0. 35.  0.  0.  0.  0.]]
set_zeros[3,3]=
[[ 0.  1.  2.  0.  4.  5.  6.  7.]
 [ 8.  9. 10.  0. 12. 13. 14. 15.]
 [16. 17. 18.  0. 20. 21. 22. 23.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [32. 33. 34.  0. 36. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[3,4]=
[[ 0.  0.  0.  0.  4.  0.  0.  0.]
 [ 0.  0.  0.  0. 12.  0.  0.  0.]
 [ 0.  0.  0.  0. 20.  0.  0.  0.]
 [24. 25. 26. 27. 28. 29. 30. 31.]
 [ 0.  0.  0.  0. 36.  0.  0.  0.]]
set_zeros[3,4]=
[[ 0.  1.  2.  3.  0.  5.  6.  7.]
 [ 8.  9. 10. 11.  0. 13. 14. 15.]
 [16. 17. 18. 19.  0. 21. 22. 23.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [32. 33. 34. 35.  0. 37. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[3,5]=
[[ 0.  0.  0.  0.  0.  5.  0.  0.]
 [ 0.  0.  0.  0.  0. 13.  0.  0.]
 [ 0.  0.  0.  0.  0. 21.  0.  0.]
 [24. 25. 26. 27. 28. 29. 30. 31.]
 [ 0.  0.  0.  0.  0. 37.  0.  0.]]
set_zeros[3,5]=
[[ 0.  1.  2.  3.  4.  0.  6.  7.]
 [ 8.  9. 10. 11. 12.  0. 14. 15.]
 [16. 17. 18. 19. 20.  0. 22. 23.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [32. 33. 34. 35. 36.  0. 38. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[3,6]=
[[ 0.  0.  0.  0.  0.  0.  6.  0.]
 [ 0.  0.  0.  0.  0.  0. 14.  0.]
 [ 0.  0.  0.  0.  0.  0. 22.  0.]
 [24. 25. 26. 27. 28. 29. 30. 31.]
 [ 0.  0.  0.  0.  0.  0. 38.  0.]]
set_zeros[3,6]=
[[ 0.  1.  2.  3.  4.  5.  0.  7.]
 [ 8.  9. 10. 11. 12. 13.  0. 15.]
 [16. 17. 18. 19. 20. 21.  0. 23.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [32. 33. 34. 35. 36. 37.  0. 39.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[3,7]=
[[ 0.  0.  0.  0.  0.  0.  0.  7.]
 [ 0.  0.  0.  0.  0.  0.  0. 15.]
 [ 0.  0.  0.  0.  0.  0.  0. 23.]
 [24. 25. 26. 27. 28. 29. 30. 31.]
 [ 0.  0.  0.  0.  0.  0.  0. 39.]]
set_zeros[3,7]=
[[ 0.  1.  2.  3.  4.  5.  6.  0.]
 [ 8.  9. 10. 11. 12. 13. 14.  0.]
 [16. 17. 18. 19. 20. 21. 22.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]
 [32. 33. 34. 35. 36. 37. 38.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[4,1]=
[[ 0.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  9.  0.  0.  0.  0.  0.  0.]
 [ 0. 17.  0.  0.  0.  0.  0.  0.]
 [ 0. 25.  0.  0.  0.  0.  0.  0.]
 [32. 33. 34. 35. 36. 37. 38. 39.]]
set_zeros[4,1]=
[[ 0.  0.  2.  3.  4.  5.  6.  7.]
 [ 8.  0. 10. 11. 12. 13. 14. 15.]
 [16.  0. 18. 19. 20. 21. 22. 23.]
 [24.  0. 26. 27. 28. 29. 30. 31.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[4,2]=
[[ 0.  0.  2.  0.  0.  0.  0.  0.]
 [ 0.  0. 10.  0.  0.  0.  0.  0.]
 [ 0.  0. 18.  0.  0.  0.  0.  0.]
 [ 0.  0. 26.  0.  0.  0.  0.  0.]
 [32. 33. 34. 35. 36. 37. 38. 39.]]
set_zeros[4,2]=
[[ 0.  1.  0.  3.  4.  5.  6.  7.]
 [ 8.  9.  0. 11. 12. 13. 14. 15.]
 [16. 17.  0. 19. 20. 21. 22. 23.]
 [24. 25.  0. 27. 28. 29. 30. 31.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[4,3]=
[[ 0.  0.  0.  3.  0.  0.  0.  0.]
 [ 0.  0.  0. 11.  0.  0.  0.  0.]
 [ 0.  0.  0. 19.  0.  0.  0.  0.]
 [ 0.  0.  0. 27.  0.  0.  0.  0.]
 [32. 33. 34. 35. 36. 37. 38. 39.]]
set_zeros[4,3]=
[[ 0.  1.  2.  0.  4.  5.  6.  7.]
 [ 8.  9. 10.  0. 12. 13. 14. 15.]
 [16. 17. 18.  0. 20. 21. 22. 23.]
 [24. 25. 26.  0. 28. 29. 30. 31.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[4,4]=
[[ 0.  0.  0.  0.  4.  0.  0.  0.]
 [ 0.  0.  0.  0. 12.  0.  0.  0.]
 [ 0.  0.  0.  0. 20.  0.  0.  0.]
 [ 0.  0.  0.  0. 28.  0.  0.  0.]
 [32. 33. 34. 35. 36. 37. 38. 39.]]
set_zeros[4,4]=
[[ 0.  1.  2.  3.  0.  5.  6.  7.]
 [ 8.  9. 10. 11.  0. 13. 14. 15.]
 [16. 17. 18. 19.  0. 21. 22. 23.]
 [24. 25. 26. 27.  0. 29. 30. 31.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[4,5]=
[[ 0.  0.  0.  0.  0.  5.  0.  0.]
 [ 0.  0.  0.  0.  0. 13.  0.  0.]
 [ 0.  0.  0.  0.  0. 21.  0.  0.]
 [ 0.  0.  0.  0.  0. 29.  0.  0.]
 [32. 33. 34. 35. 36. 37. 38. 39.]]
set_zeros[4,5]=
[[ 0.  1.  2.  3.  4.  0.  6.  7.]
 [ 8.  9. 10. 11. 12.  0. 14. 15.]
 [16. 17. 18. 19. 20.  0. 22. 23.]
 [24. 25. 26. 27. 28.  0. 30. 31.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[4,6]=
[[ 0.  0.  0.  0.  0.  0.  6.  0.]
 [ 0.  0.  0.  0.  0.  0. 14.  0.]
 [ 0.  0.  0.  0.  0.  0. 22.  0.]
 [ 0.  0.  0.  0.  0.  0. 30.  0.]
 [32. 33. 34. 35. 36. 37. 38. 39.]]
set_zeros[4,6]=
[[ 0.  1.  2.  3.  4.  5.  0.  7.]
 [ 8.  9. 10. 11. 12. 13.  0. 15.]
 [16. 17. 18. 19. 20. 21.  0. 23.]
 [24. 25. 26. 27. 28. 29.  0. 31.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]]
**************************************************
**************************************************
my_array = 
[[ 0  1  2  3  4  5  6  7]
 [ 8  9 10 11 12 13 14 15]
 [16 17 18 19 20 21 22 23]
 [24 25 26 27 28 29 30 31]
 [32 33 34 35 36 37 38 39]]
result[4,7]=
[[ 0.  0.  0.  0.  0.  0.  0.  7.]
 [ 0.  0.  0.  0.  0.  0.  0. 15.]
 [ 0.  0.  0.  0.  0.  0.  0. 23.]
 [ 0.  0.  0.  0.  0.  0.  0. 31.]
 [32. 33. 34. 35. 36. 37. 38. 39.]]
set_zeros[4,7]=
[[ 0.  1.  2.  3.  4.  5.  6.  0.]
 [ 8.  9. 10. 11. 12. 13. 14.  0.]
 [16. 17. 18. 19. 20. 21. 22.  0.]
 [24. 25. 26. 27. 28. 29. 30.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.]]
**************************************************
相关推荐
好看资源平台6 分钟前
爬虫开发工具与环境搭建——环境配置
爬虫·python
大G哥14 分钟前
python 数据类型----可变数据类型
linux·服务器·开发语言·前端·python
phoenix@Capricornus30 分钟前
卷积、频域乘积和矩阵向量乘积三种形式之间的等价关系与转换
图像处理·线性代数·矩阵
赛丽曼40 分钟前
Python中的HTML
python·html
luky!1 小时前
算法--解决熄灯问题
python·算法
深度学习lover1 小时前
<项目代码>YOLOv8 番茄识别<目标检测>
人工智能·python·yolo·目标检测·计算机视觉·番茄识别
IT古董1 小时前
【机器学习】机器学习中用到的高等数学知识-1.线性代数 (Linear Algebra)
人工智能·python·线性代数·机器学习
生信与遗传解读1 小时前
基于python的线性代数相关计算
python·线性代数·机器学习
Py小趴1 小时前
Python自学之Colormaps指南
开发语言·python·数据可视化
晒足以百八十1 小时前
基于Python 和 pyecharts 制作招聘数据可视化分析大屏
开发语言·python·信息可视化