# -*- coding: utf-8 -*-
import numpy as np
import time #calculate time of diffient method
np.random.seed(2) #set seed to make x0 unchanged
def Create_Tridiagonal_Matrices(a,b,c,n):#创建一种特殊的三对角矩阵,主对角线元素b,比主对角线低一行的对角线上a,比主对角线高一行的对角线上c
A=np.zeros((n,n))
if(b<=c or b<=a or b<a+c or n<2): # 判断是否符合三对角矩阵的基本定义,以及n的个数,1行的三对角毫无意义
print "this is not a Create_Tridiagonal_Matrices,please check a,b,c "
A[0][0]=b;A[0][1]=c
A[n-1][n-1]=b;A[n-1][n-2]=a
for j in range(
数值计算与优化(共轭梯度法和QR)
最新推荐文章于 2024-01-28 14:31:11 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)