Do you think there is any performance difference b...
# announcements
c
Do you think there is any performance difference between these two implementations?
Copy code
val selectedAxis = FMatrixRMaj(normals.numRows, 1)
		for (i in 0 until normals.numRows)
			selectedAxis.set(i, axis, b.get(i) - normals.get(i, axis) * value)
Copy code
inline fun vector(rows: Int, init: (Int) -> Float): FMatrixRMaj {
	val ret = FMatrixRMaj(rows, 1)
	for (row in 0 until rows)
		ret.set(row, init(row))
	return ret
}

val selectedAxis1 = vector(normals.numRows) { row ->
	b.get(row) - normals.get(row, axis) * value
}
I really like the second one because I think it's a lot more readable in Kotlin code, but here the performance is very important. I don't think it makes a difference, but just in case
k
There is pretty much no differences in performance thanks to inlining. Though your two snippets do not seem to be exactly the same. One uses
set(Int, Int, Float)
the other one
set(Int, Float)
.
The inlining marker
int var10 = false
will be eradicated by the JIT compiler.
c
Good to know! Out of curiosity, what's the purpose of that int?
k
It helps the debugger to detect where an inlined call starts, so it can step through the code more easily.
c
Thanks ^^