/// <summary> /// Helper function to create a SizeTVector from IEnumerable. /// </summary> /// <param name="input">Elements to be stored in the SizeTVector.</param> /// <returns>A SizeTVector containing all elements from the IEnumerable input.</returns> internal static SizeTVector AsSizeTVector(IEnumerable <int> input) { var inputVector = new SizeTVector(); foreach (var element in input) { if (element < 0) { throw new System.ArgumentException("The argument cannot contain a negative value"); } inputVector.Add((uint)element); } return(inputVector); }
/// <summary> /// Creates a new NDShape. /// </summary> /// <param name="dimensions"></param> /// <returns></returns> public static NDShape CreateNDShape(IEnumerable <int> dimensions) { var dimVector = new SizeTVector(); foreach (var element in dimensions) { if (element < 0 && !IsSpecialDimensionValues(element)) { throw new ArgumentException("The parameter diemnsions cannot contain a negative value"); } CSharp_SizeTVector_AddExt(dimVector, DimConvertCSToCPP(element)); } return(new NDShape(dimVector)); }