Project Description

DynaPrecision is a generic/template library written in C# implementing the basic algorithms and data structures in a Graduate Numerical Method or Analysis course.


Financial namespace is added, together with some option pricing models

A Projected SOR option pricing scheme based on finite difference method is provided, and can handle both European/American Style payoffs.
A trinomial tree based option pricing method is provided, and can handle both European/American Style payoffs.

Several RandomNumberGenerators are provided.
A DynamicCastOperator class is provided, so +-*/ and other basic operations on generic classes can be easier.


I've added a numerical Poisson solver to the library - in fact, it simply generates an array that you can feed in any standard Linear system solver.

Fast Fourier transform and fast Chebyshev Transform

A Fast Fourier Transform is implemented - together with a IComplex<T> struct. The input can be an IList<Complex<T>> or an IList<T> as descripted in the book Numerical Recipe.
The Chebyshev Transform or Discretized Cosine transform of the first kind is implemented - with FFT as the underlying layer.
The number of input data into FFT should be 2^N, and into Chebyshev Transform should be 2^N+1

Origin of the Project

I am currently a graduate student in University of Illinois at Urbana-Champaign and previously in the Johns Hopkins University and Tsinghua University. DynaPrecision is in fact a set of mathematical and numerical codes that accumulated through my different courses and research projects. The basic idea of all these development is to include new features provided by C#, such as generic programming and object-oriented design, into the old-fashioned numerical methods.
I've tried to carefully define the interfaces and classes to ease the users of the library from re-programming many of the standard routines, such as Newtonian Interative method for non-linear equations, Jacobi iterative method for linear system.


Generic numerical methods

I've tried to treat C# generic like C++ template to achieve the freedom in choosing of different precision by using generics or templates, like the following sum methods:
T sum<T>(IEnumerable<T> list)
    T result = 0;
    foreach( T value in list) result += value;
    return result;
however, in the age of C# 3.0 or earlier this is not an easy task. The beta version of C# 4.0 introduces the dynamic keyword and by which I decided to implement all the methods in generic manner by using this keyword - I admit this decision will greatly influence the performance of the codes and as far as I know, Microsoft will soon release an IArithmetric<T> or so to address the support for general numeric operations - which means all these generic codes would be rewritten at that time. By using the keyword, the above codes become
T sum<T>(IEnumerable<T> list)
    T result = 0;
    foreach( T value in list) result += (dynamic)value;
    return result;
I am sorry about this performance issue.

Structure of the Library

The codes are divided into two kinds, Mathematical Data Structures such as Function and Matrix, and the Analytical and Numerical Methods (or Algorithms) that will operate these data structures, such as Simpson Integrating.
The basic of all these are set of interfaces such as IFunction and IMatrix for data structures and ISolver and IIterativeSolver for methods. I've implemented many general data types and methods, and if you find something missing, please email me the mathematical descriptions for the missing thing and I will be happy to include it in this project.

Last edited Apr 17, 2011 at 4:48 AM by fardream, version 11