当前位置: 首页>>代码示例>>C#>>正文


C# Complex.Select方法代码示例

本文整理汇总了C#中Complex.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.Select方法的具体用法?C# Complex.Select怎么用?C# Complex.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Complex的用法示例。


在下文中一共展示了Complex.Select方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyFFTToFrameColumn

        private void CopyFFTToFrameColumn(Complex[] fftResults)
        {
            var maxReal = fftResults.Select(c => 20 * Math.Log10(Math.Abs(c.Magnitude))).Max();
              var minReal = fftResults.Select(c => 20 * Math.Log10(Math.Abs(c.Magnitude))).Min();
              for (int i = 0; i < _fftSize; i++)
              {
            var value = fftResults[i].Magnitude;
            var logValue = 20 * Math.Log10(Math.Abs(value));
            uint ushortedValue = (uint)(maxValue * (logValue - minReal) / (maxReal - minReal));
            uint colorB = ushortedValue * _maxColor[2] + (1-ushortedValue)* _minColor[2];
            uint colorG = ushortedValue * _maxColor[1] + (1-ushortedValue)* _minColor[1];
            uint colorR = ushortedValue * _maxColor[0] + (1-ushortedValue)* _minColor[0];
            uint uintValue = 0x000000FF;
            uintValue = uintValue | (colorR << 8);
            uintValue = uintValue | (colorG << 16);
            uintValue = uintValue | (colorB << 24);

            _spectrogramData[(_fftSize - i - 1) * _numberOfFramesPerImage + _currentFrame] = (uintValue);

              }
        }
开发者ID:cristiandonosoc,项目名称:GBSharp,代码行数:21,代码来源:APUViewModel.cs

示例2: GetDoubles

 public static void GetDoubles(double[] array, double x = 1.0)
 {
     var complex = new Complex[array.Length];
     if (array.Length > 0) complex[0] = Complex.One;
     if (array.Length > 1) complex[1] = x;
     if (array.Length > 0)
     {
         Fourier(complex, FourierDirection.Forward);
         complex = complex.Select(
             value => Complex.Pow(value, array.Length - 1)/array.Length).ToArray();
         Fourier(complex, FourierDirection.Backward);
     }
     var index = 0;
     foreach (var value in complex) array[index++] = value.Real;
 }
开发者ID:0x0all,项目名称:FFTTools,代码行数:15,代码来源:BinomialBuilder.cs

示例3: Build

        /// <summary>
        ///     Calculate function self-convolution values
        /// </summary>
        /// <param name="f">Function values</param>
        /// <returns></returns>
        public double[] Build(double[] f)
        {
            int length = (_functionType == FunctionType.Periodic) ? f.Length : (f.Length + f.Length - 1);

            var input = new fftw_complexarray(length);
            var output = new fftw_complexarray(length);
            fftw_plan forward = fftw_plan.dft_1d(length, input, output,
                fftw_direction.Forward,
                fftw_flags.Estimate);
            fftw_plan backward = fftw_plan.dft_1d(length, input, output,
                fftw_direction.Backward,
                fftw_flags.Estimate);

            var complex = new Complex[length];
            for (int i = 0; i < f.Length; i++) complex[i] = f[i];
            input.SetData(complex);
            forward.Execute();
            complex = output.GetData_Complex();
            input.SetData(complex.Select(x => x*x/length).ToArray());
            backward.Execute();
            complex = output.GetData_Complex();

            return complex.Select(x => x.Magnitude).ToArray();
        }
开发者ID:Maasik,项目名称:FFTTools,代码行数:29,代码来源:ConvolutionBuilder.cs

