⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 costshannon.cpp

📁 小波包分解去噪c++源程序
💻 CPP
字号:

#include <assert.h>
#include <stdio.h>
#include <math.h>

#include "costshannon.h"


/**

  An implementation of a modified version of the Shannon entropy
  function as a wavelet packet cost function.  This is described
  in section 8.3.2 of <i>Ripples in Mathematics</i> by 
  Jensen and la Cour-Harbo.

  The log function here is the natural log (sometimes denoted as
  ln()).  Note that the result of the entropy function is always
  negative.

 */
double costshannon::costCalc( packnode<double> *node )
{
  assert( node != 0 );

  size_t len = node->length();
  const double *a = node->getData();

  double sum = 0.0;
  for (int i = 0; i < len; i++) {
    double val = 0.0;
    if (a[i] != 0.0) {
      double square = a[i] * a[i];
      val = square * log( square );
    }
    sum = sum + val;
  }

  return -sum;
} // costshannon

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -