Struct TensorIndex
Represents a set of indices corresponding to each axis of a tensor
Syntax
[Serializable]
public struct TensorIndex
Constructors
TensorIndex(Int32)
Creates a rank-1 tensor index (d0)
Ex: (9)
Declaration
public TensorIndex(int d0)
Parameters
Type |
Name |
Description |
Int32 |
d0 |
|
TensorIndex(Int32, Int32)
Creates a rank-2 tensor index (d1, d0)
Ex: (8,9)
Declaration
public TensorIndex(int d1, int d0)
Parameters
TensorIndex(Int32, Int32, Int32)
Creates a rank-3 tensor index (d2, d1, d0)
Ex: (7,8,9)
Declaration
public TensorIndex(int d2, int d1, int d0)
Parameters
TensorIndex(Int32, Int32, Int32, Int32)
Creates a rank-4 tensor index (d3, d2, d1, d0)
Ex: (6,7,8,9)
Declaration
public TensorIndex(int d3, int d2, int d1, int d0)
Parameters
TensorIndex(Int32, Int32, Int32, Int32, Int32)
Creates a rank-5 tensor index (d4, d3, d2, d1, d0)
Ex: (5,6,7,8,9)
Declaration
public TensorIndex(int d4, int d3, int d2, int d1, int d0)
Parameters
TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32)
Creates a rank-6 tensor index (d5, d4, d3, d2, d1, d0)
Ex: (4,5,6,7,8,9)
Declaration
public TensorIndex(int d5, int d4, int d3, int d2, int d1, int d0)
Parameters
TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
Creates a rank-7 tensor index (d6, d5, d4, d3, d2, d1, d0)
Ex: (3,4,5,6,7,8,9)
Declaration
public TensorIndex(int d6, int d5, int d4, int d3, int d2, int d1, int d0)
Parameters
TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
Creates a rank-8 tensor index (d7, d6, d5, d4, d3, d2, d1, d0)
Ex: (2,3,4,5,6,7,8,9)
Declaration
public TensorIndex(int d7, int d6, int d5, int d4, int d3, int d2, int d1, int d0)
Parameters
TensorIndex(Int32[])
Creates a tensor index given an input int[] representing the index
Ex: TensorIndex(new [] {3,4,5,6}) = (3,4,5,6)
Declaration
public TensorIndex(int[] index)
Parameters
Type |
Name |
Description |
Int32[] |
index |
|
TensorIndex(TensorIndex)
Declaration
public TensorIndex(TensorIndex index)
Parameters
Fields
maxRank
TensorIndex cannot have a bigger rank than maxRank
Declaration
public const int maxRank = 8
Field Value
Properties
Item[Int32]
Gets/Sets tensor index at a given axis
Ex:
index (3, 4, 5, 6)
index 0, 1, 2, 3
-4,-3,-2,-1
index (7, 3, 2)
index 0, 1, 2
-3,-2,-1
Declaration
public int this[int axis] { get; set; }
Parameters
Type |
Name |
Description |
Int32 |
axis |
|
Property Value
rank
Declaration
public readonly int rank { get; }
Property Value
Methods
Axis(Int32)
Wraps axis to positive index between 0,rank
(5,2,3,4)
axis = -1 => axis_out = 3
axis = 1 => axis_out = 1
Declaration
public int Axis(int axis)
Parameters
Type |
Name |
Description |
Int32 |
axis |
|
Returns
Equals(Object)
Determines whether the specified object is equal to the current TensorIndex
.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
Object |
obj |
|
Returns
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Overrides
ToString()
Returns a string that represents the TensorIndex
.
Declaration
public override string ToString()
Returns
Overrides
Zeros(Int32)
Creates index with zeros 0 of specified rank
Ex:
EmptyOfRank(rank: 3) => (0, 0, 0)
Declaration
public static TensorIndex Zeros(int rank)
Parameters
Type |
Name |
Description |
Int32 |
rank |
|
Returns
Operators
Equality(TensorIndex, TensorIndex)
Compares two TensorIndex
objects
Two TensorIndices are equal if they have the same rank and all their dimensions are equal
Declaration
public static bool operator ==(TensorIndex a, TensorIndex b)
Parameters
Returns
Inequality(TensorIndex, TensorIndex)
Declaration
public static bool operator !=(TensorIndex a, TensorIndex b)
Parameters
Returns