用SOR迭代法解法方程① SOR.m文件为 function [x,n]=SOR(a,b,E,p) temp1=size(a);temp2=size(b); if temp1(1)~=temp1(2)|temp1(1)~=temp2(1)|temp2(2)~=1|det(a)==0 error('矩阵或向量的大小不对应或矩阵为奇异矩阵') return; end %%化为三角矩阵过程 leng=temp1(1);N=-tril(a,-1)-triu(a,1);M=a+N;N=-a; t=1;
numpy 返回函数的上三角矩阵
np.triu()
matrix2=np.triu(matrix1)
numpy.triu(m, k=0)[source]
Upper triangle of an array.
Return a copy of a matrix with the elements below the k-th diagonal zeroed.
np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1)
array([[ 1, 2,