/// <summary> /// Arranges the FFT values to have 0 as the center frequency /// </summary> /// <param name="fftvalues">Array of type ComplexF which contain the FFT values of a Signal</param> /// <returns>FFT values with the halves of the argument fftvalues swapped</returns> public static Complex[] FFTShift(Complex[] fftvalues) { int half = fftvalues.Length / 2; Complex[] f_half = new ArraySegment<Complex>(fftvalues, 0, half).ToArray(); Complex[] s_half = new ArraySegment<Complex>(fftvalues, half, fftvalues.Length / 2).ToArray(); Complex[] retval = s_half.Concat(f_half).ToArray(); return retval; }
/// <summary> /// Arranges the FFT values to have 0 as the center frequency /// </summary> /// <param name="fftvalues">Array of type ComplexF which contain the FFT values of a Signal</param> /// <returns>FFT values with the halves of the argument fftvalues swapped</returns> public static Complex[] FFTShift(Complex[] fftvalues) { int half = fftvalues.Length / 2; Complex[] f_half = new ArraySegment <Complex>(fftvalues, 0, half).ToArray(); Complex[] s_half = new ArraySegment <Complex>(fftvalues, half, fftvalues.Length / 2).ToArray(); Complex[] retval = s_half.Concat(f_half).ToArray(); return(retval); }
private static int[] LeftRotateArr(int rotations, int[] inArr) { if (rotations > inArr.Length) { rotations = inArr.Length % rotations; } ArraySegment <int> iGreaterThanRotations = new ArraySegment <int>(inArr , rotations , inArr.Length - rotations); ArraySegment <int> iLessThanRotations = new ArraySegment <int>(inArr , 0 , rotations); int[] rotatedArr = iGreaterThanRotations.Concat <int>(iLessThanRotations).ToArray <int>(); return(rotatedArr); }
public static void RotateArray(ref int[] nums, int k) { if (nums == null) { return; } if (k <= 0 || nums.Length == 0 || k >= nums.Length) { return; } var segment1 = new ArraySegment <int>(nums, 0, k); var segment2 = new ArraySegment <int>(nums, k, nums.Length - k); nums = segment2.Concat(segment1).ToArray(); }