Ejemplo n.º 1
0
 public static IEnumerable <long> EnumerateFlatIndex(this RegularArrayLongInfo arrayInfo, params LongRange[] ranges)
 {
     arrayInfo.ValidateRanges(ranges);
     long[] dimIndices = new long[arrayInfo.Rank];
     for (ArrayLongIndex ai = new ArrayLongIndex(new RegularArrayLongInfo(ranges.Select(r => new ArrayLongDimension(r.Count, r.Index)).ToArray())); ai.Carry == 0; ai++)
     {
         ai.GetDimIndices(dimIndices);
         yield return(arrayInfo.CalcFlatIndex(dimIndices));
     }
 }
Ejemplo n.º 2
0
 public void SetFrom(ArrayLongIndex arrayIndex)
 {
     if (arrayIndex == null)
     {
         throw new ArgumentNullException("arrayIndex");
     }
     else if (arrayIndex._arrayInfo != _arrayInfo || arrayIndex._zeroBased != _zeroBased)
     {
         throw new ArgumentException("Diffrent array specifications", "arrayIndex");
     }
     //
     _carry     = 0;
     _flatIndex = arrayIndex._flatIndex;
     arrayIndex._dimIndices.CopyTo(_dimIndices, 0);
 }
Ejemplo n.º 3
0
        public static void GetDimIndices(this ArrayLongIndex arrayIndex, long[][] dimIndices)
        {
            if (arrayIndex == null)
            {
                throw new NullReferenceException("arrayIndex");
            }
            JaggedArrayLongInfo arrayInfo = arrayIndex.ArrayInfo as JaggedArrayLongInfo;

            if (arrayInfo == null)
            {
                throw new InvalidOperationException("Indexearray is nojagged");
            }
            //
            if (dimIndices == null)
            {
                throw new ArgumentNullException("dimIndices");
            }
            else if (dimIndices.Length != arrayInfo.Depths)
            {
                throw new ArgumentException(ArrayResources.Default.Strings[ArrayMessage.InvalidArrayLength], "dimIndices");
            }
            else
            {
                for (int i = 0; i < arrayInfo.Depths; i++)
                {
                    if (dimIndices[i] == null)
                    {
                        throw new ArgumentRegularArrayLongElementException("dimIndices", "Value is null", i);
                    }
                    else if (dimIndices[i].Length != arrayInfo.GetRank(i))
                    {
                        throw new ArgumentRegularArrayLongElementException("dimIndices", ArrayResources.Default.Strings[ArrayMessage.InvalidArrayLength], i);
                    }
                }
            }
            //
            for (int i = 0, j = 0; i < arrayInfo.Depths; j += arrayInfo.GetRank(i), i++)
            {
                for (int k = 0; k < arrayInfo.GetRank(i); k++)
                {
                    dimIndices[i][k] = arrayIndex.GetLongDimIndex(j + k);
                }
            }
        }