/// <summary> /// Shift (offset) the elements in the array /// </summary> /// <param name="array"></param> /// <param name="offset"></param> static public void Shift(ComplexFloat[] array, int offset) { Debug.Assert(array != null); Debug.Assert(offset >= 0); Debug.Assert(offset < array.Length); if (offset == 0) { return; } int length = array.Length; ComplexFloat[] workspace = null; ComplexArray.LockWorkspaceF(length, ref workspace); for (int i = 0; i < length; i++) { workspace[(i + offset) % length] = array[i]; } for (int i = 0; i < length; i++) { array[i] = workspace[i]; } ComplexArray.UnlockWorkspaceF(ref workspace); }
/// <summary> /// Shift (offset) the elements in the array /// </summary> /// <param name="array"></param> /// <param name="offset"></param> public static void Shift(ComplexFloat[] array, int offset) { if (!(array != null)) { throw new ArgumentNullException(nameof(array)); } if (!(offset >= 0)) { throw new ArgumentOutOfRangeException(nameof(offset) + " should be >= 0"); } if (!(offset < array.Length)) { throw new ArgumentOutOfRangeException(nameof(offset) + " should be < array.Length"); } if (offset == 0) { return; } int length = array.Length; ComplexFloat[] workspace = null; ComplexArray.LockWorkspaceF(length, ref workspace); for (int i = 0; i < length; i++) { workspace[(i + offset) % length] = array[i]; } for (int i = 0; i < length; i++) { array[i] = workspace[i]; } ComplexArray.UnlockWorkspaceF(ref workspace); }