示例4: GetTransform

        /// <summary>
        ///   Get constant q transformation coefficients
        /// </summary>
        /// <param name = "x">Initial signal</param>
        /// <param name = "sparKernel">Spar kernel</param>
        /// <returns>Constant q transform</returns>
        /// <remarks>
        ///   Method rewritten from Matlab implementation
        ///   http://wwwmath.uni-muenster.de/logik/Personen/blankertz/constQ/constQ.html
        /// </remarks>
        /*
         * function cq= constQ(x, sparKernel) % x must be a row vector
         * cq= fft(x,size(sparKernel,1)) * sparKernel;
         */
        public double[] GetTransform(Complex[] x, Complex[][] sparKernel)
        {
            int signalLength = x.Length;
            int sparLength = sparKernel[0].Length;
            if (signalLength != sparLength)
                throw new ArgumentException("x and sparKernel dimensions are not equal");
            Fourier.FFT(x, x.Length, FourierDirection.Forward);
            int logBins = sparKernel.GetLength(0);
            Complex[] cq = new Complex[logBins];

            for (int i = 0; i < logBins; i++)
            {
                for (int j = 0; j < signalLength /*2048*/; j++)
                {
                    cq[i].Re += x[j].Re*sparKernel[i][j].Re - x[j].Im*sparKernel[i][j].Im;
                    cq[i].Im += x[j].Re*sparKernel[i][j].Im + x[j].Im*sparKernel[i][j].Re;
                }
            }
            return cq.Select((item) => 20*Math.Log10(item.GetModulus()/FingerprintManager.HUMAN_AUDITORY_THRESHOLD)).ToArray();
        }
开发者ID:gvillarroel,项目名称:memoria,代码行数:34,代码来源:ConstQ.cs

示例5: Stretch

        /// <summary>
        ///     Resize bitmap with the Fastest Fourier Transform
        /// </summary>
        /// <returns>Resized bitmap</returns>
        public double[,,] Stretch(double[,,] imageData)
        {
            int length = imageData.Length;
            int n0 = imageData.GetLength(0);
            int n1 = imageData.GetLength(1);
            int n2 = imageData.GetLength(2);

            var doubles = new double[length];
            Buffer.BlockCopy(imageData, 0, doubles, 0, length*sizeof (double));

            double average;
            double delta;
            AverageAndDelta(out average, out delta, doubles, _keepOption);

            Size newSize = _filterSize;
            switch (_filterMode)
            {
                case FilterMode.FilterSize:
                    break;
                case FilterMode.FilterStep:
                    int filterStep = _filterStep;
                    newSize = new Size(MulDiv(n1, filterStep + filterStep + 1, filterStep + filterStep),
                        MulDiv(n0, filterStep + filterStep + 1, filterStep + filterStep));
                    break;
                default:
                    throw new NotImplementedException();
            }

            var imageData2 = new double[newSize.Height, newSize.Width, n2];
            int length2 = imageData2.Length;
            int m0 = imageData2.GetLength(0);
            int m1 = imageData2.GetLength(1);
            int m2 = imageData2.GetLength(2);

            Complex[] complex = doubles.Select(x => new Complex(x, 0)).ToArray();
            var complex2 = new Complex[length2];
            Fourier(n0, n1, n2, complex, FourierDirection.Forward);
            Copy(n0, n1, m0, m1, complex, complex2, n2);
            Fourier(m0, m1, m2, complex2, FourierDirection.Backward);
            doubles = complex2.Select(x => x.Magnitude).ToArray();

            double average2;
            double delta2;
            AverageAndDelta(out average2, out delta2, doubles, _keepOption);

            // a*average2 + b == average
            // a*delta2 == delta
            double a = (_keepOption == KeepOption.AverageAndDelta) ? (delta/delta2) : (average/average2);
            double b = (_keepOption == KeepOption.AverageAndDelta) ? (average - a*average2) : 0;
            Debug.Assert(Math.Abs(a*average2 + b - average) < 0.1);
            doubles = doubles.Select(x => Math.Round(a*x + b)).ToArray();

            Buffer.BlockCopy(doubles, 0, imageData2, 0, length2*sizeof (double));
            return imageData2;
        }
开发者ID:SlimSalamin,项目名称:FFTTools,代码行数:59,代码来源:StretchBuilder.cs

示例6: SetChannel

        /// <summary>
        /// Set the channel properties
        /// </summary>
        /// <param name="channel"></param>
        public static void SetChannel(Dict channel)
        {
            // validate channel's properties
              var data = new Complex[BlocksPerSymbol];
              foreach(var curr in channel.Keys())
              {
            int index;
            double value;

            if (!int.TryParse(curr, out index))
              throw new Exception(String.Format("Channel quality indexes must be integers. '{0}' is not a valid integer!", curr));

            if (index >= data.Length)
              throw new Exception("Key exceeds array length");

            if (!double.TryParse(channel.Get(curr), out value))
              throw new Exception(String.Format("Channel quality values must be floats. '{0}' is not a valid float!", curr));

            data[index] = new Complex(value, 0);
              }

              // reverse-transform to get SNRs
              var fft = new MathNet.Numerics.IntegralTransforms.Algorithms.DiscreteFourierTransform();
              fft.BluesteinInverse(data, MathNet.Numerics.IntegralTransforms.FourierOptions.Default);
              ChannelQuality = data.Select(p => p.Magnitude).ToArray();
        }
开发者ID:menozz,项目名称:mirelle,代码行数:30,代码来源:FlowSimulation.cs

示例7: Stretch

        /// <summary>
        ///     Resize bitmap with the Fastest Fourier Transform
        /// </summary>
        /// <returns>Resized bitmap</returns>
        public Array Stretch(Array imageData)
        {
            var length = imageData.Length;
            var n0 = imageData.GetLength(0);
            var n1 = imageData.GetLength(1);
            var n2 = imageData.GetLength(2);

            var doubles = new double[length];

            var handle = GCHandle.Alloc(imageData, GCHandleType.Pinned);
            Marshal.Copy(handle.AddrOfPinnedObject(), doubles, 0, doubles.Length);
            handle.Free();

            double average;
            double delta;
            AverageAndDelta(out average, out delta, doubles, _keepOption);

            var newSize = _filterSize;
            switch (_filterMode)
            {
                case FilterMode.FilterSize:
                    break;
                case FilterMode.FilterStep:
                    var filterStep = _filterStep;
                    newSize = new Size(MulDiv(n1, filterStep + filterStep + 1, filterStep + filterStep),
                        MulDiv(n0, filterStep + filterStep + 1, filterStep + filterStep));
                    break;
                default:
                    throw new NotImplementedException();
            }

            var imageData2 = new double[newSize.Height, newSize.Width, n2];
            var length2 = imageData2.Length;
            var m0 = imageData2.GetLength(0);
            var m1 = imageData2.GetLength(1);
            var m2 = imageData2.GetLength(2);

            var complex = doubles.Select(x => new Complex(x, 0)).ToArray();
            var complex2 = new Complex[length2];
            Fourier(n0, n1, n2, complex, FourierDirection.Forward);
            Copy(n0, n1, m0, m1, complex, complex2, n2);
            Fourier(m0, m1, m2, complex2, FourierDirection.Backward);
            doubles = complex2.Select(x => x.Magnitude).ToArray();

            double average2;
            double delta2;
            AverageAndDelta(out average2, out delta2, doubles, _keepOption);

            // a*average2 + b == average
            // a*delta2 == delta
            var a = (_keepOption == KeepOption.AverageAndDelta) ? (delta/delta2) : (average/average2);
            var b = (_keepOption == KeepOption.AverageAndDelta) ? (average - a*average2) : 0;
            Debug.Assert(Math.Abs(a*average2 + b - average) < 0.1);
            doubles = doubles.Select(x => Math.Round(a*x + b)).ToArray();


            handle = GCHandle.Alloc(imageData2, GCHandleType.Pinned);
            Marshal.Copy(doubles, 0, handle.AddrOfPinnedObject(), doubles.Length);
            handle.Free();

            return imageData2;
        }
开发者ID:0x0all,项目名称:FFTTools,代码行数:66,代码来源:StretchBuilder.cs

示例8: SaveArrayToFile

 public static void SaveArrayToFile(string fileName, Complex[] dataToSave)
 {
     System.IO.File.WriteAllLines($"{fileName}_X.txt", dataToSave.Select(x => x.Real.ToString()).ToArray());
     System.IO.File.WriteAllLines($"{fileName}_Y.txt", dataToSave.Select(x => x.Imaginary.ToString()).ToArray());
 }
开发者ID:p0miki,项目名称:LaserModulation,代码行数:5,代码来源:SignalFixer.cs

示例9: CalculateTransmissionLoss


//.........这里部分代码省略.........
            Directory.CreateDirectory(tempDirectory);
            File.Copy(envFileName, Path.Combine(tempDirectory, "ramgeo.in"));
            using (var steerableArrayFile = new StreamWriter(Path.Combine(tempDirectory, "sra.in"), false))
            {
                // From http://www.activefrance.com/Antennas/Introduction%20to%20Phased%20Array%20Design.pdf
                // theta3 = 3dB beam width, in degrees
                // emitterSize = size of emitter array, in meters
                // theta3 = (0.886 * lambda / arrayLength) * 180 / pi
                // so, doing the algebra and solving for arrayLength, you get:
                // emitterSize = (0.886 * lambda) / (theta3 * (pi / 180))
                var emitterSize = (0.886 * lambda) / (mode.VerticalBeamWidth * (Math.PI / 180.0));
                var emitterCount = (int)(emitterSize / (dz * 2));
                var emitterSpacing = 1.0;
                var weights = new List<double> { 1 };
                if (emitterCount > 1)
                {
                    emitterSpacing = emitterSize / (emitterCount - 1);
                    // chebyshev window calculations for relative emitter strength across the array
                    var discreteFourierTransform = new MathNet.Numerics.IntegralTransforms.Algorithms.DiscreteFourierTransform();
                    var r0 = Math.Pow(10, mode.SideLobeAttenuation / 20.0);
                    var n = emitterCount - 1;
                    var a = Complex.Cosh((1.0 / n) * Acosh(r0));
                    var am = new Complex[n];
                    for (var m = 0; m < n; m++) am[m] = a * Complex.Cos(Math.PI * m / n);
                    var wm = new Complex[n];
                    var sign = 1;
                    for (var i = 0; i < n; i++)
                    {
                        if (am[i].Magnitude > 1) wm[i] = sign * Complex.Cosh(n * Acosh(am[i]));
                        else wm[i] = sign * Complex.Cos(n * Complex.Acos(am[i]));
                        sign *= -1;
                    }
                    discreteFourierTransform.BluesteinInverse(wm, FourierOptions.Default);
                    weights = wm.Select(e => e.Real).ToList();
                    weights[0] /= 2;
                    weights.Add(weights[0]);
                    var maxWeight = weights.Max();
                    for (var i = 0; i < weights.Count; i++) weights[i] /= maxWeight;
                }
                steerableArrayFile.WriteLine("{0}\t{1}\t{2}", emitterCount, emitterSpacing, mode.DepressionElevationAngle);
                for (var i = 0; i < emitterCount; i++) steerableArrayFile.WriteLine("{0}", weights[i]);
            }
            //File.Copy(Path.Combine(AssemblyLocation, "sra.in"), Path.Combine(tempDirectory, "sra.in"));
            //Debug.WriteLine(string.Format("Env File: {0} copied to: {1}", envFileName, tempDirectory));
            // Now that we've got the files ready to go, we can launch bellhop to do the actual calculations
            var ramProcess = new Process
            {
                StartInfo = new ProcessStartInfo(Path.Combine(AssemblyLocation, "RAMGeo.exe"))
                {
                    CreateNoWindow = true,
                    UseShellExecute = false,
                    RedirectStandardInput = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                    WorkingDirectory = tempDirectory
                }
            };
            if (radial.IsDeleted) throw new RadialDeletedByUserException();
            ramProcess.Start();
            try
            {
                ramProcess.PriorityClass = ProcessPriorityClass.Idle;
            }
            catch (InvalidOperationException) { }
            //ramProcess.BeginOutputReadLine();
            while (!ramProcess.HasExited)
开发者ID:AuditoryBiophysicsLab,项目名称:ESME-Workbench,代码行数:67,代码来源:RAMGeoEngine.cs

示例10: ComplexArrToString

 public static string ComplexArrToString(Complex[] complexarr)
 {
     string value = String.Join(",", complexarr.Select(i => i.ToString()).ToArray());
     return value;
 }
开发者ID:altaria,项目名称:Altaria,代码行数:5,代码来源:KeyGen.cs


注:本文中的Complex.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。