Thanks a lot, I'll try to write it with this API :) Honestly it says the low level API is a bit better when it comes to performance, and since I'm expecting this bit of code to be ran very often, I'm trying to put all the chances on my side—and I do realize it might be a bit naive to try and do that when I know close to nothing about the library and I don't have a real benchmark to back this up, but well...
For this use case I don't really need the extra precision of 64-bit floats so I figured I'd get a little out of it, but speed is more important than memory usage here, so maybe you have some information on what to choose?
Thanks for the given functions, I managed to write something that works, but it's probably not that performant, I'll rewrite it with your functions:
// Solving A x = b
var solver: LinearSolverDense<FMatrixRMaj> =
val solution = FMatrixRMaj(normals.numRows, normals.numCols)
// Calculates b - A x
var rs2 = new FMatrixRMaj(normals.numRows, normals.numCols)
MatrixVectorMult_FDRM.mult(normals, solution, rs2)
SimpleOperations_FDRM().minus(b, rs2, rs2)
// Sums the square of the results, to get the residual
var residual = 0f
for (int i = 0; i < rs2.getNumElements(); i++)
residual += rs2.get(i) * rs2.get(i)