public static IList <Vector4> CreateColorSparseArray(MemoryAccessor bottom, IntegerArray topKeys, MemoryAccessor topValues) { Guard.IsTrue(bottom._Attribute.Dimensions == topValues._Attribute.Dimensions, nameof(topValues)); Guard.IsTrue(topKeys.Count <= bottom._Attribute.ItemsCount, nameof(topKeys)); Guard.IsTrue(topKeys.Count == topValues._Attribute.ItemsCount, nameof(topValues)); Guard.IsTrue(topKeys.All(item => item < (uint)bottom._Attribute.ItemsCount), nameof(topKeys)); return(new SparseArray <Vector4>(bottom.AsColorArray(), topValues.AsColorArray(), topKeys)); }
public static IList <Vector4> CreateColorSparseArray(MemoryAccessor bottom, IntegerArray topKeys, MemoryAccessor topValues, Single defaultW = 1) { Guard.NotNull(bottom, nameof(bottom)); Guard.NotNull(topValues, nameof(topValues)); Guard.IsTrue(bottom._Slicer.Dimensions == topValues._Slicer.Dimensions, nameof(topValues)); Guard.IsTrue(topKeys.Count <= bottom._Slicer.ItemsCount, nameof(topKeys)); Guard.IsTrue(topKeys.Count == topValues._Slicer.ItemsCount, nameof(topValues)); Guard.IsTrue(topKeys.All(item => item < (uint)bottom._Slicer.ItemsCount), nameof(topKeys)); return(new SparseArray <Vector4>(bottom.AsColorArray(defaultW), topValues.AsColorArray(defaultW), topKeys)); }
public static IList <Single> CreateScalarSparseArray(MemoryAccessor bottom, IntegerArray topKeys, MemoryAccessor topValues) { Guard.NotNull(bottom, nameof(bottom)); Guard.NotNull(topValues, nameof(topValues)); Guard.IsTrue(bottom._Slicer.Dimensions == topValues._Slicer.Dimensions, nameof(topValues)); Guard.IsTrue(topKeys.Count <= bottom._Slicer.ItemsCount, nameof(topKeys)); Guard.IsTrue(topKeys.Count == topValues._Slicer.ItemsCount, nameof(topValues)); Guard.IsTrue(topKeys.All(item => item < (uint)bottom._Slicer.ItemsCount), nameof(topKeys)); return(new SparseArray <Single>(bottom.AsScalarArray(), topValues.AsScalarArray(), topKeys)); }
public static IntegerArray IndicesRange(int start, int count) { var array = new IntegerArray(new ArraySegment <Byte>(new Byte[count * 4]), Schema2.IndexEncodingType.UNSIGNED_INT); for (int i = 0; i < count; ++i) { array[i] = (UInt32)(start + i); } return(array); }
public SparseArray(IList <T> bottom, IList <T> top, IntegerArray topMapping) { _BottomItems = bottom; _TopItems = top; _Mapping = new Dictionary <int, int>(); for (int val = 0; val < topMapping.Count; ++val) { var key = (int)topMapping[val]; _Mapping[key] = val; } }
public static IList <Vector4> CreateVector4SparseArray(MemoryAccessor bottom, IntegerArray topKeys, MemoryAccessor topValues) { Guard.NotNull(bottom, nameof(bottom)); Guard.NotNull(topValues, nameof(topValues)); Guard.IsTrue(bottom._Encoding.Dimensions == topValues._Encoding.Dimensions, nameof(topValues)); Guard.IsTrue(topKeys.Count <= bottom._Encoding.ItemsCount, nameof(topKeys)); Guard.IsTrue(topKeys.Count == topValues._Encoding.ItemsCount, nameof(topValues)); Guard.IsTrue(topKeys.All(item => item < (uint)bottom._Encoding.ItemsCount), nameof(topKeys)); return(new SparseArray <Vector4>(bottom.AsVector4Array(), topValues.AsVector4Array(), topKeys)); }