本文整理汇总了C#中AType.Add方法的典型用法代码示例。如果您正苦于以下问题:C# AType.Add方法的具体用法?C# AType.Add怎么用?C# AType.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AType
的用法示例。
在下文中一共展示了AType.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VectorIndexing
/// <summary>
///
/// </summary>
/// <param name="indexers">List containing all of the indexes</param>
/// <param name="indexpos"></param>
/// <param name="currentIdx">Array containing the current indexes</param>
/// <returns></returns>
public static AType VectorIndexing(this AType input, List<AType> indexers, int indexpos, AType currentIdx, bool isAssign, bool isMemoryMapped)
{
if (currentIdx.Length == 0)
{
// A Null item found!, select all of the current items
for (int i = 0; i < input.Length; i++)
{
currentIdx.Add(AInteger.Create(i));
}
}
// Create an array for the results
AType result = AArray.Create(input.Type);
// Iterate over the indexes
foreach (AType index in currentIdx)
{
AType item =
index.IsArray ?
input.VectorIndexing(indexers, indexpos, index, isAssign, isMemoryMapped) :
input.SimpleIndex(indexers, indexpos, index, isAssign, isMemoryMapped);
result.AddWithNoUpdate(item);
}
result.UpdateInfo();
return result;
}
示例2: CalculateIndexes
private static AType CalculateIndexes(AType value, AType target, Aplus environment, out AType indexes)
{
if (target.Rank == 0)
{
throw new Error.Rank("assign");
}
if (!Utils.DifferentNumberType(target, value) && target.Type != value.Type)
{
// The target and value are not numbers and they are of a different type?
throw new Error.Type("assign");
}
int currentLength = target.Length;
if (target.Shape.SequenceEqual<int>(value.Shape))
{
indexes = AArray.Create(ATypes.AInteger);
for (int i = 0; i < value.Length; i++)
{
indexes.Add(AInteger.Create(currentLength));
currentLength++;
}
}
else if (target.Shape.GetRange(1, target.Shape.Count - 1).SequenceEqual<int>(value.Shape))
{
indexes = AInteger.Create(currentLength);
currentLength++;
}
else if (value.Rank == 0)
{
indexes = AInteger.Create(currentLength);
currentLength++;
}
else if (value.Rank == target.Rank)
{
indexes = AArray.Create(ATypes.AInteger);
for (int i = 0; i < value.Length; i++)
{
indexes.Add(AInteger.Create(currentLength));
currentLength++;
}
}
else
{
throw new Error.Length("assign");
}
indexes = ABox.Create(indexes);
return value;
}
示例3: AppendItem
private static AType AppendItem(AType value, AType target, Aplus environment)
{
if (target.Rank == 0)
{
throw new Error.Rank("assign");
}
if (!Utils.DifferentNumberType(target, value) && target.Type != value.Type)
{
// The target and value are not numbers and they are of a different type?
throw new Error.Type("assign");
}
if (target.Shape.SequenceEqual<int>(value.Shape))
{
for (int i = 0; i < value.Length; i++)
{
target.Add(value[i].Clone());
}
}
else if (target.Shape.GetRange(1, target.Shape.Count - 1).SequenceEqual<int>(value.Shape))
{
target.Add(value.Clone());
}
else if (value.Rank == 0)
{
AType item = DyadicFunctionInstance.Reshape.Execute(
value,
target.Shape.GetRange(1, target.Shape.Count - 1).ToAArray()
);
target.Add(item);
}
else if (value.Rank == target.Rank)
{
for (int i = 0; i < value.Length; i++)
{
target.Add(value[i].Clone());
}
}
else
{
throw new Error.Length("assign");
}
return value;
}