forked from chebfun/chebfun
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cumsummat.m
50 lines (45 loc) · 1.52 KB
/
cumsummat.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function C = cumsummat(N, dom, disc)
%CUMSUMMAT Indefinite integration matrix.
% C = CUMSUMMAT(N) returns the NxN indefinite integration matrix associated
% with the Chebyshev spectral collocation method at second-kind Chebyshev
% points. By convection, the arbitrary constant is chosen so that the result
% is zero at -1. See CHEBCOLLOC2.CUMSUMMAT for further details.
%
% D = CUMSUMMAT(N, DOM) scales the indefinite integration matrix D to the
% domain DOM. DOM should be a 1x2 vector.
%
% D = CUMSUMMAT(N, DOM, DISC) or CUMSUMMAT(N, DISC) returns the indefinite
% integration matrix associated with the OPDISCRETIZATION DISC.
%
% See also CUMSUM, CHEBCOLLOC2.DIFFMAT, DIFFMAT.
% Copyright 2015 by The University of Oxford and The Chebfun Developers.
% See http://www.chebfun.org/ for Chebfun information.
%% Parse the inputs:
if ( (nargin == 2) )
if ( isa(dom, 'function_handle') || ischar(dom) )
disc = dom;
dom = cheboppref().domain;
else
disc = chebcolloc2();
end
elseif ( nargin == 1 )
disc = chebcolloc2();
dom = cheboppref().domain;
end
% Ensure DISC is a discretization:
if ( ischar(disc) )
disc = str2func(disc);
end
if ( isa(disc, 'function_handle') )
disc = disc();
end
% No breakpoints allowed:
if ( numel(dom) > 2 )
dom = dom([1 end]);
warning('CHEBFUN:cumsummat:noBreaks', ...
'CUMSUMMAT does not support domains with breakpoints.');
end
%% Call DISC.DIFFMAT(N) and scale appropriately.
scl = .5*(dom(end) - dom(1));
C = scl*disc.cumsummat(N);
end