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

📄 bigraphdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 5 页
字号:
// file: $isip/class/dstr/BiGraph/BiGraphDiagnose.h// version: $Id: BiGraphDiagnose.h,v 1.9 2003/05/08 18:39:49 parihar Exp $//// make sure definitions are only made once//#ifndef ISIP_BI_GRAPH_DIAGNOSE#define ISIP_BI_GRAPH_DIAGNOSE// isip include files//#ifndef ISIP_BI_GRAPH#include "BiGraph.h"#endif#ifndef ISIP_DI_GRAPH#include "DiGraph.h"#endif#ifndef ISIP_FILENAME#include <Filename.h>#endif// BiGraphDiagnose: a class that contains the diagnose method of BiGraph class.//template<class TObject>class BiGraphDiagnose : public BiGraph<TObject> {  //---------------------------------------------------------------------------  //  // public constants  //  //---------------------------------------------------------------------------public:    // define the class name  //  //----------------------------------------  //  // i/o related constants  //  //----------------------------------------      //----------------------------------------  //  // default values and arguments  //  //----------------------------------------  // default values  //      // default arguments to methods  //    //----------------------------------------  //  // error codes  //  //----------------------------------------      //---------------------------------------------------------------------------  //  // protected data  //  //---------------------------------------------------------------------------protected:  // define the object used to hold graph topology in read and write  //  typedef Triple< Pair<Long, Long>, Float, Boolean> TopoTriple;    //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:  // methods: name  //  static const String& name() {    return BiGraph<TObject>::name();  }  // other static methods  //  static boolean diagnose(Integral::DEBUG debug_level);  // debug methods  //  these methods are omitted since this class does not have data  //  members and operations    //    // destructor/constructor(s):  //  these methods are omitted since this class does not have data  //  members and operations  //  // assign methods:  //  these methods are omitted since this class does not have data  //  members and operations  //  // operator= methods:  //  these methods are omitted since this class does not have data  //  members and operations  //    // i/o methods:  //  these methods are omitted since this class does not have data  //  members and operations  //  // equality methods:  //  these methods are omitted since this class does not have data  //  members and operations  //  // memory-management methods:  //  these methods are omitted since this class does not have data  //  members and operations  //    //---------------------------------------------------------------------------  //  // class-specific public methods  //  //---------------------------------------------------------------------------  //  these methods are omitted since this class does not have data  //  members and operations  //    //---------------------------------------------------------------------------  //  // private methods  //  //---------------------------------------------------------------------------private:}; // below are all the methods for the PairDiagnose template class////-----------------------------------------------------------------------------//// required static methods////-----------------------------------------------------------------------------// method: diagnose//// arguments://  Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//template<class TObject>boolean BiGraphDiagnose<TObject>::diagnose(Integral::DEBUG level_a) {  //----------------------------------------------------------------------  //  // 0. preliminaries  //  //----------------------------------------------------------------------  // output the class name  //  if (level_a > Integral::NONE) {    SysString output(L"diagnosing class ");    output.concat(CLASS_NAME);    output.concat(L": ");    Console::put(output);    Console::increaseIndention();  }  //---------------------------------------------------------------------  //  // 1. required public methods  //  //---------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing required public methods...\n");    Console::increaseIndention();  }  // test the debug methods  //  setDebug(debug_level_d);    // test constructors and memory management methods  //  BiGraph<Char> def_graph;  // create an arc from the first to the last node  //  def_graph.insertArc(def_graph.getStart(), def_graph.getTerm(), false, 0.75);  // copy constructor  //  BiGraph<Char> copy_graph(def_graph);  // the copy graph should now have an arc from its start node to its terminal  // node with a weight of 0.75  //  BiGraphArc<Char>* cstr_arc = (BiGraphArc<Char>*)NULL;  if ((cstr_arc = copy_graph.getStart()->getFirstChild()) ==       (BiGraphArc<Char>*)NULL) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex() != copy_graph.getTerm()) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  // the copy graph should also have an arc from its term node to its start  // node with a weight of 0.75  //  cstr_arc = (BiGraphArc<Char>*)NULL;  if ((cstr_arc = copy_graph.getTerm()->getFirstParent()) ==       (BiGraphArc<Char>*)NULL) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex() != copy_graph.getStart()) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }    // check the constructors and destructors for allocating on the dynamic  // memory heap  //  BiGraph<Char>* def_dyn_graph = new BiGraph<Char>;  // create an arc from the first to the last node  //  def_dyn_graph->insertArc(def_dyn_graph->getStart(), def_dyn_graph->getTerm(),			false, 0.75);  // copy constructor  //  BiGraph<Char>* copy_dyn_graph = new BiGraph<Char>(*def_dyn_graph);  // the copy graph should now have an arc from its start node to its terminal  // node with a weight of 0.75  //  cstr_arc = (BiGraphArc<Char>*)NULL;  if ((cstr_arc = copy_dyn_graph->getStart()->getFirstChild())      == (BiGraphArc<Char>*)NULL) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex() != copy_dyn_graph->getTerm()) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  // the copy graph should also have an arc from its term node to its start  // node with a weight of 0.75  //  cstr_arc = (BiGraphArc<Char>*)NULL;  if ((cstr_arc = copy_dyn_graph->getTerm()->getFirstParent())      == (BiGraphArc<Char>*)NULL) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex() != copy_dyn_graph->getStart()) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }    // clear the respective graphs  //  ((BiGraph<TObject>)copy_graph).clear(Integral::FREE);  ((BiGraph<TObject>*)def_dyn_graph)->clear(Integral::FREE);  def_graph.clear(Integral::FREE);  copy_dyn_graph->clear(Integral::FREE);    // see if we can dynamically delete  //  delete def_dyn_graph;  delete copy_dyn_graph;  {    // test constructors and memory management methods in USER-allocation    //    BiGraph<Char> def_graph(USER);        // create an arc from the first to the last node    //    def_graph.insertArc(def_graph.getStart(), def_graph.getTerm(),			false, 0.75);        // copy constructor    //    BiGraph<Char> copy_graph(def_graph);        // the copy graph should now have an arc from its start node to its    // terminal node with a weight of 0.75    //    BiGraphArc<Char>* cstr_arc = (BiGraphArc<Char>*)NULL;    if ((cstr_arc = copy_graph.getStart()->getFirstChild()) == 	(BiGraphArc<Char>*)NULL) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }    if ((cstr_arc->getVertex() != copy_graph.getTerm()) ||	cstr_arc->getEpsilon() ||	!Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }    // the copy graph should also have an arc from its term node to its    // start node with a weight of 0.75    //    cstr_arc = (BiGraphArc<Char>*)NULL;    if ((cstr_arc = copy_graph.getTerm()->getFirstParent()) == 	(BiGraphArc<Char>*)NULL) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }    if ((cstr_arc->getVertex() != copy_graph.getStart()) ||	cstr_arc->getEpsilon() ||	!Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }            // check the constructors and destructors for allocating on the dynamic    // memory heap in USER-allocation mode    //    BiGraph<Char>* def_dyn_graph = new BiGraph<Char>(USER);        // create an arc from the first to the last node    //    def_dyn_graph->insertArc(def_dyn_graph->getStart(),			     def_dyn_graph->getTerm(), false, 0.75);        // copy constructor    //    BiGraph<Char>* copy_dyn_graph = new BiGraph<Char>(*def_dyn_graph);        // the copy graph should now have an arc from its start node to its    // terminal node with a weight of 0.75    //    cstr_arc = (BiGraphArc<Char>*)NULL;    if ((cstr_arc = copy_dyn_graph->getStart()->getFirstChild())	== (BiGraphArc<Char>*)NULL) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }    if ((cstr_arc->getVertex() != copy_dyn_graph->getTerm()) ||	cstr_arc->getEpsilon() ||	!Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }    // the copy graph should also have an arc from its term node to its    // start node with a weight of 0.75    //    cstr_arc = (BiGraphArc<Char>*)NULL;    if ((cstr_arc = copy_dyn_graph->getTerm()->getFirstParent())	== (BiGraphArc<Char>*)NULL) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }    if ((cstr_arc->getVertex() != copy_dyn_graph->getStart()) ||	cstr_arc->getEpsilon() ||	!Integral::almostEqual((double)cstr_arc->getWeight(), 0.75)) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }        // clear the respective graphs    //    copy_graph.clear(Integral::FREE);    def_dyn_graph->clear(Integral::FREE);    def_graph.clear(Integral::FREE);    copy_dyn_graph->clear(Integral::FREE);        // see if we can dynamically delete    //    delete def_dyn_graph;    delete copy_dyn_graph;      }  // test large allocation construction and deletion in both modes  //  if (level_a >= Integral::ALL) {    // output an informative message    //    Console::put(L"\ntesting large chunk memory allocation and deletion:\n");        // set the memory to a strange block size so we can hopefully catch any    // frame overrun errors    //    BiGraph<TObject>::setGrowSize((long)731);        // loop for a large number of times creating and deleting a large number    // of vertices at each loop    //    for (long j = 1; j <= 100; j++) {      BiGraph<TObject>** self_graphs = new BiGraph<TObject>*[j * 50];      BiGraph<TObject>** graphs = new BiGraph<TObject>*[j * 50];            // create the vertices      //      for (long i = 0; i < j * 50; i++) {	self_graphs[i] = new BiGraph<TObject>();	graphs[i] = new BiGraph<TObject>(USER);      }            // delete nodes      //      for (long i = (j * 50) - 1; i >= 0; i--) {	delete self_graphs[i];	delete graphs[i];      }            delete [] self_graphs;      delete [] graphs;    }

⌨️ 快捷键说明

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