diff --git a/buildSrc/src/main/kotlin/kscience/kmath/gsl/codegen/vectorsCodegen.kt b/buildSrc/src/main/kotlin/kscience/kmath/gsl/codegen/vectorsCodegen.kt index 4a903d9a7..87acd258c 100644 --- a/buildSrc/src/main/kotlin/kscience/kmath/gsl/codegen/vectorsCodegen.kt +++ b/buildSrc/src/main/kotlin/kscience/kmath/gsl/codegen/vectorsCodegen.kt @@ -23,13 +23,11 @@ private fun KtPsiFactory.createVectorClass( override val size: Int get() = nativeHandleChecked().pointed.size.toInt() - override fun get(index: Int): $kotlinTypeName = ${ - fn("gsl_vectorRget", - cTypeName) - }(nativeHandleChecked(), index.toULong()) - override fun set(index: Int, value: $kotlinTypeName): Unit = ${ - fn("gsl_vectorRset", cTypeName) - }(nativeHandleChecked(), index.toULong(), value) + override operator fun get(index: Int): $kotlinTypeName = + ${fn("gsl_vectorRget", cTypeName)}(nativeHandleChecked(), index.toULong()) + + override operator fun set(index: Int, value: $kotlinTypeName): Unit = + ${fn("gsl_vectorRset", cTypeName)}(nativeHandleChecked(), index.toULong(), value) override fun copy(): $className { val new = requireNotNull(${fn("gsl_vectorRalloc", cTypeName)}(size.toULong())) diff --git a/kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Vectors.kt b/kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Vectors.kt index 43c21fb04..d7ed4718b 100644 --- a/kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Vectors.kt +++ b/kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Vectors.kt @@ -8,8 +8,11 @@ internal class GslRealVector(override val nativeHandle: CPointer, sc override val size: Int get() = nativeHandleChecked().pointed.size.toInt() - override fun get(index: Int): Double = gsl_vector_get(nativeHandleChecked(), index.toULong()) - override fun set(index: Int, value: Double): Unit = gsl_vector_set(nativeHandleChecked(), index.toULong(), value) + override operator fun get(index: Int): Double = + gsl_vector_get(nativeHandleChecked(), index.toULong()) + + override operator fun set(index: Int, value: Double): Unit = + gsl_vector_set(nativeHandleChecked(), index.toULong(), value) override fun copy(): GslRealVector { val new = requireNotNull(gsl_vector_alloc(size.toULong())) @@ -32,8 +35,11 @@ internal class GslFloatVector(override val nativeHandle: CPointer, override val size: Int get() = nativeHandleChecked().pointed.size.toInt() - override fun get(index: Int): Int = gsl_vector_int_get(nativeHandleChecked(), index.toULong()) - override fun set(index: Int, value: Int): Unit = gsl_vector_int_set(nativeHandleChecked(), index.toULong(), value) + override operator fun get(index: Int): Int = + gsl_vector_int_get(nativeHandleChecked(), index.toULong()) + + override operator fun set(index: Int, value: Int): Unit = + gsl_vector_int_set(nativeHandleChecked(), index.toULong(), value) override fun copy(): GslIntVector { val new = requireNotNull(gsl_vector_int_alloc(size.toULong())) @@ -176,8 +197,11 @@ internal class GslUIntVector(override val nativeHandle: CPointer