pd.m
来自「LiScNLS is a Matlab application for the 」· M 代码 · 共 16 行
M
16 行
function [x,w]=pd(n,dom)
% Nodes and weights for Gauss quadrature on the domain dom
%
% from N. L. Trefethen, Spectral Methods in Matlab, SIAM 2000
% http://web.comlab.ox.ac.uk/oucl/work/nick.trefethen/spectral.html, gauss.m
%
% input: n - number of gridpoints
% dom - working interval
% output: x - the (Legendre) grid (n x 1)
% w - the weights (1 x n)
beta = .5./sqrt(1-(2*(1:n-1)).^(-2));
T = diag(beta,1) + diag(beta,-1);
[V,D] = eig(T);
x = diag(D); [x,i] = sort(x);
x=x*(dom(2)-dom(1))/2+(dom(2)+dom(1))/2;
w = 2*V(1,i).^2;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?