矩阵乘法实现获取第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.]]
**************************************************
相关推荐
岑梓铭2 分钟前
(CentOs系统虚拟机)Standalone模式下安装部署“基于Python编写”的Spark框架
linux·python·spark·centos
游客52016 分钟前
opencv中的各种滤波器简介
图像处理·人工智能·python·opencv·计算机视觉
Eric.Lee202119 分钟前
moviepy将图片序列制作成视频并加载字幕 - python 实现
开发语言·python·音视频·moviepy·字幕视频合成·图像制作为视频
Dontla24 分钟前
vscode怎么设置anaconda python解释器(anaconda解释器、vscode解释器)
ide·vscode·python
qq_529025291 小时前
Torch.gather
python·深度学习·机器学习
数据小爬虫@1 小时前
如何高效利用Python爬虫按关键字搜索苏宁商品
开发语言·爬虫·python
Cachel wood2 小时前
python round四舍五入和decimal库精确四舍五入
java·linux·前端·数据库·vue.js·python·前端框架
終不似少年遊*2 小时前
pyecharts
python·信息可视化·数据分析·学习笔记·pyecharts·使用技巧
Python之栈2 小时前
【无标题】
数据库·python·mysql
袁袁袁袁满2 小时前
100天精通Python(爬虫篇)——第113天:‌爬虫基础模块之urllib详细教程大全
开发语言·爬虫·python·网络爬虫·爬虫实战·urllib·urllib模块教程