📄 prototype.cpp
字号:
/* Context : Fuzzy Clustering Algorithms Author : Frank Hoeppner, see also AUTHORS file Description : implementation of class module Prototype History : prototype.normmatrix: $Id:$ prototype.covmatrix: $Id:$ prototype.apriori: $Id:$ prototype.operation: $Id:$ prototype.unrecognized: $Id:$ 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 Prototype_SOURCE#define Prototype_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif// necessary includes#include "Prototype.hpp"#include "stlstream.hpp"// data// implementationPrototype::Prototype ( ) : m_type(CLUSTER_PROTOTYPE) , m_total_pow_membxweight(DEFAULT_PROTO_WEIGHT) , m_covdet(DEFAULT_PROTO_COVDET) , m_apriori(DEFAULT_PROTO_APRIORI) , m_operation(DEFAULT_PROTO_OPERATION) { m_center.adjust(0); m_normmatrix.adjust(0,0); m_covmatrix.adjust(0,0); m_coefficient.adjust(0); m_range.adjust(0); start().adjust(0); delta().adjust(0); }bool Prototype::consistent ( int a_data_dim, int a_act_depth, int& a_prot_depth ) const { bool ok(true); if ((m_center.rows()!=a_data_dim) && (m_center.rows()!=0)) { ok=false; error("prototype center size mismatch",*this); } if ( (m_normmatrix.rows()!=m_center.rows()) || (m_normmatrix.cols()!=m_center.rows()) ) { ok=false; error("prototype norm matrix size mismatch",*this); } if ( (m_covmatrix.rows()!=m_center.rows()) || (m_covmatrix.cols()!=m_center.rows()) ) { ok=false; error("prototype norm matrix size mismatch",*this); } /* == data_dim if no transformation given, otherwise == transform.rows if ((m_coefficient.rows()!=a_data_dim) && (m_coefficient.rows()!=0)) { ok=false; error("prototype center size mismatch",*this); } */ if ( ((m_start.rows()!=a_data_dim) || (m_delta.rows()!=a_data_dim)) && (m_start.rows()!=0) ) { ok=false; error("prototype line start/delta size mismatch",*this); } return ok; }real_type Prototype::select ( const Selector& a_selector ) const { real_type value(0); int index(a_selector.m_index[0]); switch (a_selector.m_type) { case SELECT_ATTR : if (index>=0) { if (center().rows()>index) value=center()(index); else if (start().rows()>index) value=start()(index); } break; case SELECT_DELT : if (index>=0) { if (delta().rows()>index) value=delta()(index); } break; case SELECT_WEIG : value=total_pow_membxweight(); break; default : break; } return value; }real_typePrototype::diff ( const Prototype& a_prot ) const { real_type diff(0); diff = max(diff,matrix_maximum_distance(center(),a_prot.center())); diff = max(diff,matrix_maximum_distance(start(),a_prot.start())); diff = max(diff,matrix_maximum_distance(delta(),a_prot.delta())); return diff; }voidPrototype::read ( istream& is ) { //bool read_total_pow_membxweight(false); bool read_total_pow_membxweight(false); bool read_center(false); bool read_normmatrix(false); bool read_covmatrix(false); bool read_covdet(false); bool read_apriori(false); bool read_linear(false); bool read_range(false); bool read_operation(false); bool read_line(false); m_hierarchy.clear(); m_unrecognized = ""; read_until(is,KEYWORD_PROTOTYPE); while (!is_followed_by(is,KEYWORD_CLOSE,false)) { /*if (is_followed_by(is,KEYWORD_PROTO_WEIGHT,false)) { is >> m_total_pow_membxweight; read_total_pow_membxweight=true; } */ if (is_followed_by(is,KEYWORD_PROTO_WEIGHT,false)) { is >> m_total_pow_membxweight; read_total_pow_membxweight=true; } else if (is_followed_by(is,KEYWORD_PROTO_CENTER,false)) { read_matrix(is,m_center); read_center=true; } else if (is_followed_by(is,KEYWORD_PROTO_NORMMAT,false)) { read_matrix(is,m_normmatrix); read_normmatrix=true; } else if (is_followed_by(is,KEYWORD_PROTO_COVMAT,false)) { read_matrix(is,m_covmatrix); read_covmatrix=true; } else if (is_followed_by(is,KEYWORD_PROTO_COVDET,false)) { is >> m_covdet; read_covdet=true; } else if (is_followed_by(is,KEYWORD_PROTO_APRIORI,false)) { is >> m_apriori; read_apriori=true; } else if (is_followed_by(is,KEYWORD_PROTO_COEFF,false)) { read_matrix(is,m_coefficient); read_linear=true; } else if (is_followed_by(is,KEYWORD_PROTO_RANGE,false)) { read_matrix(is,m_range); read_range=true; } else if (is_followed_by(is,KEYWORD_PROTO_OPERATION,false)) { is >> m_operation; read_operation=true; } else if (is_followed_by(is,KEYWORD_PROTO_LINE,false)) { read_matrix(is,start()); read_matrix(is,delta()); read_line=true; } else if (is_followed_by(is,KEYWORD_PROTO_HIERARCHY)) { stl_container_input(is,m_hierarchy,KEYWORD_PROTO_HIERARCHY," ",KEYWORD_CLOSE); is.putback(')'); // is expected below } else { read_until(is,"("); // read opening paranthesis of unknown command string entry; read_until_matching_paranthesis(is,'(',')',entry); m_unrecognized += "("; m_unrecognized += entry; m_unrecognized +=") "; is.putback(')'); } read_until_matching_paranthesis(is,'(',')'); } //if (!read_total_pow_membxweight) m_total_pow_membxweight=0; if (!read_total_pow_membxweight) m_total_pow_membxweight=0; if (!read_center) { m_center.adjust(0); } if (!read_normmatrix) { m_normmatrix.adjust(m_center.rows(),m_center.rows()); matrix_set_identity(m_normmatrix); } if (!read_covmatrix) { m_covmatrix.adjust(m_center.rows(),m_center.rows()); matrix_set_identity(m_covmatrix); m_covdet = 1.0; } if ((!read_covdet) && (read_covmatrix)) { m_covdet = matrix_det(m_covmatrix); } if (!read_apriori) { m_apriori = DEFAULT_PROTO_APRIORI; } if (!read_linear) { m_coefficient.adjust(0); } if (!read_range) { m_range.adjust(0); } if (!read_operation) { m_operation = DEFAULT_PROTO_OPERATION; } if (!read_line) { start().adjust(0); delta().adjust(0); } trace("read",*this); }voidPrototype::write ( ostream& os ) const { os << KEYWORD_PROTOTYPE << " "; /* if (m_total_pow_membxweight!=DEFAULT_PROTO_WEIGHT) { os << KEYWORD_PROTO_WEIGHT << " " << m_total_pow_membxweight << KEYWORD_CLOSE << " "; } */ if (m_total_pow_membxweight!=DEFAULT_PROTO_WEIGHT) { os << KEYWORD_PROTO_WEIGHT << " " << m_total_pow_membxweight << KEYWORD_CLOSE << " "; } if (m_center.rows()>0) { os << KEYWORD_PROTO_CENTER << " " << m_center << KEYWORD_CLOSE << " "; } if ((m_normmatrix.rows()>0) && (m_normmatrix.cols()>0) && (!matrix_is_identity(m_normmatrix))) { os << KEYWORD_PROTO_NORMMAT << " " << m_normmatrix << KEYWORD_CLOSE << " "; } if ((m_covmatrix.rows()>0) && (m_covmatrix.cols()>0) && (!matrix_is_identity(m_covmatrix))) { os << KEYWORD_PROTO_COVMAT << " " << m_covmatrix << KEYWORD_CLOSE << " "; } if (m_covdet!=DEFAULT_PROTO_COVDET) { os << KEYWORD_PROTO_COVDET << " " << m_covdet << KEYWORD_CLOSE << " "; } if (m_apriori!=DEFAULT_PROTO_APRIORI) { os << KEYWORD_PROTO_APRIORI << " " << m_apriori << KEYWORD_CLOSE << " "; } if (m_coefficient.rows()>0) { os << KEYWORD_PROTO_COEFF << " " << m_coefficient << KEYWORD_CLOSE << " "; } if (m_range.rows()!=0) { os << KEYWORD_PROTO_RANGE << " " << m_range << KEYWORD_CLOSE << " "; } if (m_operation!=DEFAULT_PROTO_OPERATION) { os << KEYWORD_PROTO_OPERATION << " " << m_operation << KEYWORD_CLOSE << " "; } if (m_start.rows()>0) { os << KEYWORD_PROTO_LINE << " " << m_start << m_delta << KEYWORD_CLOSE << " "; } if (!m_hierarchy.empty()) stl_container_output(os,m_hierarchy,KEYWORD_PROTO_HIERARCHY," ",KEYWORD_CLOSE); os << m_unrecognized; os << KEYWORD_CLOSE << " "; }// template instantiation#endif // Prototype_SOURCE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -