コード例 #1
0
        public static int TransformFlatIndex(this RegularArrayInfo arrayInfo, int flatIndex, params Range[] ranges)
        {
            arrayInfo.ValidateRanges(ranges);
            int[]            dimIndices = new int[arrayInfo.Rank];
            RegularArrayInfo ai         = new RegularArrayInfo(ranges.Select(r => new ArrayDimension(r.Count, r.Index)).ToArray());

            ai.CalcDimIndices(flatIndex, dimIndices);
            return(arrayInfo.CalcFlatIndex(dimIndices));
        }
コード例 #2
0
 public static IEnumerable <int> EnumerateFlatIndex(this RegularArrayInfo arrayInfo, params Range[] ranges)
 {
     arrayInfo.ValidateRanges(ranges);
     int[] dimIndices = new int[arrayInfo.Rank];
     for (ArrayIndex ai = new ArrayIndex(new RegularArrayInfo(ranges.Select(r => new ArrayDimension(r.Count, r.Index)).ToArray())); ai.Carry == 0; ai++)
     {
         ai.GetDimIndices(dimIndices);
         yield return(arrayInfo.CalcFlatIndex(dimIndices));
     }
 }