Worst c++ code ever — My first matrix-class
My first C++-code I wrote was a finite-element-solver ( in short FE ) for my master-thesis. The task was complex: implement a non-linear algorithm to calculate the maximum possible load for user-defined 2D-steal structures by using the plastical capacity of steal-beams. You can use this algorithm to design much more filigree steel-structures than using only the elastic capacity. This helps a lot to save steel and money.
The task in short:
- You need to write a FE-solver for 2D-beam-elements
- Calculate the forces and moments for your model
- Increase the loads until they reaches the boundary of the elastic capacity
- Add a joint there
- Goto 1 until the model collapses
Seems to be easy so I said yes to my professor when he asked me. But It took 10 months to complete this task.
The first thing you need for this are vectors and matrixes. So I started to implement a vector- and a matrix-class. I need to reserve the number of elements dynamically. I looked around how to do this and I found: a linked list. Easy to add new elements to the end of the matrix / vector. Of course I used my own implementation, no STL or another implementation. In 2000 I didn’t found any books about the STL. The only book I had…