Big Chungus
06/07/2022, 4:42 PMPavel Gorgulov
06/07/2022, 5:41 PMBig Chungus
06/07/2022, 5:42 PMPavel Gorgulov
06/07/2022, 5:43 PMBig Chungus
06/07/2022, 5:43 PMPavel Gorgulov
06/07/2022, 6:16 PMroll
without specifying an axis, it’s just a shift.
You can use `Collections.rotate`:
fun D2Array<Int>.roll(n: Int): D2Array<Int> {
val data = this.toList().also { Collections.rotate(it, n) }
return D2Array(MemoryViewIntArray(data.toIntArray()), shape = this.shape.clone(), dim = this.dim)
}
or use sliceArray
fun D2Array<Int>.roll(n: Int): D2Array<Int> {
val newData = this.data.getIntArray().let { it.sliceArray(size - n until size) + it.sliceArray(0 until size - n) }
return D2Array(MemoryViewIntArray(newData), shape = this.shape.clone(), dim = this.dim)
}
Big Chungus
06/07/2022, 6:17 PMimg = np.roll(img, dy, axis=0)
img = np.roll(img, dx, axis=1)
Pavel Gorgulov
06/07/2022, 6:20 PMstrides
Big Chungus
06/07/2022, 6:25 PMPavel Gorgulov
06/07/2022, 6:36 PMBig Chungus
06/07/2022, 6:36 PMaltavir
06/07/2022, 8:11 PMBig Chungus
06/07/2022, 8:20 PMaltavir
06/08/2022, 5:47 AM