Search code examples
javamatrixujmp

How to dynamically add or remove columns / rows in a matrix?


I'm using the Universal Java Matrix Package (UJMP) for handling matrices. My problem now is that the matrices are fixed in size but I would like to add or remove rows or columns.

Does somebody have an idea how this can be achieved efficiently without just creating a new matrix each time a row or columns gets added/removed?


Solution

  • I believe that matrices in UJMP implement the ObjectCalculations interface, which has deleteRows and deleteColumns methods of various signatures that return either a new Matrix or a reference to a modified original matrix, depending on how they are called.