Skip to content

zaman13/Matrix-Differentiation-Operators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matrix-Differentiation-Operators

alt text alt text alt text

alt text

Finite difference matrix operators for performing numerical differentiation in python. The current version can handle 1D and 2D numpy arrays. 2D arrays need to be reshaped/unraveled into a column vector first. Differentiation can be performed by pre-multiplying the vector with the matrix operator. After the matrix operation, it can be reshaped to its originial dimensions. The matrix operators use secord order central differene formula (except for edge points where second order forward/backward difference formula is used). The code uses sparse matrices and therefore can handle large arrays.

Features

  • Differentiate numpy arrays using simple matrix multiplication.
  • Differentiation of 1D and 2D data (in meshgrid format) have been implemented so far.
  • The matrix operators are in the form of sparse matrices. So, the operators can handle large datasets.

Package requirements

  • NumPy alt text
  • SciPy (sparse matrices, sparse linear algebra) alt text alt text

Use

The Differentiation_testing_v1.py file contains an example differentiation problem in 1D and 2D.

Sample Output

The following plots show the first and second derivative of an one dimensional Gaussian function. The results obtained using the matrix operators are compared with the analytical results.

alt text

The following plots show the first derivative of a two dimensional Gaussian function. The results obtained using the matrix operators are compared with the analytical results.

alt text

About

Finite difference matrix operators for performing numerical differentiation in python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages