linspace

inline fun <T : Number> Multik.linspace(    start: Int,     stop: Int,     num: Int = 50): D1Array<T>

Returns evenly spaced values within a given interval start, stop, more precisely than arange.

Return

D1Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.linspace<Float>(-1, 1, 9)
println(ndarray) // [-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0] 
   //sampleEnd
}

Parameters

start

starting value of the interval.

stop

end of the interval.

num

number of values. Default is 50.


inline fun <T : Number> Multik.linspace(    start: Double,     stop: Double,     num: Int = 50): D1Array<T>

Returns evenly spaced values within a given interval start, stop, where start and stop is Double.

Return

D1Array.

Samples

import org.jetbrains.kotlinx.multik.api.*
import org.jetbrains.kotlinx.multik.ndarray.data.D2
import org.jetbrains.kotlinx.multik.ndarray.data.D3
import org.jetbrains.kotlinx.multik.ndarray.data.DN
import org.jetbrains.kotlinx.multik.ndarray.data.DataType
import kotlin.test.Test
fun main() { 
   //sampleStart 
   val ndarray = mk.linspace<Double>(-1.5, 2.1, 7)
println(ndarray) // [-1.5, -0.9, -0.30000000000000004, 0.2999999999999998, 0.8999999999999999, 1.5, 2.1] 
   //sampleEnd
}

See also

Parameters

start

starting value of the interval.

stop

end of the interval.

num

number of values.