示例#1
0
 protected override void VerifyRankAndSize(IPinnedArray <double> bufferReal, IPinnedArray <Complex> bufferComplex)
 {
     if (bufferReal.Rank != bufferComplex.Rank)
     {
         throw new ArgumentException($"{nameof(bufferReal)} and {nameof(bufferComplex)} must have the same rank and size.");
     }
     for (int i = 0; i < bufferReal.Rank - 1; i++)
     {
         if (bufferReal.GetLength(i) != bufferComplex.GetLength(i))
         {
             throw new ArgumentException($"Lenght of {nameof(bufferComplex)} must be equal to n[0]*...*(n[n.Length - 1] / 2 + 1) with n being the size of {nameof(bufferReal)}.");
         }
     }
     if (bufferReal.GetLength(bufferReal.Rank - 1) / 2 + 1 != bufferComplex.GetLength(bufferReal.Rank - 1))
     {
         throw new ArgumentException($"Lenght of {nameof(bufferComplex)} must be equal to n[0]*...*(n[n.Length - 1] / 2 + 1) with n being the size of {nameof(bufferReal)}.");
     }
 }
示例#2
0
 protected override void VerifyRankAndSize(IPinnedArray <Complex> input, IPinnedArray <Complex> output)
 {
     if (input.Rank != output.Rank)
     {
         throw new ArgumentException($"{nameof(input)} and {nameof(output)} must have the same rank and size.");
     }
     for (int i = 0; i < input.Rank; i++)
     {
         if (input.GetLength(i) != output.GetLength(i))
         {
             throw new ArgumentException($"{nameof(input)} and {nameof(output)} must have the same rank and size.");
         }
     }
 }
示例#3
0
        public static int GetIndex <T>(this IPinnedArray <T> array, int[] indices)
            where T : struct
        {
            if (indices.Length != array.Rank)
            {
                throw new ArgumentException($"Array of length {nameof(array.Rank)} = {array.Rank} expected.", nameof(indices));
            }
            int index = indices[0];

            for (int i = 1; i < indices.Length; i++)
            {
                index *= array.GetLength(i);
                index += indices[i];
            }
            return(index);
        }