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

📄 ext_alloc.c

📁 LastWave
💻 C
📖 第 1 页 / 共 3 页
字号:
/*..........................................................................*//*                                                                          *//*      L a s t W a v e    P a c k a g e 'extrema1d' 2.1                    *//*                                                                          *//*      Copyright (C) 1999-2002 Emmanuel Bacry.                             *//*      email : lastwave@cmap.polytechnique.fr                              *//*                                                                          *//*..........................................................................*//*                                                                          *//*      This program is a 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 (in a file named COPYRIGHT);                *//*      if not, write to the Free Software Foundation, Inc.,                *//*      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA             *//*                                                                          *//*..........................................................................*//****************************************************************************//*                                                                          *//*  ext_alloc.c    Functions for (des)allocation of:                        *//*                     extrema (EXT)                                        *//*		       extrema list (EXTLIS)                              *//*                     extrema representation (EXTREP)                    *//*                                                                          *//****************************************************************************/#include "lastwave.h"#include "int_fsilist.h"#include "extrema1d.h"/******************************************************** *  *     Dealing with Extrema * ********************************************************/  /* *           (Des)Allocation of extrema EXT          */extern int flagOn;/* Delete an extremum  (WARNING : it's better to use RemoveDeleteExt) */void DeleteExt(EXT ext){    if (ext == NULL) return;    RemoveRefValue(ext);  if (ext->nRef > 0) return;  if (flagOn) Printf("** Delete Ext %p\n",ext);     #ifdef DEBUGALLOCDebugType = "Ext1d";#endif  Free(ext);}/* allocate an extrema and returns it */EXT NewExt(void){  EXT ext;#ifdef DEBUGALLOCDebugType = "Ext1d";#endif  ext = (EXT) (Malloc(sizeof(struct ext)));   InitValue(ext,&tsExt);     ext->type = 1;  ext->previous = ext->next = NULL;  ext->coarser = ext->finer = NULL;    ext->extlis = NULL;    return(ext);}/* Remove an extremum from its extrep and delete it */void RemoveDeleteExt(EXT ext){  if (ext->extlis != NULL) {    ext->extlis->size--;    if (ext->extlis->first == ext) ext->extlis->first = ext->next;  }  if (ext->previous != NULL) {    if (ext->next != NULL) {      ext->previous->next = ext->next;      ext->next->previous = ext->previous;    }    else ext->previous->next = NULL;  }  else if (ext->next != NULL) ext->next->previous = NULL;    if (ext->coarser != NULL) ext->coarser->finer = NULL;  if (ext->finer != NULL) ext->finer->coarser = NULL;    ext->next = ext->previous = ext->finer = ext->coarser = NULL;  ext->extlis =  NULL;      DeleteExt(ext);}/* Remove an extrema chain from its extrep */void RemoveDeleteChain(EXT ext){  EXT ext1;    while (ext->coarser != NULL) ext = ext->coarser;    while (ext != NULL) {    ext1 = ext->finer;    RemoveDeleteExt(ext);    ext = ext1;  }}/* Copy an extremum */EXT CopyExt(EXT in,EXT out){    if (out == NULL) out = NewExt();    	out->abscissa = in->abscissa;	out->scale = in->scale;	out->ordinate = in->ordinate;	out->next = in->next;	out->previous = in->previous;	out->coarser = in->coarser;	out->finer = in->finer;	out->type = in->type;		out->index = in->index;	out->extlis = in->extlis;		return(out);}/* * Command to perform operations on extrema */ void C_Ext(char **argv){  EXT ext;  char *action;    argv = ParseArgv(argv,tWORD,&action,tEXT,&ext,0);    /* remove action */  if (!strcmp(action,"remove")) RemoveDeleteExt(ext);      /* else remove chain action */  else if (!strcmp(action,"removechain")) RemoveDeleteChain(ext);      else Errorf("Unknown action '%s'",action);}/* * 'extrep' field */static char *extrepDoc = "{} {Gets the extrema representation (type &extrep), the extremum is in.}";static void * GetExtrepExtV(VALUE val, void **arg){  EXT ext;    /* Documentation */  if (val == NULL) return(extrepDoc);    ext = (EXT) val;  if(ext->extlis == NULL)  return(GetValueField(nullValue,arg));  return(GetValueField(ext->extlis->extrep,arg));}/* * 'first' field */static char *firstDoc = "{} {Gets the first extremum at the same scale.}";static void * GetFirstExtV(VALUE val, void **arg){  EXT ext;    /* Documentation */  if (val == NULL) return(firstDoc);    ext = (EXT) val;  while (ext->previous != NULL) ext = ext->previous;  return(GetValueField(ext,arg));}/* * 'last' field */static char *lastDoc = "{} {Gets the last extremum at the smae scale.}";static void * GetLastExtV(VALUE val, void **arg){  EXT ext;    /* Documentation */  if (val == NULL) return(lastDoc);    ext = (EXT) val;  while (ext->next != NULL) ext = ext->next;  return(GetValueField(ext,arg));}/* * 'coarsest' field */static char *coarsestDoc = "{} {Gets the coarsest extremum (or null if none) on the same chain.}";static void * GetCoarsestExtV(VALUE val, void **arg){  EXT ext;    /* Documentation */  if (val == NULL) return(coarsestDoc);    ext = (EXT) val;  while (ext->coarser != NULL) ext = ext->coarser;  return(GetValueField(ext,arg));}/* * 'finest' field */static char *finestDoc = "{} {Gets the finest extremum (or null if none) on the same chain.}";static void * GetFinestExtV(VALUE val, void **arg){  EXT ext;    /* Documentation */  if (val == NULL) return(finestDoc);    ext = (EXT) val;  while (ext->finer != NULL) ext = ext->finer;  return(GetValueField(ext,arg));}/* * 'coarser' field */static char *coarserDoc = "{} {Gets the coarser extremum (or null if none) at the next larger scale on the same chain.}";static void * GetCoarserExtV(VALUE val, void **arg){  EXT ext;  ext = (EXT) val;  /* Documentation */  if (val == NULL) return(coarserDoc);    if (ext->coarser != NULL) return(GetValueField(ext->coarser,arg));  return(GetValueField(nullValue,arg));}/* * 'finer' field */static char *finerDoc = "{} {Gets the finer extremum (or null if none) at the next smaller scale on the same chain.}";static void * GetFinerExtV(VALUE val, void **arg){  EXT ext;  ext = (EXT) val;  /* Documentation */  if (val == NULL) return(finerDoc);    if (ext->finer != NULL) return(GetValueField(ext->finer,arg));  return(GetValueField(nullValue,arg));}/* * 'previous' field */static char *previousDoc = "{} {Gets the previous extremum (or null if none) at the same scale.}";static void * GetPreviousExtV(VALUE val, void **arg){  EXT ext;  ext = (EXT) val;  /* Documentation */  if (val == NULL) return(previousDoc);    if (ext->previous != NULL) return(GetValueField(ext->previous,arg));  return(GetValueField(nullValue,arg));}/* * 'next' field */static char *nextDoc = "{} {Gets the next extremum (or null if none) at the same scale.}";static void * GetNextExtV(VALUE val, void **arg){  EXT ext;    /* Documentation */  if (val == NULL) return(nextDoc);  ext = (EXT) val;    if (ext->next != NULL) return(GetValueField(ext->next,arg));  return(GetValueField(nullValue,arg));}/* * 'nbExt' field */static char *nbDoc = "{} {Gets the number of extrema at the same scale as this extremum.}";static void * GetNbExtExtV(VALUE val, void **arg){  EXT ext;    /* Documentation */  if (val == NULL) return(nbDoc);    ext = (EXT) val;    if (ext->extlis == NULL) return(GetIntField(0,arg));  return(GetIntField(ext->extlis->size,arg));}/* * 'z' field */static char *zDoc = "{[= <wtValue>]} {Sets/Gets the wavelet transform value at the extremum.}";static void * GetZExtV(VALUE val, void **arg){  /* Documentation */  if (val == NULL) return(zDoc);    return(GetFloatField(((EXT) val)->ordinate,arg));}static void * SetZExtV(VALUE val, void **arg){  /* Documentation */  if (val == NULL) return(zDoc);    return(SetFloatField(&(((EXT) val)->ordinate),arg,0));}/* * 'y' field */static char *yDoc = "{} {Gets the scale of an extremum. It is an integer (0 corresponds to the smallest scale).}";static void * GetYExtV(VALUE val, void **arg){  /* Documentation */  if (val == NULL) return(yDoc);    return(GetIntField(((EXT) val)->scale,arg));}/* * 'index' field */static char *indexDoc = "{[= <index>]} {Sets/Gets the position of an extremum using an integer index.}";static void * GetIndexExtV(VALUE val, void **arg){  /* Documentation */  if (val == NULL) return(indexDoc);    return(GetIntField(((EXT) val)->index,arg));}static void * SetIndexExtV(VALUE val, void **arg){  /* Documentation */  if (val == NULL) return(indexDoc);    return(SetIntField(&(((EXT) val)->index),arg,0));}/* * 'x' field */static char *xDoc = "{[= <x>]} {Sets/Gets the abscissa of an extremum.}";static void * GetXExtV(VALUE val, void **arg){  /* Documentation */

⌨️ 快捷键说明

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