AdamMil.net Libraries Home

He is truly wise who gains wisdom from another's mishap.

AdamMil.net Libraries

Introduction

The AdamMil.net collection of libraries provides a number of services that I've found useful or interesting. It has the following libraries:
  • Artificial Intelligence
  • Collections
  • IO
  • Mathematics
  • Security
  • Transactions
  • User Interfaces
  • General Utilities

All libraries are documented, commented, and fairly well-designed, and many libraries have solid unit tests as well. Some libraries are works in progress, and their design may change. The libraries are separate, but there are some dependencies between them.

All code is released under the terms of the GNU GPL version 2.

Libraries

Artificial Intelligence

Currently, the library primarily covers search. It is well-designed, documented, and commented. It has the following features:
  • Graph search - A*, breadth-first, depth-first, depth-limited, greedy best-first, iterative deepening, and uniform cost, plus the ability to search graphs bidirectionally
  • Local search - genetic algorithms, hill climbing, simulated annealing
  • Adversarial search - N player minimax, alpha-beta
  • Constraint satisfaction solvers - backtracking and local search
  • Base classes and interfaces that make it easy to create your own types of searches or to attack a problem with many different types of searches (For example, a problem can be described using a generic interface and solved using a graph search, local search, or constraint satisfaction search without having to completely reformulate the problem for each search type.)
  • Ability to parallelize some searches across multiple CPU cores

Collections

The library implements collection classes that I've found useful. It is fully documented, commented, and unit-tested. It has the following features:
  • Base collections - Useful base classes that make it very easy to create custom collections, including lists and dictionaries.
  • Bloom filter - A generalized Bloom filter that works with any .NET type.
  • Circular list - Useful for implementing queues and buffers.
  • Hash providers - Hash code providers for many built-in types to support data structures that need multiple hash functions.
  • Priority queue - An efficient sorted queue that always dequeues the superlative item.
  • Read-only wrappers - Wrap collections, including dictionaries, in an interface that doesn't allow modification.
  • Stack - Unlike the .NET one, this stack is indexable and implements an IQueue<T> interface.
  • Topological sorts - The ability to order items based on dependencies and to group them into sets that can be processed in parallel. Implemented as LINQ extensions.

IO

The library is fully documented and commented, and has some unit tests. It has the following features:
  • Low-level methods to read values from and write values to arrays and streams
  • Medium-level binary reader/writer classes to efficiently process data in arrays and streams
  • High-level python-like formatted binary IO
  • Full-duplex inheritable pipes for communicating with child processes
  • Library of flexible stream classes - aggregate streams, read & copy streams, streams to read binary data from databases, streams that wrap other streams, streams that encode or decode data transparently, reference-counted streams, tee streams, temporary file streams, text streams
  • Compression and decompression using the PKWARE Data Compression Library format. (This format is inferior to gzip and many others. It is included to provide interop with software that uses it.)
  • Helpful extensions to built-in stream classes

Mathematics

This library is just started. It has only the following features:
  • Combinatorics - Currently just a couple methods to permute data and calculate some functions from combinatorics
  • Coherent noise - Perlin and Simplex noise in one, two, and three dimensions
  • Geometry - 2D and 3D points, vectors, lines, and line segments; polygons, circles, spheres, rectangles, and planes, including rotations, intersections, distance calculations, splitting concave polygons into convex ones, efficiently packing rectangular items into a space, etc.
  • Financial functions - Methods for computing rates, payments, periods, and present & future value of annuities, loans, etc.
  • Linear equation solvers and matrix factorizers - Gauss-Jordan, LU decomposition, QR decomposition, and singular value decomposition.
  • Matrices - 3x3, 4x4, and general matrices, including inversion, transposition, addition, subtraction, multiplication, and geometric rotation, scaling, and shearing
  • Number theory - Currently just GCD and LCM.
  • Optimization - Subdivision and Brent's method for one-dimensional function minimization. BFGS for multidimensional minimization. Penalty and barrier methods for general constrained multidimensional minimization.
  • Numerics - Fast, high-precision floating-point calculations and arbitrary-precision integer and rational math
  • Polynomials
  • Random number generators - Fast and flexible random number generator classes for a variety of purposes, including uniform, normal, and exponential variates. Easy to add new ones.
  • Root finding - Brent's method, Newton-Raphson, and Subdivision for one-dimensional functions. Newton-Raphson and Broyden's method for multidimensional and vector-valued functions.
  • Quaternions

Security

This library is documented and commented, and has some unit tests. It has the following features:
  • An OpenPGP system interface
  • An implementation of the OpenPGP interface for the GNU Privacy Guard (GnuPG/GPG). This allows you to use GPG programmatically from C# (or another .NET language) with a nice API, rather than having to shell out to the GPG executable. Essentially all GPG features are implemented except smart card support, because I don't have an OpenPGP-compatible smart card. :-( But as soon as I get one, that'll be implemented too. This library was previously called GPG.net.

Security UI

This library is a work in progress, but is already very usable. It has the following features:
  • Fancy user interface controls supporting almost all of the functionality in the security library. This is intended to be used along with the security library to help you write graphical applications that use OpenPGP. The controls can be used as-is, or used as a starting point and modified to suit your purposes.

Transactions

This library is well-developed already, although more features are planned.
  • Software Transactional Memory (STM) library - The best publically available STM library for .NET at the time of writing.
  • Transactional collections - array, list, and hash table
  • Transactional filesystem support (planned: to be implemented when I upgrade to an OS that supports the necessary primitives)

User Interfaces

This library is just started. It is a work in progress. It has the following features:
  • Text editor control - Suitable for writing a text or code editor (not finished).
  • Rich document editor control - Suitable for writing a simple desktop publishing program, word processor, web browser, or information display (not finished).
  • Wizards - A simple framework for creating application wizards, with good designer support.

Utilities

General utilities for .NET development.
  • Efficient array-based buffer classes, to make buffering code easy to write
  • Efficient methods for copying, clearing, and filling blocks of unmanaged memory. Faster than calling memcpy(), memset(), CopyMemory, RtlMoveMemory, etc.
  • LINQ extensions for simplified ordering, date-based min and max, efficient selections (e.g. take the least or greatest N items)
  • A library to simplify the creation of efficient binary encodings and encoders that can be used transparently with streams. Includes a highly-efficient base64 encoding (uses only a few bytes of memory regardless of the data size).
  • Path utilities for manipulating filenames, searching for files, and creating temporary files
  • A class to query system information, such as the number of CPU cores, hardware threads, independent processors, etc.
  • Task-based multithreading library, similar to the .NET 4 Task Parallel Library, but simpler and implemented for .NET 2.0
  • Useful and convenient string utilities
  • Type conversion utilities
  • Many, many extensions to System.Xml classes to make generating and parsing XML much less painful
  • Conversions to and from binary, binary hashes, CRC calculations, byte swaps, and other binary operations
  • A few useful collection extensions and comparison classes
  • Various date, GUID, and primitive type utilities
  • Miscellaneous commonly-used functions

Download

The latest version of the AdamMil.net libraries can be downloaded here. Alternately, if you can't figure out how to build it from source but still want to try it out, feel free to contact me.