All entries for October 2006

October 31, 2006

Fabric 10th November

Writing about web page http://www.fabriclondon.com/club/listings.php

Oh boy, oh boy, oh boy! This is gonna be awesome:

THE SCRATCH PERVERT BEATDOWN

Fabric in London
Fri 10th Nov 06
9:30pm – 6:00am

Room One:

Scratch Perverts & Dynamite MC
Plan B (Live)
DJ Netik (2006 DMC World Champion )
Akala (Live)
DJ Craze & MC Armanni
Tucker (Live)
Kid Beyond
Joe Ransom

Room Two:

Andy C
Roni Size
Dillinja & Lemon D
Ed Rush & Optical
TC & Distorted Minds
Tony Vegas
MCs Dynamite, GQ & 2 Shy

Room Three:

Roots Manuva (DJ Set)
Blakey (1Xtra)
Mixologists
Jeff Metal

I can’t wait for this event. I already have a few people coming with me. If you want to join this epic night out give me a shout :D


October 27, 2006

Mono + Nemerle on Linux

Today I managed to get Mono installed on my DCS account. I had failed to compile and install from source before, so used the pre-compiled binary installed this time. It works like a charm – as easy as installing something on Windows! :)

Then I installed Nemerle – also easy. So will now be able to compile and run my project at university. This will be useful for demoing, etc.

I’ve not tested the Windows Forms support yet. Ideally I can create a UI capable of running under Windows and Linux with no recompiling…


October 25, 2006

Setting Up Code in VS

I created a Visual Studio solution that will hold all the code for the project. It will eventually contain:
  • Library – The code that has all the algorithms and data structures
  • Tests – NUnit test suites for the library
  • UI – Windows Form application to demo the library

Today I added Library and Tests projects to the solution. These are both Nemerle Class Library projects. I refactored yesterday’s experimental linear regression code into the library project to get the ball rolling.

The project root directory looks like this at the moment:

+ src
| + Equin.Vectorization.Library
  | - Equin.Vectorization.Library.nproj
  | - (various .n files)
| + Equin.Vectorization.Library.Tests
  | - Equin.Vectorization.Library.Tests.nproj
  | - Equin.Vectorization.Library.Tests.nunit
  | - (various .n files)
| - Equin.Vectorization.sln

A set of tests were also written to exercise the BestFit function.

Here is a sample of the testing code:

#pragma indent
using System
using NUnit.Framework
using Equin.Vectorization.Library

namespace Equin.Vectorization.Library.Tests
    [TestFixture] public class BestFit

        [Test] public Diagonal_Points() : void
            def points = [Point(0,0), Point(1,1), Point(2,2)]
            def line = points.BestFit()
            match (line)
                | Line.Normal(g, i) =>
                    Assert.AreEqual(1f, g)
                    Assert.AreEqual(0f, i)
                | _ => Assert.Fail("Line should have been Normal.")

Once compiled, the Tests assembly was opened in the NUnit test runner GUI. I may get a test runner for Visual Studio installed, so I don’t have to leave the IDE.

Having got the BestFit function working with the tests, I imported the solution into SubVersion (svn server runs on a separate machine downstairs). I then did the slightly annoying “rename old folder, create new folder, svn export” dance :) So I now have a solid project tree to work under.

I will need to setup a batch backup system soon to copy the repository to a university server. Maybe I’ll even get fancy continuous integration tool running to perform nightly builds, etc!


October 24, 2006

Linear Regression

I’ve made a start on Phase 1 of the project.
One of the goals of this phase is to get Nemerle up and running. As a warm up I implemented a linear regression algorithm. The idea being given a list of points, calculate the line of best fit.

First some basic type definitions:

[Record] class Point
    [Accessor] _x : float
    [Accessor] _y : float

[Record] variant Line
    | Normal
        [Accessor] _gradient : float
        [Accessor] _yIntercept : float
    | Vertical
        [Accessor] _xIntercept : float

These types use the Record macro to generate constructors that assign the fields in the order defined. For example, Point(10,20) .
The Accessor macro generates public property getters for the fields, so that they are externally visible. For example, pt.X + pt.Y .

A line is usually defined by a gradient and y-intercept. However, a vertical line has an infinite gradient and no y-intercept. Therefore the Line type is a variant capturing these two cases.

The best-fit function is defined as:

BestFitLine(points : list[Point]) : Line
    def SumWith(f) { points.Map(f).FoldLeft(0f, (x,y) => x + y) }

    def xSum = SumWith(pt => pt.X)
    def ySum = SumWith(pt => pt.Y)
    def xySum = SumWith(pt => pt.X * pt.Y)
    def xxSum = SumWith(pt => pt.X * pt.X)

    def denom = (xSum * xSum - points.Length * xxSum)
    if (denom >= -float.Epsilon && denom <= float.Epsilon)
        Line.Vertical(xSum / points.Length)
    else
        def gradient = (xSum * ySum - points.Length * xySum) / denom
        def intercept = (xSum * xySum - ySum * xxSum) / denom

        Line.Normal(gradient, intercept)

Nemerle language features to note here are:
  • Local functions – e.g. SumWith that projects a list of points using a function f, and then sums the values.
  • Lambda functions – e.g. pt => pt.X is a function from a Point to its X value.
  • Type inference – Nemerle is statically typed, so type inference is a great time saver.
  • Indentation sensistive block constructs as an optional alternative to braces and semi-colons.

The function can be used like this:

def points = [Point(1,10), Point(2,5), Point(3,9), Point(4,4)]
def line = BestFitLine(points)

match (line)
    | Line.Normal(g, i) =>
        WriteLine($"Gradient $g")
        WriteLine($"Intercept $i")
    | Line.Vertical(x) => WriteLine($"Vertical @ X = $x")

The match block is a powerful pattern matching construct, ideal for breaking apart variant types.
The $ macro is for splicing expressions into strings.

I am very pleased with Nemerle as a language so far. It’s functional features make algorithms succinct. The object oriented features will make building a large project managable and easy to use from other .NET projects.

The Visual Studio integration is not perfect yet. However, intellisense and the debugger will be very useful during development.


October 18, 2006

Project Specification

I have completed my initial project specification. This is meant to be a working document that evolves with the project.

The current version (0.1.1) is online www.equin.co.uk/uni/project/Specification-0.1.1.pdf

I will be handing it in tomorrow.


Ohloh

Writing about web page http://next.ohloh.net/projects/3222

http://www.ohloh.com/ is a web site that analyses open source projects and tells you how much time/money it would have taken develop them.

I just added BindingListView

Stats calculated by ohloh:
Codebase 3,723 LOC
Effort (est.) 1 Man Years
Avg. Salary 55000$/year
Total $43,431

Damn! That would solve my current money situation…
Of course the project is open source and so far I’ve had zero donations (despite 796 downloads!).
Although I do use the library in some private applications, where it saves me a whole bunch of time.


October 07, 2006

Nemerle VSIP

I am planning to write my project’s code using Nemerle . It has a good cross section of language features that I will leverage. The concentration on efficient algorithms and data structures will leverage the functional aspects of Nemerle. Whilst the vast .NET libraries and imperative constructs will make image handling and UI code easy.

Of course, being a Visual Studio junkie means I will require decent tool support. Luckily I managed to get the Nemerle VSIP (Visual Studio Integration Package) to work yesterday. Now I can edit code inside Visual Studio with the aid of intellisense, syntax highlighting and built-in compiler support.
The package is still somewhat under development, so I’m not sure how stable it will be. My project will not require too much code so I think it will hold up OK. To be honest, just having a Visual Studio “project” to manage building source, etc is a God send compared to manually writing build scripts and command line compiling!

I’m looking forward to getting this project off the ground. My current goal is writing the proposal document by week 3…


October 04, 2006

3rd Year Project

Having begun the 3rd of my Computer Science degree, I have to undertake a medium sized project for 1/4 of the year’s credit.
My project title is “Automating Vectorisation of Raster Geometry”. Basically, taking bitmap images (like maps) and converting points, lines or polygons into vector objects.
I will be using this blog to keep track of my progress and notes throughout the project life-cycle.
I will tag all project entries as “project”. So http://blogs.warwick.ac.uk/andrewdavey/tags/project will have all project related writings.


October 01, 2006

Circular, doubly–linked list

Follow-up to Loopy linked lists from codeMonkey.Weblog();

After taking considerable inspiration from a Haskell implementation , I managed to write some Nemerle code that creates a circular, doubly-linked list, without using any mutable variables.
It is not as elegant as the Haskell version because I had to use class fields to get lazy access to variables not yet assigned. Translating lines like:

mkDList xs = let (first,last) = go last xs first
             in  first

into Nemerle is tricky, even with the “lazy” macro.

So here’s the code…

#pragma indent

using System
using Nemerle

[Record] struct Node[T]
    public Prev : LazyValue[Node[T]]
    public Value : T
    public Next : LazyValue[Node[T]]

class LoopList[T]
    private first : Node[T]
    private last : Node[T]

    private this(items : list[T])
        def go = Go(lazy(last), items, lazy(first))
        (first,last) = (go.me, go.last)

    private class Go
        private rest : LazyValue[Node[T]]
        public me : LazyValue[Node[T]]
        public last : LazyValue[Node[T]]

        public this(prev : LazyValue[Node[T]], items : list[T], next : LazyValue[Node[T]])
            match((prev, items, next))
                | (prev, [], next) =>
                    (me, last) = (next, prev)

                | (prev, x::xs, next) =>
                    me = lazy(Node(prev, x, rest))
                    def go = Go(me, xs, next)
                    (rest, last) = (go.me, go.last)

    public static Create(xs : list[T]) : Node[T]
        LoopList(xs).first

// Test Code

mutable n = LoopList.Create([1,2,3,4])

Console.WriteLine("Forwards")
repeat(10)
    Console.Write($"$(n.Value) ")
    n = n.Next

n = n.Prev
Console.WriteLine()
Console.WriteLine("and back again")
repeat(10)
    Console.Write($"$(n.Value) ")
    n = n.Prev

// Output
/*
Forwards
1 2 3 4 1 2 3 4 1 2
and back again
2 1 4 3 2 1 4 3 2 1
*/

I’m planning to use this in my 3rd year project. The Weiler-Atherton algorithm requires a CDDL.


Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help http://www.webmd.com/eye–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry

Tags

October 2006

Mo Tu We Th Fr Sa Su
Sep |  Today  | Nov
                  1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31               

Galleries

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXIX