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

📄 turnintopointmap.cpp

📁 模糊聚類分析源碼。包含教學文件
💻 CPP
字号:
/*    Context       : Fuzzy Clustering Algorithms  Author        : Frank Hoeppner, see also AUTHORS file   Description   : implementation of class module TurnIntoPointMap                    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 TurnIntoPointMap_SOURCE#define TurnIntoPointMap_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif// necessary includes#include "TurnIntoPointMap.hpp"// data// implementationtemplate < class ANALYSIS >TurnIntoPointMap< ANALYSIS >::TurnIntoPointMap  (  Algorithm<basic_pointmap_type>* ap_alg  )  : mp_succ_alg(ap_alg)  , m_analysis_counter(0)    {    }template < class ANALYSIS >TurnIntoPointMap< ANALYSIS >::~TurnIntoPointMap  (  )  {  FUNCLOG("~TurnIntoPointMap");  basic_pointmap_type::time_map_type::iterator i_data_map,i_mesh_map;  for (int time=(int)m_point_map.bbox().minimum(AXIS_T);       time<=(int)m_point_map.bbox().maximum(AXIS_T);       ++time)    {    i_mesh_map = m_point_map.grid().find(time);    i_data_map = m_point_map.data().find(time);    if ((i_mesh_map!=m_point_map.grid().end()) &&         (i_data_map!=m_point_map.data().end()) &&        ((*i_mesh_map).second.size()<3))      {      (*i_data_map).second.insert((*i_mesh_map).second.begin(),(*i_mesh_map).second.end());      (*i_mesh_map).second.clear();      }    }  (*mp_succ_alg)(m_point_map);  delete mp_succ_alg;  }template < class ANALYSIS >voidTurnIntoPointMap< ANALYSIS >::operator()  (  ANALYSIS& a_analysis  )  {  FUNCLOG("TurnIntoPointMap");    ++m_analysis_counter;  mp_analysis = &a_analysis;  m_connect = a_analysis.option().connect();  {    m_data_counter=0;    mi_link=a_analysis.links().begin();    const int c(a_analysis.option().number_prototypes());    typename ANALYSIS::data_type *p_prev(NULL);    for (        typename ANALYSIS::data_iter i_data(a_analysis.data().begin());        i_data != a_analysis.data().end();        ++i_data        )      {      (*i_data).apply(this,0,p_prev,NULL /*no father*/);      ++m_data_counter;      for (int p=0;p<c;++p) ++mi_link;      p_prev = &(*i_data);      }  }  invariant(mi_link==a_analysis.links().end(),"links match",SOURCELOC);  {    m_prot_counter=0;    for (        typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin());        i_prot != a_analysis.prototypes().end();        ++i_prot        )       {      (*i_prot).apply(this,0);      ++m_prot_counter;      }  }  m_point_map.options()[m_analysis_counter] = a_analysis.option();  // bbox includes zero => otherwise selector one will be scaled to zero!  // affects only memb, dist, size where zero values are meaningful!  // by using point as initialization of lower/upper, if get_bounds  // does not modify the values, we do not touch the bbox  basic_pointmap_type::display_tuple_type point;  if (!m_point_map.data()[1].empty()) point = (*m_point_map.data()[1].begin());  basic_pointmap_type::display_tuple_type lower(point),upper(point);  for (int axis=0;axis<lower.rows();++axis)    {    a_analysis.get_selection_bounds(a_analysis.option().m_selector[axis],      lower(axis),upper(axis));    }  m_point_map.bbox().include(lower);  m_point_map.bbox().include(upper);    }template < class ANALYSIS >voidTurnIntoPointMap< ANALYSIS >::operator()  (  const typename ANALYSIS::data_type& a_feature,  int a_hierarchy_level,  const typename ANALYSIS::data_type* ap_prev,  const typename ANALYSIS::data_type* ap_father  )  {  FUNCLOG("TurnIntoPointMap::iteration(data)");  basic_pointmap_type::display_tuple_type point;  const typename ANALYSIS::data_type *prev;  for (int axis=0;axis<point.rows();++axis)    {    switch (m_connect)      {      case FC_CONNECT_HIER : prev=ap_father; break;      case FC_CONNECT_FLAT : prev=ap_prev; break;      default              : prev=NULL; break;      }    point[axis] = mp_analysis->select(mp_analysis->option().m_selector[axis],       a_feature,m_data_counter,m_analysis_counter,a_hierarchy_level,mi_link,       prev);    }  if ((m_connect==FC_CONNECT_HIER) && (prev==NULL))    { // in case of hierarchical display: no lines for top level    point[AXIS_DX] = point[AXIS_DY] = point[AXIS_DZ] = 0;    }  bool griddata;  if (m_point_map.grid()[ point[AXIS_T] ].size()==0)     {    griddata=false;    }   else    {    // find 1st index where point differs from lastpoint    int index(0);    while ((index<=AXIS_Y) && (point(index)==lastpoint(index))) ++index;    // we MUST have a difference at this index    griddata=(index<=AXIS_Y) && (lastpoint(index)!=point(index));    // the difference must be equal to the gridresolution    if (griddata)      {      if (gridres(index)==0)        gridres(index)=point(index)-lastpoint(index);      else        griddata=fabs(gridres(index) - (point(index)-lastpoint(index)))<0.01;      }    // all remaining components must be equal to start value or last value    if (griddata)      {      ++index;      for (;index<=AXIS_Y;++index)        griddata &= ((point(index)==lastpoint(index)) ||                      ((point(index)==gridstart(index)) && (lastpoint(index)!=gridstart(index)))                    );      }    if (m_connect==FC_CONNECT_SEQC)      {      point[AXIS_DX] = lastpoint[AXIS_X] - point[AXIS_X];      point[AXIS_DY] = lastpoint[AXIS_Y] - point[AXIS_Y];      point[AXIS_DZ] = lastpoint[AXIS_Z] - point[AXIS_Z];      }    }  if (!griddata)    {    m_point_map.data()[ point[AXIS_T] ].insert(       m_point_map.grid()[ point[AXIS_T] ].begin(),      m_point_map.grid()[ point[AXIS_T] ].end());    m_point_map.grid()[ point[AXIS_T] ].clear();    gridstart=point;    matrix_set_scalar(gridres,0);    }  m_point_map.grid()[ point[AXIS_T] ].insert(point);  lastpoint=point;  // make bbox respect points and deltas  m_point_map.bbox().include(point);  point[AXIS_X] += point[AXIS_DX];  point[AXIS_Y] += point[AXIS_DY];  point[AXIS_Z] += point[AXIS_DZ];  m_point_map.bbox().include(point);  }template < class ANALYSIS >voidTurnIntoPointMap< ANALYSIS >::operator()  (  const typename ANALYSIS::prot_type& a_prototype,  int a_hierarchy_level  )  {  FUNCLOG("TurnIntoPointMap::iteration(prot)");  basic_pointmap_type::display_tuple_type point;  for (int axis=0;axis<point.rows();++axis)    {    point[axis] = mp_analysis->select(mp_analysis->option().m_selector[axis],      a_prototype,m_prot_counter,m_analysis_counter,a_hierarchy_level);    }  m_point_map.prototypes()[ point[AXIS_T] ].insert(point);  // make bbox respect points and deltas  m_point_map.bbox().include(point);  point[AXIS_X] += point[AXIS_DX];  point[AXIS_Y] += point[AXIS_DY];  point[AXIS_Z] += point[AXIS_DZ];  m_point_map.bbox().include(point);  }// template instantiation//template class TurnIntoPointMap<full_analysis_type>;#include "Tuple.cpp"template class Tuple<AXIS_END,real_type>;#include "Box.cpp"template class Box< Tuple<AXIS_END,real_type> >;#endif // TurnIntoPointMap_SOURCE

⌨️ 快捷键说明

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