0

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?

demongolem
  • 9,474
  • 36
  • 90
  • 105
machinery
  • 5,972
  • 12
  • 67
  • 118

1 Answers1

0

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.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • Thank you, I did not see it, I will check it out. But adding seems not to be natively supported. – machinery Feb 07 '16 at 01:26
  • @machinery - It's awkward, but I think you can insert rows or columns by first splitting the matrix in two (using `ObjectCalculations.submatrix()`) and then pasting the pieces back together with the additional rows or columns (using `MiscGeneralDoubleCalculations.appendHorizontally()` or `appendVertically()`). There may be a better way, but you can at least package up this way into a utility method or two. – Ted Hopp Feb 07 '16 at 15:13