v0.2.0 #206

Merged
altavir merged 210 commits from dev into master 2021-02-21 16:33:25 +03:00
Showing only changes of commit f46826f2b1 - Show all commits

View File

@ -19,10 +19,9 @@ internal inline fun <T : Any, H : CStructVar> GslMatrix<T, H>.fill(initializer:
internal inline fun <T : Any, H : CStructVar> GslVector<T, H>.fill(initializer: (Int) -> T): GslVector<T, H> = internal inline fun <T : Any, H : CStructVar> GslVector<T, H>.fill(initializer: (Int) -> T): GslVector<T, H> =
apply { (0 until size).forEach { index -> this[index] = initializer(index) } } apply { (0 until size).forEach { index -> this[index] = initializer(index) } }
public abstract class GslMatrixContext< public abstract class GslMatrixContext<T : Any, H1 : CStructVar, H2 : CStructVar> internal constructor(
T : Any, internal val scope: DeferScope
H1 : CStructVar, ) : MatrixContext<T, GslMatrix<T, H1>> {
H2 : CStructVar> internal constructor(internal val scope: DeferScope) : MatrixContext<T> {
init { init {
ensureHasGslErrorHandler() ensureHasGslErrorHandler()
} }
@ -46,7 +45,10 @@ public abstract class GslMatrixContext<
public class GslRealMatrixContext(scope: DeferScope) : GslMatrixContext<Double, gsl_matrix, gsl_vector>(scope) { public class GslRealMatrixContext(scope: DeferScope) : GslMatrixContext<Double, gsl_matrix, gsl_vector>(scope) {
override fun produceDirtyMatrix(rows: Int, columns: Int): GslMatrix<Double, gsl_matrix> = override fun produceDirtyMatrix(rows: Int, columns: Int): GslMatrix<Double, gsl_matrix> =
GslRealMatrix(nativeHandle = requireNotNull(gsl_matrix_alloc(rows.toULong(), columns.toULong())), scope = scope) GslRealMatrix(
nativeHandle = requireNotNull(gsl_matrix_alloc(rows.toULong(), columns.toULong())),
scope = scope
)
override fun produceDirtyVector(size: Int): GslVector<Double, gsl_vector> = override fun produceDirtyVector(size: Int): GslVector<Double, gsl_vector> =
GslRealVector(nativeHandle = requireNotNull(gsl_vector_alloc(size.toULong())), scope = scope) GslRealVector(nativeHandle = requireNotNull(gsl_vector_alloc(size.toULong())), scope = scope)
@ -131,7 +133,8 @@ public class GslFloatMatrixContext(scope: DeferScope) :
public class GslComplexMatrixContext(scope: DeferScope) : public class GslComplexMatrixContext(scope: DeferScope) :
GslMatrixContext<Complex, gsl_matrix_complex, gsl_vector_complex>(scope) { GslMatrixContext<Complex, gsl_matrix_complex, gsl_vector_complex>(scope) {
override fun produceDirtyMatrix(rows: Int, columns: Int): GslMatrix<Complex, gsl_matrix_complex> = GslComplexMatrix( override fun produceDirtyMatrix(rows: Int, columns: Int): GslMatrix<Complex, gsl_matrix_complex> =
GslComplexMatrix(
nativeHandle = requireNotNull(gsl_matrix_complex_alloc(rows.toULong(), columns.toULong())), nativeHandle = requireNotNull(gsl_matrix_complex_alloc(rows.toULong(), columns.toULong())),
scope = scope scope = scope
) )