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

📄 selfeature.cpp

📁 模糊聚類分析源碼。包含教學文件
💻 CPP
字号:
/*    Context       : Fuzzy Clustering Algorithms  Author        : Frank Hoeppner, see also AUTHORS file   Description   : implementation of class module SelFeature                    History       :      Comment       :     This file was generated automatically. DO NOT EDIT.  Copyright     : Copyright (C) 1999-2000 Frank Hoeppner    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*//*  The University of Applied Sciences Oldenburg/Ostfriesland/Wilhelmshaven  hereby disclaims all copyright interests in the program package `fc'   (tool package for fuzzy cluster analysis) written by Frank Hoeppner.    Prof. Haass, President of Vice, 2000-Mar-10*/#ifndef SelFeature_SOURCE#define SelFeature_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif// necessary includes#include "SelFeature.hpp"// data// implementationtemplate <class FEATURE>SelFeature<FEATURE>::SelFeature  (  FEATURE *ap_feature  , const int_matrix_type& a_data_selection  , const int_matrix_type& a_result_selection  )  : mp_feature(ap_feature)  , m_select_datum(ap_feature->datum(),a_data_selection)  , m_select_result((a_result_selection.rows()==0)?ap_feature->result():ap_feature->datum(),a_result_selection)  {    }template <class FEATURE> boolSelFeature<FEATURE>::consistent  (  int& a_data_dim,  const int a_act_depth,  int& a_data_depth  )  const  {  bool ok(true);  a_data_depth=max(a_data_depth,a_act_depth);  if ((a_data_dim==-1) && (datum().rows()>0))    {    a_data_dim = datum().rows();    }    if ((datum().rows()!=a_data_dim) && (datum().rows()!=0))    {     ok=false;     error("feature datum size mismatch",*this);     }  return ok;  }template <class FEATURE> voidSelFeature<FEATURE>::self_include  (  bbox_type& a_bbox,  stat_type& a_stat  )  const  {  if (datum().rows()>0)     {     a_bbox.include(datum());     a_stat.include(datum());    }  }template <class FEATURE> real_typeSelFeature<FEATURE>::select  (  const Selector& a_selector,  const SelFeature* ap_prev_data  )  const  {  const int index(a_selector.m_index[0]);  real_type value(0);  switch (a_selector.m_type)    {    case SELECT_ATTR : if (index>=0) {      if (datum().rows()>index) value = datum()(index);      } break;    case SELECT_DELT : if (index>=0) {      if (datum().rows()>index)        value = (ap_prev_data==NULL)?0:(ap_prev_data->datum()(index)-datum()(index));      } break;    case SELECT_WEIG :       value = weight();      break;    default :      break;    }  return value;  }template <class FEATURE> voidSelFeature<FEATURE>::define  (  const Selector& a_selector,  real_type a_value  )  {  const int index(a_selector.m_index[0]);  switch (a_selector.m_type)    {    case SELECT_ATTR : if (index>=0) {      if (datum().rows()>index) datum()(index) = a_value;      } break;    case SELECT_DELT : if (index>=0) {             } break;    case SELECT_WEIG :       weight()=a_value;      break;    default :       break;    }  }template <class FEATURE> voidSelFeature<FEATURE>::read  (  istream& is  )  {  bool read_vector(false);  bool read_weight(false);  bool read_result(false);  unrecognized() = "";  read_until(is,KEYWORD_FEATURE);  while (!is_followed_by(is,KEYWORD_CLOSE,false))    {    if (is_followed_by(is,KEYWORD_FEATURE_VECTOR,false))      { read_matrix(is,datum()); read_vector=true; } else    if (is_followed_by(is,KEYWORD_FEATURE_WEIGHT,false))      { is >> weight(); read_weight = true; } else    if (is_followed_by(is,KEYWORD_FEATURE_RESULT,false))      { is >> result(); read_result = true; } else    // ASSUME: there is an IF above, closed by an open ELSE      {      read_until(is,"("); // read opening paranthesis of unknown command      string entry;      read_until_matching_paranthesis(is,'(',')',entry);      unrecognized() += "(";       unrecognized() += entry;       unrecognized() +=") ";      is.putback(')');      }    read_until_matching_paranthesis(is,'(',')');    }  if (!read_vector) { datum().adjust(0); }  if (!read_weight)    { weight() = DEFAULT_FEATURE_WEIGHT; }  if (!read_result)    { result().adjust(0); }  trace("read",*this);  }template <class FEATURE> voidSelFeature<FEATURE>::write  (  ostream& os  )  const  {  os << KEYWORD_FEATURE << " ";  if (datum().rows()>0)    { os << KEYWORD_FEATURE_VECTOR << " ";      write_matrix(os,datum()); os << KEYWORD_CLOSE << " "; }  if (weight()!=DEFAULT_FEATURE_WEIGHT)    os << KEYWORD_FEATURE_WEIGHT << " "        << weight() << KEYWORD_CLOSE << " ";  if (result().rows()>0)    os << KEYWORD_FEATURE_RESULT << " "        << result() << KEYWORD_CLOSE << " ";  os << unrecognized();  os << KEYWORD_CLOSE << " ";  }// template instantiation#endif // SelFeature_SOURCE

⌨️ 快捷键说明

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