Worst c++ code ever — My first matrix-class

kim kulling
LegacyCode
Published in
3 min readApr 15, 2020

--

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:

  1. You need to write a FE-solver for 2D-beam-elements
  2. Calculate the forces and moments for your model
  3. Increase the loads until they reaches the boundary of the elastic capacity
  4. Add a joint there
  5. 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…

--

--

kim kulling
LegacyCode

I am working as a System-Architect and Cyber-Security Engineer. I am the Asset-Importer-Lib Lead programmer. My Linketree https://linktr.ee/kimkulling