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

📄 ghmmwrapper.i

📁 一个通用的隐性马尔可夫C代码库 开发环境:C语言 简要说明:这是一个通用的隐性马尔可夫C代码库
💻 I
📖 第 1 页 / 共 4 页
字号:
/* author       : Wasinee Rungsarityotin and Benjamin Georgi *  filename    : ghmmwrapper/ghmmwrapper.i *  created      : DATE: September, 2003 * * $Id: ghmmwrapper.i,v 1.28 2004/05/03 11:41:28 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  */%module ghmmwrapper%{#include <stdio.h>#include <ghmm/ghmm.h>#include <ghmm/vector.h>#include <ghmm/sequence.h>#include <ghmm/scanner.h>#include <ghmm/smodel.h>#include <ghmm/rng.h>#include <ghmm/reestimate.h>#include <ghmm/foba.h>#include <ghmm/scluster.h>#include <ghmm/mes.h>#include "sdclass_change.h"%}%include carrays.i%include cmalloc.i%include cpointer.i%include cstring.i// %pointer_functions(int, intp)%include constraints.i%include exception.i    %include typemaps.i// Constraints on GHMM date types - no NULL pointers as function arguments%apply Pointer NONNULL { model * };%apply Pointer NONNULL { model ** };%apply Pointer NONNULL { smodel * };%apply Pointer NONNULL { smodel ** };%apply Pointer NONNULL { state * };%apply Pointer NONNULL { sstate * };%apply Pointer NONNULL { sequence_t * };%apply Pointer NONNULL { sequence_t ** };%apply Pointer NONNULL { sequence_d_t * };%apply Pointer NONNULL { sequence_d_t ** };%apply Pointer NONNULL { scluster * }; // Constraints on general C data types - no NULL pointers as function arguments// XXX certain arguments are supposed to be NULL// %apply Pointer NONNULL { int *, double *, int **, double **, void * };/*=============================================================================================  =============================== Random Number Generator (RNG ================================= *//* The global RNG */extern gsl_rng * RNG; /* Important! initialise rng  */extern void gsl_rng_init(void);/* Initialise random timeseed */extern void gsl_rng_timeseed(gsl_rng * r);%inline %{	void time_seed(){		gsl_rng_timeseed(RNG);	}%}		/*=============================================================================================  ================= Utility functions: Matrix allocation and destruction  =====================*//*  Allocation of a double matrix.   @return pointer to a matrix  @param rows: number of rows  @param columns: number of columns  */extern double** matrix_d_alloc(int rows, int columns);/**  Copying and allocation of a double matrix.  @return pointer to a matrix  @param rows: number of rows  @param columns: number of columns  @param copymatrix: matrix to copy   */extern double** matrix_d_alloc_copy(int rows, int columns, double **copymatrix);/**  Free the memory of a double matrix.  @return 0 for succes; -1 for error  @param  matrix: matrix to free  @param  rows: number of rows  */extern int matrix_d_free(double ***matrix,int row);/**  Allocation of a integer matrix.  @return pointer to a matrix  @param rows: number of rows  @param columns: number of columns  */extern int** matrix_i_alloc(int rows, int columns);/**  Free the memory of a integer matrix.  @return 0 for succes; -1 for error  @param  matrix: matrix to free  @param  rows: number of rows  */extern int matrix_i_free(int ***matrix, long rows); /**  Writes a double matrix (without parenthesis).  @param file:       output file  @param matrix:     matrix to write  @param rows:       number of rows  @param columns:    number of columns  @param tab:        format: leading tabs  @param separator:  format: separator for columns  @param ending:     format: end of a row    */extern void matrix_d_print(FILE *file, double **matrix, int rows, int columns, 		    char *tab, char *separator, char *ending);				/*=============================================================================================  =============================== sequence.c  ============================================== */				/**@name sequences  (double and int) *//*@{ (Doc++-Group: sequence) *//** @name struct sequence_t    Sequence structure for integer sequences.     Contains an array of sequences and corresponding    data like sequence label, sequence weight, etc. Sequences may have different    length.     */struct sequence_t {  /** sequence array. sequence[i] [j] = j-th symbol of i-th seq.   */  int **seq;  /** matrix of state ids  */  int **states;  /** array of sequence length */  int *seq_len;  /**  array of sequence labels */  long *seq_label;  /**  array of sequence IDs*/  double *seq_id;  /** positiv! sequence weights.  default is 1 = no weight */  double *seq_w;  /** total number of sequences */  long seq_number;  /** sum of sequence weights */  double total_w;    /* matrix of state labels corresponding to seq */  int **state_labels;   /* number of labels for each sequence */    int *state_labels_len;        };typedef struct sequence_t sequence_t;%pointer_functions(sequence_t **, sequence_setPtr)/** @name struct sequence_d_t    Sequence structure for double sequences.     Contains an array of sequences and corresponding    data like sequnce label, sequence weight, etc. Sequences may have different    length.     */struct sequence_d_t {  /** sequence array. sequence[i] [j] = j-th symbol of i-th seq. */  double **seq;  /** array of sequence length */  int *seq_len;  /**  array of sequence labels */  long *seq_label;  /**  array of sequence IDs*/  double *seq_id;  /** positive! sequence weights.  default is 1 = no weight */  double *seq_w;  /** total number of sequences */  long seq_number;  /** sum of sequence weights */  double total_w;  };typedef struct sequence_d_t sequence_d_t;%pointer_functions(sequence_d_t **, sequence_d_setPtr)/**   Memory allocation for an integer sequence struct. Allocates arrays of lenght   seq\_number. NO allocation for the actual sequence, since its length is    unknown.   @param seq\_number:  number of sequences   @return:     pointer of sequence struct*/extern sequence_t *sequence_calloc(long seq_number);/**   Memory allocation for a double  sequence struct. Allocates arrays of lenght   seq\_number. NO allocation for the actual sequence, since its length is    unknown.   @param seq\_number:  number of sequences   @return:     pointer of sequence struct*/extern sequence_d_t *sequence_d_calloc(long seq_number);/**   Cleans integer sequence pointers in sequence struct. sets    seq\_number to zero.   Differs from sequence\_free since memory is not freed here.    @param sq sequence structure  */extern void sequence_clean(sequence_t *sq);/**   Cleans integer sequence pointers in sequence struct. sets    seq\_number to zero.   Differs from sequence\_free since memory is not freed here.    @param sq sequence structure  */extern void sequence_d_clean(sequence_d_t *sq);/**  Prints one array of integer sequences in a file.  @param file       output file  @param sequence    array of sequences  */void sequence_print(FILE *file, sequence_t *sequence);/**  copy one integer sequence. Memory for target has to be allocated outside.  @param target  target sequence  @param source source sequence  @param len     length of source sequence  */void sequence_copy(int *target, int *source, int len);/**   Reads one or several arrays of double sequences.    Calls sequence\_read\_alloc, where reading   and memory allocation is done.    @return pointer to sequence array   @param filename    input filename*/sequence_d_t **sequence_d_read(const char *filename, int *sqd_number);/**  Adds all integer sequences, sequence lengths etc   from source to target. Memory allocation is done here.  @param target target sequence structure  @param source  source sequence structure  @return -1 for error, 0 for success  */int sequence_add(sequence_t *target, sequence_t *source);/**  Adds all double sequences, sequence lengths etc   from source to target. Memory allocation is done here.  @param target target sequence structure  @param source  source sequence structure  @return -1 for error, 0 for success  */extern int sequence_d_add(sequence_d_t *target, sequence_d_t *source);/**  Frees all memory in a given array of integer sequences.  @param sq sequence  structure  @return 0 for succes, -1 for error  */int sequence_free(sequence_t **sq);/**  Frees all memory in a given array of double sequences.  @param sq sequence  structure  @return 0 for succes, -1 for error  */int sequence_d_free(sequence_d_t **sq);extern void sequence_d_print(FILE *file, sequence_d_t *sqd, int discrete);/*** !!!!!!!! TO DO: Free functions for all types of pointers !!!!!!!!***/%inline%{  /* return a C-pointer to an integer sequence */  int *get_onesequence(sequence_t *seqpt, int seqnumber) {     return (int *) seqpt->seq[seqnumber];  }    sequence_t *seq_read(char* filename ){	  int i;	  sequence_t** s;	  //s = (sequence_d_t **) malloc(1*sizeof(sequence_d_t*));	  s = sequence_read(filename, &i);	  return s[0];  }    sequence_t* get_seq_ptr(sequence_t** array, int index){	  return (sequence_t*) array[index];  }    /*** create and manipulate an array of pointers of pointers to sequence_d_t structs ***/  sequence_d_t **sequence_d_t_array(int size) {     int i;	 sequence_d_t **s;	 s = (sequence_d_t **) malloc(size*sizeof(sequence_d_t*));	 for(i =0;i<size;i++){			 s[i] = NULL;	 }	 return s;	   }  sequence_d_t* get_seq_d_ptr(sequence_d_t** array, int index){	  return (sequence_d_t*) array[index];  }	      void set_seq_d_array(sequence_d_t** array, int index,sequence_d_t* seq){	array[index] = seq;  }	    void set_sequence_d_label(sequence_d_t* seq, int seq_num, long label){	  seq->seq_label[seq_num] = label;  }    long get_sequence_d_label(sequence_d_t* seq, int seq_num ){	  return seq->seq_label[seq_num];  }	         sequence_d_t *seq_d_read(char* filename ){	  int i;      sequence_d_t** s;	  //s = (sequence_d_t **) malloc(1*sizeof(sequence_d_t*));	  s = sequence_d_read(filename, &i);	  return *s;  }  void call_sequence_print(char* ch, sequence_t* seq){    FILE* file_name;    file_name = fopen(ch,"at");    sequence_print(file_name,seq);    fclose(file_name);  }	    void call_sequence_d_print(char* ch,sequence_d_t* seq, int disc){    FILE* file_name;    file_name = fopen(ch,"at");    sequence_d_print(file_name,seq, disc);    fclose(file_name);  }	     %}/*=============================================================================================  =============================== model.c  ============================================== */

⌨️ 快捷键说明

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