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

📄 partialknotupdate.cpp

📁 模糊聚類分析源碼。包含教學文件
💻 CPP
字号:
/*    Context       : Fuzzy Clustering Algorithms  Author        : Frank Hoeppner, see also AUTHORS file   Description   : implementation of class module PartialKnotUpdate                    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 PartialKnotUpdate_SOURCE#define PartialKnotUpdate_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif// necessary includes#include "PartialKnotUpdate.hpp"// data// implementationtemplate < class ANALYSIS >PartialKnotUpdate< ANALYSIS >::PartialKnotUpdate  (  bool a_update_k,  Algorithm<ANALYSIS> *ap_alg  )  : mp_succ_alg(ap_alg)  , axis( a_update_k ? AXIS_X : AXIS_Y )  , hat_axis( a_update_k ? AXIS_Y : AXIS_X )    {    }template < class ANALYSIS >PartialKnotUpdate< ANALYSIS >::~PartialKnotUpdate  (  )  {  FUNCLOG("~PartialKnotUpdate");    delete mp_succ_alg;  }template < class ANALYSIS >voidPartialKnotUpdate< ANALYSIS >::operator()  (  ANALYSIS& a_analysis  )  {  FUNCLOG("PartialKnotUpdate");      const int c( a_analysis.option().number_prototypes() );    tuple_type l,hl,s;    tuple_type start,delta;    matrix_type T;    l.adjust(c+1);    hl.adjust(c+1);    s.adjust(c+1);    T.adjust(c+1,c+1);    start.adjust(2); delta.adjust(2);         matrix_set_scalar(s,0);    matrix_set_scalar(T,0);    real_type xmin(POS_IMPOSSIBLE_RANGE),xmax(NEG_IMPOSSIBLE_RANGE);    bool line_type;    real_type z,hz,nz,nhz;    {      hl[0] = (*a_analysis.prototypes().begin()).start()[hat_axis];      int i(1);      for (          typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin());          i_prot != a_analysis.prototypes().end();          ++i_prot          )        {        if ((*i_prot).type()==CLUSTER_PROTOTYPE)          {          hl[i] = (*i_prot).start()[hat_axis] + (*i_prot).delta()[hat_axis];          ++i;          }         }       trace("hl=",hl);    }    typename ANALYSIS::link_iter i_link(a_analysis.links().begin());    for (        typename ANALYSIS::data_iter i_data(a_analysis.data().begin());        i_data != a_analysis.data().end();        ++i_data        )      {      int i(0);      for (          typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin());          i_prot != a_analysis.prototypes().end();          ++i_prot          )        {        real_type u ( (*i_link).pow_membxweight() );      line_type = ( (*i_data).datum().rows()==0 );  if (u!=0)    {      if (line_type)        {   start[AXIS_X] = max((*i_prot).start()[AXIS_X],(*i_data).start()[AXIS_X]);  delta[AXIS_X] = min((*i_prot).start()[AXIS_X]+(*i_prot).delta()[AXIS_X],                      (*i_data).start()[AXIS_X]+(*i_data).delta()[AXIS_X]) - start[AXIS_X];  start[AXIS_Y] = (*i_data).start()[AXIS_Y]+(*i_data).delta()[AXIS_Y]*(start[AXIS_X]-(*i_data).start()[AXIS_X])/(*i_data).delta()[AXIS_X];  delta[AXIS_Y] =    (*i_data).delta()[AXIS_Y]/(*i_data).delta()[AXIS_X]*delta[AXIS_X];  trace_id("adjust_line","prototype line",make_pair((*i_prot).start(),(*i_prot).delta()));  trace_id("adjust_line","original data line",make_pair((*i_data).start(),(*i_data).delta()));  trace_id("adjust_line","adjusted data line",make_pair(start,delta));  invariant(delta[AXIS_X]>=0,"lines intersect");        }      else        {        matrix_set(start,(*i_data).datum());        matrix_set_scalar(delta,0);        }      z = (start[axis]);      hz = (start[hat_axis]);      nz = (z+delta[axis]);      nhz = (hz+delta[hat_axis]);      if (axis==0) { xmin=min(z,xmin); xmax=max(nz,xmax); }    }        if (u!=0)           {          if (line_type)            {              s(i)     += u*(hl[i]-hl[i+1])*                            ((3.0*hl[i+1]-2.0*nhz-hz)*nz+(3.0*hl[i+1]-2.0*hz-nhz)*z);              T(i,i)   += u*((hz-nhz)*(3.0*hl[i+1]-2.0*nhz-hz)                            +(hl[i+1]-hz)*3.0*(2.0*hl[i+1]-nhz-hz));              T(i,i+1) += u*((nhz-hz)*(3.0*hl[i]-2.0*nhz-hz)                            -(hl[i+1]-hz)*3.0*(2.0*hl[i]-nhz-hz));              s(i+1)     += u*(hl[i+1]-hl[i])*                              ((3.0*hl[i]-2.0*nhz-hz)*nz+(3.0*hl[i]-2.0*hz-nhz)*z);              T(i+1,i)   += u*((nhz-hz)*(3.0*hl[i+1]-2.0*nhz-hz)                              -(hl[i]-hz)*3.0*(2.0*hl[i+1]-nhz-hz));              T(i+1,i+1) += u*((hz-nhz)*(3.0*hl[i]-2.0*nhz-hz)                              +(hl[i]-hz)*3.0*(2.0*hl[i]-nhz-hz));            }          else             { // point type              s(i)     += u*z*(hl[i]-hl[i+1])*(hl[i+1]-hz);              T(i,i)   += u*SQR(hl[i+1]-hz);              T(i,i+1) += u*(hz-hl[i])*(hl[i+1]-hz);              s(i+1)     += u*z*(hl[i]-hl[i+1])*(hz-hl[i]);              T(i+1,i)   += u*(hz-hl[i])*(hl[i+1]-hz);              T(i+1,i+1) += u*SQR(hz-hl[i]);            }          }        ++i_link; ++i;        }      }    trace("T=",T);    trace("s=",s);    gauss_jordan(T);    matrix_set_product(l,T,s);    matrix_scale(l,-1.0);    if (axis==AXIS_X)       {        trace("original l=",l);      l[0]=xmin; l[c]=xmax;           }    int i(0);    bool degenerated(false);    real_type change(a_analysis.option().change());    for (        typename ANALYSIS::prot_iter i_prot(a_analysis.prototypes().begin());        i_prot != a_analysis.prototypes().end();        ++i_prot        )      {      change = max(change,fabs(l[i]-(*i_prot).start()[axis]));      (*i_prot).start()[axis] = l[i];      (*i_prot).delta()[axis] = l[i+1]-l[i];      if (axis==AXIS_X) /* only relevant when x-axis */        if (l[i+1]-l[i]<0)          { degenerated=true; /* tiny, delete */ }      ++i;      }     a_analysis.option().change()=change;    degenerated &= (axis==AXIS_X); // only relevant when updating x axis    trace("l=",l);    trace("degenerated=",degenerated);        // quick exit when degenerated    if (degenerated) a_analysis.option().change() = 0;    (*mp_succ_alg)(a_analysis);    }// template instantiation#endif // PartialKnotUpdate_SOURCE

⌨️ 快捷键说明

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