DScalar

interface DScalar : DTensor

A differentiable scalar (float). We represent a number DScalar as either

  • a FloatScalar, which is a wrapper around a float, or

  • a ForwardScalar for forward differentiation with a DScalar primal value, and a DTensor tangent, or

  • a ReverseScalar for reverse mode differentiation.

Functions

get
Link copied to clipboard
open operator fun get(index: Int): DTensor
open operator fun get(vararg indices: Int): DTensor
toCodeString
Link copied to clipboard
open fun toCodeString(): String
wrap
Link copied to clipboard
open override fun wrap(wrapper: Wrapper): DTensor

Wrapper around the tensor

Properties

derivativeID
Link copied to clipboard
abstract val derivativeID: DerivativeID

Each derivative is assigned a unique DerivativeID

indices
Link copied to clipboard
open val indices: Iterator<IntArray>

An iterator over the indices for the tensor

isScalar
Link copied to clipboard
open val isScalar: Boolean

True if the tensor is a scalar.

operations
Link copied to clipboard
abstract val operations: Operations

The operations available on a tensor.

primal
Link copied to clipboard
abstract override val primal: DScalar

primal points to the actual tensor

rank
Link copied to clipboard
open override val rank: Int

rank is the number of dimension of a tensor. scalars always have a rank of 0

shape
Link copied to clipboard
open override val shape: Shape

shape indicates the number of dimensions and the length of the dimensions. Since scalars have rank 0, shape always returns Shape()

size
Link copied to clipboard
open val size: Int

The total number of elements of this tensor.

Inheritors

FloatScalar
Link copied to clipboard
ForwardScalar
Link copied to clipboard
GpuFloatScalar
Link copied to clipboard
ReverseScalar
Link copied to clipboard
TracingScalar
Link copied to clipboard

Extensions

basePrimal
Link copied to clipboard
fun DScalar.basePrimal(): FloatScalar

Returns the primal value as a FloatScalar.

compareTo
Link copied to clipboard
operator fun DScalar.compareTo(right: Float): Int
operator fun DScalar.compareTo(right: DScalar): Int
div
Link copied to clipboard
operator fun DScalar.div(right: Int): DScalar
operator fun DScalar.div(right: DScalar): DScalar
operator fun DScalar.div(right: Float): DScalar
eq
Link copied to clipboard
infix fun DScalar.eq(other: DScalar): DScalar
infix fun DScalar.eq(other: Float): DScalar
ge
Link copied to clipboard
infix fun DScalar.ge(other: DScalar): DScalar
infix fun DScalar.ge(other: Float): DScalar
gt
Link copied to clipboard
infix fun DScalar.gt(other: DScalar): DScalar
infix fun DScalar.gt(other: Float): DScalar
le
Link copied to clipboard
infix fun DScalar.le(other: DScalar): DScalar
infix fun DScalar.le(other: Float): DScalar
lt
Link copied to clipboard
infix fun DScalar.lt(other: DScalar): DScalar
infix fun DScalar.lt(other: Float): DScalar
minus
Link copied to clipboard
operator fun DScalar.minus(right: Float): DScalar

Scalar (floating-point) subtraction.

operator fun DScalar.minus(right: DScalar): DScalar
ne
Link copied to clipboard
infix fun DScalar.ne(other: DScalar): DScalar
infix fun DScalar.ne(other: Float): DScalar
plus
Link copied to clipboard
operator fun DScalar.plus(right: Float): DScalar

The addition of a floating-point number to a DScalar simply updates the primal with the scaled value.

operator fun DScalar.plus(right: DScalar): DScalar

Scalar (floating-point) addition.

pow
Link copied to clipboard
fun DScalar.pow(x: DScalar): DScalar
fun DScalar.pow(x: Float): DScalar
fun DScalar.pow(x: Int): DScalar
primal
Link copied to clipboard
fun DScalar.primal(derivativeID: DerivativeID): DScalar
relu
Link copied to clipboard
@JvmName(name = "DScalarRelu")
fun DScalar.relu(): DScalar
times
Link copied to clipboard
operator fun DScalar.times(right: Float): DScalar
operator fun DScalar.times(right: DScalar): DScalar
operator fun DScalar.times(right: DTensor): DTensor
unaryMinus
Link copied to clipboard
operator fun DScalar.unaryMinus(): DScalar