Equation Solutions - This is where I met C# (2004)

Sep 2nd, 2008 by ca7l0s.9 | 0

Equation Solutions

My first ever venture into C#, as far as I can remember at least. :P I started this only on my 2nd year of college. Why? Well because after learning C/C++ early in my freshman year, I shifted to trying Java. It never caught up with me, though. However, Java became an exquisite stepping stone to C#, unlike C/C++, which wasn’t purely OOP. I always say that once you know Java, you already  know C#.

Anyways, the project was simple enough. The user provides a text input file containing a set of test cases where each case has one system of equations with N unknowns. The objective of the tool was to solve for the N unknowns using matrix inversion.

It wasn’t a class project per se. I just like implementing concepts into homemade pancakes. :D I find it a nice way to learn the concept and enjoy writing programs at the same time. I remember writing two satellite libraries, one for matrix operations and another for evaluating equations. The third assembly was a demo application which used the mentioned libraries, parsed and evaluated the user’s input, and displayed the results.1

Equation Solutions input file

With the risk of sounding like an ACM-ICPC problem, the input file has a number of test cases terminated by a blank line. On the first line of each test case is N, the number of unknowns to be solved for, thus also the number of equations to be read. The next N lines contains the series of equations belonging to the system.

The whole project was a Microsoft Visual Studio .NET 2003 solution. Sadly, the source was lost during the first mass data extinction. Only a vague memory of the implementation remains. I remember a character-by-character parsing scheme but should I do this now, I would prefer to use Regular Expressions. The constants are fed into a matrix which could have been as simple as a square two dimensional array of class Double. Then, the inverse of that matrix object is computed and the unknowns inferred. Done.

Why does C# appeal to me so much? Well, I don’t have a straight forward answer. But maybe it’s because of the way syntax joins together into such beautiful code. Or maybe it’s so easy to write in it and yet it can scale to support enterprise level applications. Or maybe it’s the IDE. Or maybe, it’s all of that. Whatever the reason, I’m rooting to make my specialization as a C# software engineer. Write now, I’m writing parts of an enterprise application using Microsoft Visual Studio 2008 and so far I’m enjoying it. All the cool new features like LINQ, lambdas, anonymous classes, object and collection constructors and others makes this version of C# worth trying out.2 ;)

P.S.: I had this as a draft for over two months, during the time when I didn’t have time to blog. I’m glad I’m able to publish it finally. :D

  1. I also remember creating a whole nother application to demo matrix operations which included creating/modifiying/delete matrices, loading and saving matrix sets from and into files and evaluating all matrix operations. []
  2. I did have an affair with C++ back in my senior year but was because I made a lexical analyzer, i.e. a really low level program but I still made it object-oriented. The infidelity didn’t end there. :o Just last year, I was involved with PHP and Ruby though they aren’t exactly strongly-typed or for windows applications. Maybe it’s not cheating at all. :D []

Leave a Reply