All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.danielTucano.matplotlib.np.arange.kt Maven / Gradle / Ivy

Go to download

Matplotlib for kotlin: A simple graph plot library for kotlin with powerful python matplotlib

The newest version!
package io.github.danielTucano.matplotlib.np

import io.github.danielTucano.matplotlib.np.NPVar.Companion.npVarNumber
import org.ejml.simple.SimpleMatrix
import io.github.danielTucano.python.PythonScriptBuilder

fun arange(limInf: Double, limSup: Double, step: Double): NPVar {
    return object : NPVar {
        override val variableName: String = "np_var_$npVarNumber"
        init {
            PythonScriptBuilder.addCommand("$variableName = np.arange($limInf,$limSup,$step)")
        }
    }
}

fun meshgrid(xValues: List, yValues: List): Pair {
    val X = SimpleMatrix(
        yValues.map {
            xValues.toDoubleArray()
        }.toTypedArray()
    )

    val Y = SimpleMatrix(
        yValues.mapIndexed { index, _ ->
            DoubleArray(xValues.size) {yValues[index]}
        }.toTypedArray()
    )

    return X to Y
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy