⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jacobi1.m

📁 国外计算机科学教材系列 numerial method using matlab (third edition)
💻 M
字号:
function [V,D]=jacobi1(A,epsilon)%Input - A is an nxn matrix%      - epsilon the is tolerance%Output - V is the nxn matrix of eigenvectors%       - D is the diagonal nxn matrix of eigenvalues%Initialize V, D, and parameters% NUMERICAL METHODS: MATLAB Programs%(c) 1999 by John H. Mathews and Kurtis D. Fink%To accompany the textbook:%NUMERICAL METHODS Using MATLAB,%by John H. Mathews and Kurtis D. Fink%ISBN 0-13-270042-5, (c) 1999%PRENTICE HALL, INC.%Upper Saddle River, NJ 07458D=A;[n,n]=size(A);V=eye(n);state=1;%Calculate row p and column q of the off-diagonal element%of greatest magnitude in A[m1 p]=max(abs(D-diag(diag(D))));[m2 q]=max(m1);p=p(q);while (state==1)   %Zero out Dpq and Dqp   t=D(p,q)/(D(q,q)-D(p,p));   c=1/sqrt(t^2+1);   s=c*t;   R=[c s;-s c];   D([p q],:)=R'*D([p q],:);   D(:,[p q])=D(:,[p q])*R;   V(:,[p q])=V(:,[p q])*R;   [m1 p]=max(abs(D-diag(diag(D))));   [m2 q]=max(m1);   p=p(q);   if (abs(D(p,q))<epsilon*sqrt(sum(diag(D).^2)/n))      state=0;   endendD=diag(diag(D));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -