Archive for category Programming

Code Prettification

This is a test of the code prettification feature/plug-in of Live Writer.  The following Snippit is from my k-means implementation.

CentroidDelegate<Point> pointCentroidFunc =
    delegate( IEnumerable<Point> collection, int count )
    {
        double sumX = 0;
        double sumY = 0;

        foreach( Point curPoint in collection )
        {
            sumX += curPoint.X;
            sumY += curPoint.Y;
        }

        Point newCentroid = new Point( sumX / count, sumY / count );

        return newCentroid;
    };

seqKMeans = new SequentialImpl<Point>( ( p1, p2 ) => p1.DistanceSquared( p2 ), pointCentroidFunc );
parKMeans = new ParallelImpl<Point>( ( p1, p2 ) => p1.DistanceSquared( p2 ), pointCentroidFunc );

k-Means class diagram

The class diagram thereof.  Again, will add more stuff at a later point, but for now, this is good.

No Comments

close