Table of Contents

Class ConstNode

Namespace
NumSharp.Backends.Iteration
Assembly
NumSharp.dll
public sealed class ConstNode : NDExpr
Inheritance
ConstNode
Inherited Members

Constructors

ConstNode(bool)

public ConstNode(bool v)

Parameters

v bool

ConstNode(char)

public ConstNode(char v)

Parameters

v char

ConstNode(decimal)

public ConstNode(decimal v)

Parameters

v decimal

ConstNode(double)

public ConstNode(double v)

Parameters

v double

ConstNode(Half)

public ConstNode(Half v)

Parameters

v Half

ConstNode(int)

public ConstNode(int v)

Parameters

v int

ConstNode(long)

public ConstNode(long v)

Parameters

v long

ConstNode(Complex)

public ConstNode(Complex v)

Parameters

v Complex

ConstNode(float)

public ConstNode(float v)

Parameters

v float

ConstNode(uint)

public ConstNode(uint v)

Parameters

v uint

ConstNode(ulong)

public ConstNode(ulong v)

Parameters

v ulong

Properties

SupportsSimd

True if this node and its entire sub-tree have a SIMD emit path. Structural and type-independent — prefer SupportsSimdAt(NPTypeCode) for the compile decision, since some ops only vectorize at certain element types/runtimes.

public override bool SupportsSimd { get; }

Property Value

bool

Methods

AppendSignature(StringBuilder)

Appends the literal's part of the kernel key: its kind and its exact value, so two literals that differ in either compile to distinct kernels (2 and 2.0 type differently; 2m and 2 emit differently at a Decimal target).

public override void AppendSignature(StringBuilder sb)

Parameters

sb StringBuilder

The key being built.

Remarks

The kernel cache is keyed by this text, and the kernel bakes the literal into its IL, so the text must be INJECTIVE over the values the IL can tell apart: a float is written as its 64 bits (hex), as the structural cache compares it (StructureEquals(NDExpr, NDExprOperandScratch)). Text from .NET's formatter is not injective, and a collision hands a tree another literal's kernel — a wrong result, silently: ToString("R") prints every NaN alike, on the .NET 10 runtime (10.0.1) prints 2^-25 and the double below it as the same 16 digits, and without an invariant culture prints Complex(1.5, 2) and Complex(1, 5.2) alike under a comma decimal separator ("1,5,2"). A decimal's invariant text is exact and keeps its scale (1.0m and 1.00m, which emit different constants, stay apart); an integer's digits are exact in every culture.

EmitScalar(ILGenerator, NDExprCompileContext)

Emit scalar code. On exit, the evaluation stack must have exactly one value of dtype ctx.OutputType.

public override void EmitScalar(ILGenerator il, NDExprCompileContext ctx)

Parameters

il ILGenerator
ctx NDExprCompileContext

EmitVector(ILGenerator, NDExprCompileContext)

Emit vector code. On exit, the evaluation stack must have exactly one Vector{W}<T> of element type ctx.OutputType. Called only when SupportsSimd is true and all input types equal the output type.

public override void EmitVector(ILGenerator il, NDExprCompileContext ctx)

Parameters

il ILGenerator
ctx NDExprCompileContext