You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
480 B

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

# 1. 2 设置值1, 2, 3, 4落在5x5矩阵对角线下方位置
## (1). 解题思路
`numpy`库中提供了一个名为`diag`的方法用来提取或者构造对角矩阵,当它用于构造矩阵时,其第一个参数可以指定设置的元素,第二个参数设定元素落入的位置,`大于0`表示位于对角线上方位置,`小于0`表示位于对角线下方的位置,对于本题,设置为为-1。
## (2). 运行结果
![](images/resultpng.png)