https://kotlinlang.org logo
Title
b

bjonnh

05/16/2018, 4:58 PM
One of my bottlenecks is
fun kroneckerProduct_(x: MatrixStore<Double>, y: MatrixStore<Double>): MatrixStore<Double> {
    val newRows = x.countRows() * y.countRows()
    val newCols = x.countColumns() * y.countColumns()
    val store = SparseStore.PRIMITIVE.make(newRows, newCols)
    var count = 0

    for (i in 0 until x.countRows()) {
        for (k in 0 until y.countRows()) {
            for (j in 0 until x.countColumns()) {
                for (l in 0 until y.countColumns()) {
                    store.set((count/newRows)%newCols, count%newRows , x.get(i, j) * y.get(k, l))
                    count++
                }
            }
        }
    }
    return store
}
Not using a sparse matrix made it 20% faster (there was no need for that one to make it sparse, all values are existing)