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

📄 ghmm_sequence.cpp

📁 一个通用的隐性马尔可夫C代码库 开发环境:C语言 简要说明:这是一个通用的隐性马尔可夫C代码库
💻 CPP
字号:
/* * created: 21 Feb 2002 by Peter Pipenbacher * authors: Peter Pipenbacher (pipenb@zpr.uni-koeln.de) * file   : $Source: /cvsroot/ghmm/ghmm/ghmm++/GHMM_Sequence.cpp,v $ * $Id: GHMM_Sequence.cpp,v 1.6 2003/09/18 10:04:49 cic99 Exp $ *  * Copyright (C) 1998-2001, ZAIK/ZPR, Universit鋞 zu K鰈n *  * 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 *  */#include "ghmm++/GHMM_Sequence.h"#include "ghmm++/GHMM_Alphabet.h"#ifdef HAVE_NAMESPACESusing namespace std;#endifGHMM_Sequence::GHMM_Sequence(GHMM_SequenceType my_sequence_type, int len, int my_weight) {  switch (my_sequence_type) {  case GHMM_INT:    init_INT(NULL,len,my_weight);    break;  case GHMM_DOUBLE:    init_DOUBLE(len,my_weight);    break;  }}GHMM_Sequence::GHMM_Sequence(GHMM_Alphabet* my_alphabet, int len, int my_weight) {  init_INT(my_alphabet,len,my_weight);}GHMM_Sequence::~GHMM_Sequence() {  if (c_i_sequences)    sequence_free(&c_i_sequences);  if (c_d_sequences)    sequence_d_free(&c_d_sequences);    c_i_sequences = NULL;  c_d_sequences = NULL;}const char* GHMM_Sequence::toString() const {  return "GHMM_Sequence";}void GHMM_Sequence::XMLIO_finishedReading() {  unsigned int i;  XMLIO_ArrayElement<string>::XMLIO_finishedReading();  if (sequence_type == GHMM_INT) {    string seq;        c_i_sequences->seq_w[0] = weight;        for (i = 0; i < size(); ++i)      seq += (*this)[i];        resize(seq.length());        for (i = 0; i < seq.length(); ++i)      c_i_sequences->seq[0][i] = alphabet->getIndex(seq.substr(i,1));  }  if (sequence_type == GHMM_DOUBLE) {    resize(size());    c_d_sequences->seq_w[0] = weight;    for (i = 0; i < size(); ++i)      c_d_sequences->seq[0][i] = atof((*this)[i].c_str());  }  /* clear array. */  clear();}void GHMM_Sequence::resize(int new_len) {  int new_alloc_len = max(1,new_len);  switch (sequence_type) {  case GHMM_INT:    c_i_sequences->seq[0]     = (int*) realloc(c_i_sequences->seq[0],sizeof(int) * new_alloc_len);    c_i_sequences->seq_len[0] = new_len;    break;  case GHMM_DOUBLE:    c_d_sequences->seq[0]     = (double*) realloc(c_d_sequences->seq[0],sizeof(double) * new_alloc_len);    c_d_sequences->seq_len[0] = new_len;    break;  }}void GHMM_Sequence::init() {  c_i_sequences = NULL;  c_d_sequences = NULL;  alphabet      = NULL;}void GHMM_Sequence::init_INT(GHMM_Alphabet* my_alphabet, int len, int my_weight) {  init();  sequence_type = GHMM_INT;  c_i_sequences = sequence_calloc(1);  alphabet      = my_alphabet;  resize(len);  weight = my_weight;}void GHMM_Sequence::init_DOUBLE(int len, int my_weight) {  init();  sequence_type = GHMM_DOUBLE;  c_d_sequences = sequence_d_calloc(1);  resize(len);  weight = my_weight;}void GHMM_Sequence::setDouble(int index, double value) {  if (c_d_sequences)    if (c_d_sequences->seq_len[0] > index)      c_d_sequences->seq[0][index] = value;}void GHMM_Sequence::setInt(int index, int value) {  if (c_i_sequences)    if (c_i_sequences->seq_len[0] > index)      c_i_sequences->seq[0][index] = value;}void GHMM_Sequence::print(FILE *file, int discrete) const {  if (sequence_type == GHMM_INT)    sequence_print(file,c_i_sequences);  if (sequence_type == GHMM_DOUBLE)    sequence_d_print(file,c_d_sequences,discrete);}

⌨️ 快捷键说明

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