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

📄 normal.h

📁 c++最经典的入门书籍
💻 H
字号:
// normal.h
// Normalize an array of values to the range 0 to 1
#include "tempcomp.h"

namespace compare {
  template<class Toriginal, class Tnormalized>
      void normalize(Toriginal* data, Tnormalized* newData, int size) {
    Toriginal minValue = min(data, size);        // Get minimum element

    // Shift all elements so minimum is zero
    for(int i = 0 ; i < size ; i++)
      newData[i] = static_cast<Tnormalized>(data[i]-minValue);

    Tnormalized maxValue = max(newData, size);    // Get max of new set 

    // Scale elements so maximum is 1
    for(int i = 0 ; i < size ; i++)
      newData[i] /= maxValue;
  }
}

⌨️ 快捷键说明

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