📄 windows.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace DSProcessing
{
/// <summary>
/// Windows functions, a part of DSProcessing library.
/// author: Jan Sova
/// mailto: twardowski@email.cz
///
/// -------------------------------------------------------------------------
///
/// DSProcessing - C#/C++ library of signal processing, speech processing,
/// and communications classes and functions
///
/// Copyright (C) 2007-2008
///
/// This program is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with this program; if not, write to the Free Software
/// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
///
///-------------------------------------------------------------------------
/// </summary>
public class Windows
{
/// <summary>
/// vrati vektor hanningova okna
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static double[] hanning(int n)
{
double[] hanningW = new double[n];
for(int i =0; i < n; i++)
hanningW[i] = 0.5*(1-Math.Cos(2*Math.PI*i/(n+1)));
return hanningW;
}
/// <summary>
/// vynasobi data hanningem
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static double[] multHanning(double[] data)
{
double[] hanningW = hanning(data.Length);
double[] returnValue = Tools.mult(data, hanningW);
return returnValue;
}
/// <summary>
/// nasobi realno cast i komplexniho cisla hanningem
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static Complex[] complexMultHanning(Complex[] data)
{
Complex[] returnValue = new Complex[data.Length];
double[] hanningW = hanning(data.Length);
double[] reData = new double[data.Length];
double[] imData = new double[data.Length];
for (int i = 0; i < data.Length; i++)
{
reData[i] = data[i].Re;
imData[i] = data[i].Im;
}
reData = multHanning(reData);
imData = multHanning(imData);
returnValue = Complex.makeFrom(reData, imData);
return returnValue;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -