• 大小: 4KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-15
  • 语言: C#
  • 标签: C#  DCT  

资源简介

C# 离散余弦变换DCT, 经检验与Matlab计算结果相同

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DCT_Test
{
    class Complex
    {
        private double m_dRealPart;
        private double m_dImagePart;
    
        public double Real
        {
            set{ m_dRealPart = value;}
            get{ return m_dRealPart; }
        }

        public double Image
        {
            set { m_dImagePart = value; }
            get { return m_dImagePart; }
        }

        public Complex(double dRealPart double dImagePart)
        {
            m_dRealPart = dRealPart;
            m_dImagePart = dImagePart;
        }
        public Complex(double dRealPart)
        {
            m_dRealPart = dRealPart;
            m_dImagePart = 0;
        }
        public Complex()
        {
            m_dRealPart = 0;
            m_dImagePart = 0;
        }
        public Complex(Complex orig)
        {
            m_dRealPart = orig.m_dRealPart;
            m_dImagePart = orig.m_dImagePart;
        }

        static public Complex operator +(Complex op1 Complex op2)
        {
            Complex res = new Complex();
            res.m_dRealPart = op1.m_dRealPart + op2.m_dRealPart;
            res.m_dImagePart = op1.m_dImagePart + op2.m_dImagePart;
            return res;
        }
        static public Complex operator -(Complex op)
        {
            Complex res = new Complex();
            res.m_dRealPart = -op.m_dRealPart;
            res.m_dImagePart = -op.m_dImagePart;
            return res;
        }
        static public Complex operator -(Complex op1 Complex op2)
        {
            Complex res = new Complex();
            res = op1 + (-op2);
            return res;
        }
        static public Complex operator *(Complex op1 Complex op2)
        {
            Complex res = new Complex();
            res.m_dRealPart = op1.m_dRealPart * op2.m_dRealPart - op1.m_dImagePart * op2.m_dImagePart;
            res.m_dImagePart = op1.m_dImagePart * op2.m_dRealPart + op1.m_dRealPart * op2.m_dImagePart;
            return res;
        }
        static public Complex operator /(Complex op1 Complex op2)
        {
            Complex res = new Complex();
            double temp = op2.m_dRealPart * op2.m_dRealPart + op2.m_dRealPart * op2.m_dImagePart;
            res.m_dRealPart = (op1.m_dRealPart * op2.m_dRealPart + op1.m_dImagePart * op2.m_dImagePart) / temp;
            res.m_dImagePart = (op1.m_dImagePart * op2.m_dRealPart - op1.m_dRealPart * op2.m_dImagePart) / temp;
            return res;
        }



        public double NormSquare()
        {
            return m_dRealPart * m_dRealPart + m_dImagePart * m_dImagePart;
        }

        public static Complex [] exp(Complex [] data)
        {
            //  For complex Z=X+i*Y EXP(Z) = EXP(X)*(COS(Y)+i*SIN(Y))=EXP(X)*COS(Y)+EXP(X)*i*SIN(Y) .
            int Len = data.Length;      
            Complex[] ex

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4249  2013-08-18 00:24  Complex.cs

     文件        825  2013-08-18 00:12  ComplexExp.cs

     文件       1882  2013-08-18 12:46  DCTransform.cs

     文件       8041  2013-08-18 12:46  FFTransform.cs

     文件        595  2013-08-17 22:41  ReorderSort.cs

----------- ---------  ---------- -----  ----

                15592                    5


评论

共有 条评论