Class Range
A range of values from 0 to N-1. The size N may be an integer expression or constant.
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Models
Assembly: Microsoft.ML.Probabilistic.Compiler.dll
Syntax
public class Range : IModelExpression, IStatementBlock
Constructors
Range(IModelExpression<Int32>)
Constructs a range whose size is given by an integer-value expression.
Declaration
public Range(IModelExpression<int> size)
Parameters
| Type | Name | Description |
|---|---|---|
| IModelExpression<Int32> | size | An expression giving the size of the range |
Range(Range)
Copy constructor
Declaration
protected Range(Range parent)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | parent |
Range(Int32)
Constructs a range containing values from 0 to N-1.
Declaration
public Range(int N)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | N | The number of elements in the range, including zero. |
Fields
attributes
The attributes associated with this Range.
Declaration
protected List<ICompilerAttribute> attributes
Field Value
| Type | Description |
|---|---|
| List<ICompilerAttribute> |
name
Name
Declaration
protected string name
Field Value
| Type | Description |
|---|---|
| String |
nameInGeneratedCode
Name used in generated code
Declaration
protected string nameInGeneratedCode
Field Value
| Type | Description |
|---|---|
| String |
Properties
Name
Name of the range
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
Parent
Range from which this range was cloned, or null if none.
Declaration
public Range Parent { get; }
Property Value
| Type | Description |
|---|---|
| Range |
Size
Model expression for size of the range
Declaration
public IModelExpression<int> Size { get; }
Property Value
| Type | Description |
|---|---|
| IModelExpression<Int32> |
SizeAsInt
Returns the size of the range as an integer. This will fail if the size is not a constant, for example, if it is a Given value.
Declaration
public int SizeAsInt { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Methods
AddAttribute(ICompilerAttribute)
Adds an attribute to this range. Attributes can be used to modify how inference is performed on the range.
Declaration
public void AddAttribute(ICompilerAttribute attr)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompilerAttribute | attr | The attribute to add |
Attrib(ICompilerAttribute)
Inline method for adding an attribute to a range. This method returns the range object, so that is can be used in an inline expression.
Declaration
public Range Attrib(ICompilerAttribute attr)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompilerAttribute | attr | The attribute to add |
Returns
| Type | Description |
|---|---|
| Range | The range object |
Clone()
Create a copy of a range. The copy can be used to index the same arrays as the original range.
Declaration
public Range Clone()
Returns
| Type | Description |
|---|---|
| Range |
GetAttributes<AttributeType>()
Get all attributes of this range having type AttributeType.
Declaration
public IEnumerable<AttributeType> GetAttributes<AttributeType>()
where AttributeType : ICompilerAttribute
Returns
| Type | Description |
|---|---|
| IEnumerable<AttributeType> |
Type Parameters
| Name | Description |
|---|---|
| AttributeType |
GetExpression()
Gets the expression for the index variable
Declaration
public IExpression GetExpression()
Returns
| Type | Description |
|---|---|
| IExpression |
IsIncreasing()
Get an expression that evaluates to true when this loop counter is increasing in the currently executing loop.
Declaration
public Variable<bool> IsIncreasing()
Returns
| Type | Description |
|---|---|
| Variable<Boolean> |
Named(String)
Inline method to name a range
Declaration
public Range Named(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| String | name | Name for the range |
Returns
| Type | Description |
|---|---|
| Range | this |
ToString()
ToString override
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
Explicit Interface Implementations
IModelExpression.Name
Declaration
string IModelExpression.Name { get; }
Returns
| Type | Description |
|---|---|
| String |