forked from kscience/kmath
Track generated code
This commit is contained in:
parent
d46350e7b7
commit
956fe9b9e6
278
kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Matrices.kt
Normal file
278
kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Matrices.kt
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
package kscience.kmath.gsl
|
||||||
|
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
import kscience.kmath.linear.*
|
||||||
|
import org.gnu.gsl.*
|
||||||
|
|
||||||
|
internal class GslRealMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<Double, gsl_matrix>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslRealMatrix =
|
||||||
|
GslRealMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): Double = gsl_matrix_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: Double): Unit =
|
||||||
|
gsl_matrix_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslRealMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_memcpy(new, nativeHandle)
|
||||||
|
return GslRealMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslRealMatrix) return gsl_matrix_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslFloatMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix_float>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<Float, gsl_matrix_float>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslFloatMatrix =
|
||||||
|
GslFloatMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): Float = gsl_matrix_float_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: Float): Unit =
|
||||||
|
gsl_matrix_float_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslFloatMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_float_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_float_memcpy(new, nativeHandle)
|
||||||
|
return GslFloatMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_float_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslFloatMatrix) return gsl_matrix_float_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslShortMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix_short>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<Short, gsl_matrix_short>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslShortMatrix =
|
||||||
|
GslShortMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): Short = gsl_matrix_short_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: Short): Unit =
|
||||||
|
gsl_matrix_short_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslShortMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_short_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_short_memcpy(new, nativeHandle)
|
||||||
|
return GslShortMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_short_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslShortMatrix) return gsl_matrix_short_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslUShortMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix_ushort>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<UShort, gsl_matrix_ushort>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslUShortMatrix =
|
||||||
|
GslUShortMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): UShort = gsl_matrix_ushort_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: UShort): Unit =
|
||||||
|
gsl_matrix_ushort_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslUShortMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_ushort_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_ushort_memcpy(new, nativeHandle)
|
||||||
|
return GslUShortMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_ushort_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslUShortMatrix) return gsl_matrix_ushort_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslLongMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix_long>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<Long, gsl_matrix_long>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslLongMatrix =
|
||||||
|
GslLongMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): Long = gsl_matrix_long_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: Long): Unit =
|
||||||
|
gsl_matrix_long_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslLongMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_long_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_long_memcpy(new, nativeHandle)
|
||||||
|
return GslLongMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_long_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslLongMatrix) return gsl_matrix_long_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslULongMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix_ulong>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<ULong, gsl_matrix_ulong>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslULongMatrix =
|
||||||
|
GslULongMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): ULong = gsl_matrix_ulong_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: ULong): Unit =
|
||||||
|
gsl_matrix_ulong_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslULongMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_ulong_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_ulong_memcpy(new, nativeHandle)
|
||||||
|
return GslULongMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_ulong_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslULongMatrix) return gsl_matrix_ulong_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslIntMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix_int>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<Int, gsl_matrix_int>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslIntMatrix =
|
||||||
|
GslIntMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): Int = gsl_matrix_int_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: Int): Unit =
|
||||||
|
gsl_matrix_int_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslIntMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_int_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_int_memcpy(new, nativeHandle)
|
||||||
|
return GslIntMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_int_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslIntMatrix) return gsl_matrix_int_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslUIntMatrix(
|
||||||
|
override val nativeHandle: CPointer<gsl_matrix_uint>,
|
||||||
|
features: Set<MatrixFeature> = emptySet()
|
||||||
|
) : GslMatrix<UInt, gsl_matrix_uint>() {
|
||||||
|
override val rowNum: Int
|
||||||
|
get() = nativeHandle.pointed.size1.toInt()
|
||||||
|
|
||||||
|
override val colNum: Int
|
||||||
|
get() = nativeHandle.pointed.size2.toInt()
|
||||||
|
|
||||||
|
override val features: Set<MatrixFeature> = features
|
||||||
|
|
||||||
|
override fun suggestFeature(vararg features: MatrixFeature): GslUIntMatrix =
|
||||||
|
GslUIntMatrix(nativeHandle, this.features + features)
|
||||||
|
|
||||||
|
override operator fun get(i: Int, j: Int): UInt = gsl_matrix_uint_get(nativeHandle, i.toULong(), j.toULong())
|
||||||
|
|
||||||
|
override operator fun set(i: Int, j: Int, value: UInt): Unit =
|
||||||
|
gsl_matrix_uint_set(nativeHandle, i.toULong(), j.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslUIntMatrix {
|
||||||
|
val new = requireNotNull(gsl_matrix_uint_alloc(rowNum.toULong(), colNum.toULong()))
|
||||||
|
gsl_matrix_uint_memcpy(new, nativeHandle)
|
||||||
|
return GslUIntMatrix(new, features)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_matrix_uint_free(nativeHandle)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslUIntMatrix) return gsl_matrix_uint_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
173
kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Vectors.kt
Normal file
173
kmath-gsl/src/nativeMain/kotlin/kscience/kmath/gsl/_Vectors.kt
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
package kscience.kmath.gsl
|
||||||
|
|
||||||
|
import kotlinx.cinterop.*
|
||||||
|
import org.gnu.gsl.*
|
||||||
|
|
||||||
|
internal class GslRealVector(override val nativeHandle: CPointer<gsl_vector>) : GslVector<Double, gsl_vector>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): Double = gsl_vector_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: Double): Unit = gsl_vector_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslRealVector {
|
||||||
|
val new = requireNotNull(gsl_vector_alloc(size.toULong()))
|
||||||
|
gsl_vector_memcpy(new, nativeHandle)
|
||||||
|
return GslRealVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslRealVector) return gsl_vector_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslFloatVector(override val nativeHandle: CPointer<gsl_vector_float>) : GslVector<Float, gsl_vector_float>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): Float = gsl_vector_float_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: Float): Unit = gsl_vector_float_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslFloatVector {
|
||||||
|
val new = requireNotNull(gsl_vector_float_alloc(size.toULong()))
|
||||||
|
gsl_vector_float_memcpy(new, nativeHandle)
|
||||||
|
return GslFloatVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslFloatVector) return gsl_vector_float_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_float_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslShortVector(override val nativeHandle: CPointer<gsl_vector_short>) : GslVector<Short, gsl_vector_short>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): Short = gsl_vector_short_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: Short): Unit = gsl_vector_short_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslShortVector {
|
||||||
|
val new = requireNotNull(gsl_vector_short_alloc(size.toULong()))
|
||||||
|
gsl_vector_short_memcpy(new, nativeHandle)
|
||||||
|
return GslShortVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslShortVector) return gsl_vector_short_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_short_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslUShortVector(override val nativeHandle: CPointer<gsl_vector_ushort>) : GslVector<UShort, gsl_vector_ushort>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): UShort = gsl_vector_ushort_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: UShort): Unit = gsl_vector_ushort_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslUShortVector {
|
||||||
|
val new = requireNotNull(gsl_vector_ushort_alloc(size.toULong()))
|
||||||
|
gsl_vector_ushort_memcpy(new, nativeHandle)
|
||||||
|
return GslUShortVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslUShortVector) return gsl_vector_ushort_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_ushort_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslLongVector(override val nativeHandle: CPointer<gsl_vector_long>) : GslVector<Long, gsl_vector_long>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): Long = gsl_vector_long_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: Long): Unit = gsl_vector_long_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslLongVector {
|
||||||
|
val new = requireNotNull(gsl_vector_long_alloc(size.toULong()))
|
||||||
|
gsl_vector_long_memcpy(new, nativeHandle)
|
||||||
|
return GslLongVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslLongVector) return gsl_vector_long_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_long_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslULongVector(override val nativeHandle: CPointer<gsl_vector_ulong>) : GslVector<ULong, gsl_vector_ulong>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): ULong = gsl_vector_ulong_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: ULong): Unit = gsl_vector_ulong_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslULongVector {
|
||||||
|
val new = requireNotNull(gsl_vector_ulong_alloc(size.toULong()))
|
||||||
|
gsl_vector_ulong_memcpy(new, nativeHandle)
|
||||||
|
return GslULongVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslULongVector) return gsl_vector_ulong_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_ulong_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslIntVector(override val nativeHandle: CPointer<gsl_vector_int>) : GslVector<Int, gsl_vector_int>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): Int = gsl_vector_int_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: Int): Unit = gsl_vector_int_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslIntVector {
|
||||||
|
val new = requireNotNull(gsl_vector_int_alloc(size.toULong()))
|
||||||
|
gsl_vector_int_memcpy(new, nativeHandle)
|
||||||
|
return GslIntVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslIntVector) return gsl_vector_int_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_int_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GslUIntVector(override val nativeHandle: CPointer<gsl_vector_uint>) : GslVector<UInt, gsl_vector_uint>() {
|
||||||
|
override val size: Int
|
||||||
|
get() = nativeHandle.pointed.size.toInt()
|
||||||
|
|
||||||
|
override fun get(index: Int): UInt = gsl_vector_uint_get(nativeHandle, index.toULong())
|
||||||
|
override fun set(index: Int, value: UInt): Unit = gsl_vector_uint_set(nativeHandle, index.toULong(), value)
|
||||||
|
|
||||||
|
override fun copy(): GslUIntVector {
|
||||||
|
val new = requireNotNull(gsl_vector_uint_alloc(size.toULong()))
|
||||||
|
gsl_vector_uint_memcpy(new, nativeHandle)
|
||||||
|
return GslUIntVector(new)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GslUIntVector) return gsl_vector_uint_equal(nativeHandle, other.nativeHandle) == 1
|
||||||
|
return super.equals(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close(): Unit = gsl_vector_uint_free(nativeHandle)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user