Difference between revisions of "Fdmat.m"

From Spinach Documentation Wiki
Jump to: navigation, search
(Created page with "Returns arbitrary-order central finite-difference differentiation matrix (sparse) with unit spacing and sided finite-difference schemes of the same order at the edges. Syntax:...")
 
(Update function See also links and function index membership)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Returns arbitrary-order central finite-difference differentiation matrix (sparse) with unit spacing and sided finite-difference schemes of the same order at the edges. Syntax:
+
{{DISPLAYTITLE:fdmat.m}} __NOTOC__
 +
Returns arbitrary-order central finite-difference differentiation matrices (sparse) with unit grid point spacing.
  
                  D=fdmat(dim,npoints,order,boundary)
+
==Syntax==
  
Parameters:
+
    D=fdmat(dim,nstenc,order,boundary)
 +
 
 +
==Parameters==
  
 
     dim      - dimension of the column vector to be
 
     dim      - dimension of the column vector to be
 
                 differentiated
 
                 differentiated
 
+
     npoints  - number of points in the finite diffe-
+
     nstenc    - number of points in the finite diffe-
 
                 rence stencil
 
                 rence stencil
 
+
 
     order    - order of the derivative required
 
     order    - order of the derivative required
 
+
 
     boundary  - 'wall' fills the edges with sided
 
     boundary  - 'wall' fills the edges with sided
 
                 finite difference schemes, 'pbc'
 
                 finite difference schemes, 'pbc'
 
                 assumes periodic boundaries. The
 
                 assumes periodic boundaries. The
                 default is 'wall'.
+
                 default is 'pbc'.
 +
 
 +
==Outputs==
 +
 
 +
    D      - finite difference differentiation matrix
 +
 
 +
==Examples==
 +
A three-point second derivative matrix designed to act on a vector with ten elements with periodic boundary conditions is:
 +
 
 +
  >> full(fdmat(10,3,2,'pbc'))
 +
 +
  ans =
 +
 +
      -2    1    0    0    0    0    0    0    0    1
 +
      1    -2    1    0    0    0    0    0    0    0
 +
      0    1    -2    1    0    0    0    0    0    0
 +
      0    0    1    -2    1    0    0    0    0    0
 +
      0    0    0    1    -2    1    0    0    0    0
 +
      0    0    0    0    1    -2    1    0    0    0
 +
      0    0    0    0    0    1    -2    1    0    0
 +
      0    0    0    0    0    0    1    -2    1    0
 +
      0    0    0    0    0    0    0    1    -2    1
 +
      1    0    0    0    0    0    0    0    1    -2
 +
 
 +
==See also==
 +
[[fdvec.m]], [[fdlap.m]], [[fdhess.m]], [[fdkup.m]], [[fdweights.m]], [[fftdiff.m]], [[fourdif.m]], [[fourlap.m]], [[cgsppm2ang.m]], [[corrfun.m]], [[fpl2phan.m]], [[fpl2rho.m]], [[hydrodynamics.m]], [[interpmat.m]], [[oscillator.m]], [[overwound.m]], [[phan2fpl.m]], [[points2mult.m]], [[qform2sph.m]], [[qxspen_kernel.m]], [[spden.m]], [[Hyperfine_shift_module]], [[Kernel_utilities]]
 +
 
 +
''Version 2.2, authors: [[Ilya Kuprov]]''

Latest revision as of 19:36, 6 June 2026

Returns arbitrary-order central finite-difference differentiation matrices (sparse) with unit grid point spacing.

Syntax

    D=fdmat(dim,nstenc,order,boundary)

Parameters

    dim       - dimension of the column vector to be
                differentiated

    nstenc    - number of points in the finite diffe-
                rence stencil

    order     - order of the derivative required

    boundary  - 'wall' fills the edges with sided
                finite difference schemes, 'pbc'
                assumes periodic boundaries. The
                default is 'pbc'.

Outputs

    D      - finite difference differentiation matrix

Examples

A three-point second derivative matrix designed to act on a vector with ten elements with periodic boundary conditions is:

 >> full(fdmat(10,3,2,'pbc'))

 ans =

     -2     1     0     0     0     0     0     0     0     1
      1    -2     1     0     0     0     0     0     0     0
      0     1    -2     1     0     0     0     0     0     0
      0     0     1    -2     1     0     0     0     0     0
      0     0     0     1    -2     1     0     0     0     0
      0     0     0     0     1    -2     1     0     0     0
      0     0     0     0     0     1    -2     1     0     0
      0     0     0     0     0     0     1    -2     1     0
      0     0     0     0     0     0     0     1    -2     1
      1     0     0     0     0     0     0     0     1    -2

See also

fdvec.m, fdlap.m, fdhess.m, fdkup.m, fdweights.m, fftdiff.m, fourdif.m, fourlap.m, cgsppm2ang.m, corrfun.m, fpl2phan.m, fpl2rho.m, hydrodynamics.m, interpmat.m, oscillator.m, overwound.m, phan2fpl.m, points2mult.m, qform2sph.m, qxspen_kernel.m, spden.m, Hyperfine_shift_module, Kernel_utilities

Version 2.2, authors: Ilya Kuprov