List of Figures

  • 2.1 The fold_range function can be used to accumulate the result of applying a function f to a contiguous sequence of integers, in this case the sequence [1,9). 40

  • 2.2 Developing an application written entirely in F# using Microsoft Visual Studio 2005. 53

  • 2.3 Visual Studio provides graphical throwback of the type information inferred by the F# compiler: hovering the mouse over the definition of a variable r in the source code brings up a tooltip giving the inferred type of r. 54

  • 2.4 A project's properties page allows the compiler to be controlled. 55

  • 2.5 The Add-in Manager is used to provide the F# interactive mode. 57

  • 2.6 Creating a new C# class library project called ClassLibraryl inside a new solution called Interop. 59

  • 2.7 Creating a new F# project called Projectl also inside the Interop solution. 59

  • 2.8 Setting the startup project ofthe Interop solution to the F# project Project1 rather than the C# project ClassLibraryl as a DLL cannot be used to start an application . 60

  • 3.1 Complexities of the ipow_l and ipow_2 functions in terms of the number T(n) of multiplies performed. 67

  • 3.2 Complexities of the ipow_2 function in terms of the number of multiplies performed, showing: exact complexity T(n) (dots) and lower- and upper-bounds algorithmic complexities log2(n) — 1 ≤ T (n) 2(1 + log2 n) for n > 1 (lines). 68

  • 3.3 Measured performance of the ipow_l and ipow_2 functions which have asymptotic algorithmic complexities of

    List of Figures
  • 3.4 Arrays are the simplest data structure, allowing fast, random access (reading or writing) to the ith element ∀ i |ϵ {0 ... n — 1} where n is the number of elements in the array. Elements cannot be added or removed without copying the whole array. 69

  • 3.5 The higher-order Array, init function creates an array ai = f (i) for i ϵ {0 ... n — 1} using the given function f. 72

  • 3.6 The higher-order Array. map function creates an array containing the result of applying the given function f to each element in the given array a. 73

  • 3.7 The higher-order Array. fold_left function repeatedly applies the given function f to the current accumulator and the current array element to produce a new accumulator to be applied with the next array element. 74

  • 3.8 Lists are the simplest, arbitrarily-extensible data structure. Decapitation splits a list li iϵ{0... n — 1} into the head element h and the tail list ti i ϵ{0 ... n — 2}. 76

  • 3.9 Measured performance (time t in seconds) for inserting key-value pairs into hash tables and functional maps containing n — 1 elements. Although the hash table implementation results in better average-case performance, the 0 (n) time-complexity incurred when the hash table is resized internally produces much slower worst-case performance by the hash table. 88

  • 3.10 A perfectly-balanced binary tree of depth x = 3 containing 2X+1 — 1 = 15 nodes, including the root node and 2X = 8 leaf nodes. 94

  • 3.11 The result of inserting an integer counter into each node of the tree depicted in figure 3.10 using the counted_ptree_of_tree function. 96

  • 3.12 An unbalanced binary tree with the remaining depth stored in every node. 98

  • 3.13 A maximally-unbalanced binary tree of depth x = 7 containing 2x + 1 = 15 nodes, including the root node and x + 1 = 8 leaf nodes. 100

  • 3.14 An unbalanced binary tree used to partition the space r ϵ (0,1) in order to approximate the gravitational effect of a cluster of particles in a system. 106

  • 3.15 Measured performance of the tree-based approach relative to a simple array-based approach for the evaluation of long-range forces showing the resulting fractional error

    List of Figures
  • 4.1 Values i of the type int, called machine-precision integers, are an exact representation of a consecutive subset of the set of integers i ϵ [I... u] C Z where I and u are given by min_int and max_int, respectively. 114

  • 4.2 Values of the type float, called double-precision floating-point numbers, are an approximate representation of real-valued numbers, showing: a) full-precision (normalized) numbers (black), and b) denormalized numbers (gray). 115

  • 4.3 Accuracy of two equivalent expressions when evaluated using floating-point arithmetic: a)

    List of Figures
  • 5.1 Parsing character sequences often entails lexing into a token stream and then parsing to convert patterns of tokens into grammatical constructs represented hierarchically by a tree data structure. 132

  • 6.1 The first seven rows of Pascal's triangle. 149

  • 7.1 A blank Windows form. 175

  • 7.2 A form with a single control, a button. 176

  • 7.3 A thousand generations of the rule 30 cellular automaton. 179

  • 7.4 A DirectX viewer that clears the display to a single color (called "coral"). 183

  • 7.5 Abutting triangles can be amortised into triangle fans and strips to reduce the number of vertices required to describe a geometry. 187

  • 7.6 A triangle rendered programmatically and visualized using an orthographic projection. 189

  • 7.7 A DirectX viewer that draws an icosahedron. 190

  • 7.8 Progressively more refined uniform tesselations of a sphere, obtained by subdividing the triangular faces of an icosahedron and normalising the resulting vertex coordinate vectors to push them onto the surface of a sphere. 195

  • 7.9 3D surface plot of y = sin(r +3x) /r where

    List of Figures
  • 8.1 Profiling results generated by the freely-available NProf profiler for a program solving the queens problem on an 11 × 11 board. 204

  • 8.2 Measured performance (time t in seconds) of mem functions over set, list and array data structures containing n elements. 206

  • 8.3 Relative time taken t = ts/ta for testing membership in a set (ts) and an array (t a) as a function of the number of elements n in the container, showing that arrays are up to 2x faster for n < 35. 208

  • 8.4 Measured performance (time t in seconds per element) of List. of _array, Array. copy and Set. of _array data structures containing n elements. 208

  • 8.5 Measured performance (time t in seconds per element) of iter functions over list, array and set data structures containing n elements. 209

  • 8.6 Measured performance (time t in seconds per element) of the fold_left functions over list and array data structures containing n elements. 210

  • 8.7 Measured performance (time t in seconds per element) of the fold_right functions over list, array and set data structures containing n elements. 210

  • 8.8 Controlling the optimization flags passed to the F# compiler by Visual Studio 2005. 211

  • 8.9 Deforestation refers to methods used to reduce the size of temporary data, such as the use of composite functions to avoid the creation of temporary data structures illustrated here: a) mapping a function f over a list 1 twice, and b) mapping the composite function f o f over the list 1 once. 214

  • 8.10 An array of tuples or records containing pairs of float values incurs a level of indirection. 222

  • 8.11 A struct can be used to completely unbox the float values, placing them directly into the array. This is often the most efficient representation. 222

  • 9.1 The XYGraph tool from ComponentXtra. 227

  • 9.2 Fourier series of a discretely sampled sine wave, showing: a) the samples ur rϵ [0,16) and Fourier series

    List of Figures
  • 10.1 Using a Windows Forms TreeView control to visualize the contents of an XML document from the Protein Data Bank. 254

  • 10.2 Visualizing the contents of a SQL Server database using the Windows Forms DataGrid control. 265

  • 11.1 An Excel spreadsheet with cell values generated from a F# interactive session. 270

  • 11.2 A plot of sin(x) created in MATLAB by an F# program. 274

  • 12.1 The approximately semi-circular eigenvalue density P(λ) for a dense, random, square matrix Mij = ±1 with n = 1024, showing the computed eigenvalue distribution. 292

  • 12.2 Conventionally, atoms are referenced only by their index i ϵ I={l...N } within the supercell. Consequently, atoms i,j ϵ I at opposite ends of the supercell are considered to be bonded. 293

  • 12.3 We use an unconventional representation that allows all atoms to be indexed by the supercell they are in as well as their index within the supercell. In this case, the pair of bonded atoms are referenced as (0, 0), ii) and ((1,0), ij,), i.e. with i in the origin supercell (0,0) and j in the supercell with offset (1,0). 294

  • 12.4 The 50th-nearest neighbour shell from a 105-atom model of amorphous silicon [1] rendered using the F#for Visualization library. 301

  • 12.5 Chaotic behaviour of the logistic map. 304

  • 12.6 Real-time interactive simulation and visualization of non-interacting particles bouncing on a 3D surface. 308

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.7.102