Note: The latest version of the F# PowerPack does not have official documentation. Documentation for version 1.9.6.16 can be found at http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/fsharp.powerpack/Microsoft.FSharp.Math.html.

I'll begin by looking at some of the modules and types found in the FSharp.PowerPack\math directory of the F# PowerPack source.

**Associations:**

The first module that we find in this directory is called GlobalAssociations. To quote from the comments in the F# PowerPack code, "Associations are a way of associating dictionaries of

operations with given types at runtime. Associations are global to a .NET application domain. Once specified an association may not be deleted or modified." The following links provide examples of this module in use:

F# INumerics Interface, and Matrix class by Yin

Example on StackOverflow by Tomas Petricek

**Complex:**

The module found in Complex.fs provides support for complex numbers and includes members that allow you to easily work with those numbers. A few of the members include retrieval of the real as well as imaginary parts of the complex number, addition/subtraction/multiplication of complex numbers, etc.

Here is a simple example from the F# PowerPack CodePlex home page:

let c = complex 0.0 1.0 * complex 0.0 1.0 // result is -1r+0i

**Matrix:**

There are several examples of using the Matrix type out on the web. The F# PowerPack CodePlex home page provides the following example:

let v = vector [1.0;1.0;1.0] + vector [2.0;2.0;2.0] // result is (3.0; 3.0; 3.0)

Additionally, the previously mentioned post by Yin provides a few good examples. Also, Chapter 10 of the book Expert F# by Don Syme, Adam Granicz, and Antonio Cisternino has a section called Introducing Microsoft.FSharp.Math which contains a little more information and a few simple examples. A more involved example can be found here.

**NativeArrayExtensionsForMatrix:**

This module adds a few extension methods (i.e. of_vector, of_rowvec, and of_matrix) to the PinnedArray and PinnedArray2 types. An example of of_vector in use can be found here.

**BigRational:**

A simple example of the BigRational type in use, as documented on the F# PowerPack CodePlex home page, is shown below.

let r = (1N/2N) * (1N/3N) // result is 1/6

A more complex example can be found here.

**Wrapping Up:**

That's all for now. Everything described in this post (and the items described in the next few posts for this series) is provided in the FSharp.PowerPack.dll, which is available as part of an MSI on CodePlex as well as on NuGet Gallery as package ID FSPowerPack.Core.Community. In the next post for this series I will walk through and point out or provide examples for the command-line argument parser, AsyncOperations, AsyncStreamReader, and AsyncWorker.

## No comments:

## Post a Comment