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

📄 ugraphdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 3 页
字号:
// file: $isip/class/dstr/UGraph/UGraph.h// version: $Id: UGraphDiagnose.h,v 1.1 2001/01/17 17:46:59 alphonso Exp $//// make sure definitions are only made once//#ifndef ISIP_U_GRAPH_DIAGNOSE#define ISIP_U_GRAPH_DIAGNOSE// isip include files//#ifndef ISIP_U_GRAPH#include "UGraph.h"#endif// UGraphDiagnose: a class that contains the diagnose method of UGraph class.//template<class TObject>class UGraphDiagnose : public UGraph<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:  //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:  // methods: name  //  static const String& name() {    return UGraph<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 UGraphDiagnose<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  //  UGraph<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  //  UGraph<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  //  GraphArc<Char>* cstr_arc = (GraphArc<Char>*)NULL;  if ((cstr_arc = copy_graph.getStart()->getFirst()) ==      (GraphArc<Char>*)NULL) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex() != copy_graph.getTerm()) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual(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  //  UGraph<Char>* def_dyn_graph = new UGraph<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  //  UGraph<Char>* copy_dyn_graph = new UGraph<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 = (GraphArc<Char>*)NULL;  if ((cstr_arc = copy_dyn_graph->getStart()->getFirst())      == (GraphArc<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(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 constructors and memory management methods in USER-allocation    //    UGraph<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    //    UGraph<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    //    GraphArc<Char>* cstr_arc = (GraphArc<Char>*)NULL;    if ((cstr_arc = copy_graph.getStart()->getFirst()) ==	(GraphArc<Char>*)NULL) {      return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			   __LINE__);    }    if ((cstr_arc->getVertex() != copy_graph.getTerm()) ||	cstr_arc->getEpsilon() ||	!Integral::almostEqual(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    //    UGraph<Char>* def_dyn_graph = new UGraph<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    //    UGraph<Char>* copy_dyn_graph = new UGraph<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 = (GraphArc<Char>*)NULL;    if ((cstr_arc = copy_dyn_graph->getStart()->getFirst())	== (GraphArc<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(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    //    UGraph<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++) {      UGraph<TObject>** self_graphs = new UGraph<TObject>*[j * 50];      UGraph<TObject>** graphs = new UGraph<TObject>*[j * 50];            // create the vertices      //      for (long i = 0; i < j * 50; i++) {	self_graphs[i] = new UGraph<TObject>();	graphs[i] = new UGraph<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;    }    // perform the same test using the new[] and delete [] operators    //    for (long j = 1; j <= 100; j++) {            // allocate a large number of nodes      //      UGraph<TObject>* self_graphs = new UGraph<TObject>[j * 50];      UGraph<TObject>* graphs = new UGraph<TObject>[j * 50](USER);      // clean up memory      //      delete [] self_graphs;      delete [] graphs;    }  }  // test assign method in SYSTEM-allocation mode  //  UGraph<Char> assn_graph_0;  // create an arc from the first to a common node  //  Char* char1 = new Char('k');  assn_graph_0.insertArc(assn_graph_0.getStart(),			 assn_graph_0.insertVertex(char1),			 false, 0.75);  GraphVertex<Char>* tmp_vertex;  if ((tmp_vertex = assn_graph_0.getFirst()) == (GraphVertex<Char>*)NULL) {    return Error::handle(name(), L"insertArc", Error::TEST, __FILE__,			 __LINE__);  }  assn_graph_0.insertArc(tmp_vertex, assn_graph_0.getTerm(),			 false, -0.75);  UGraph<Char> assn_graph_1;  assn_graph_1.assign(assn_graph_0);    // the assigned graph should now have an arc from its start node to the  // char1 with a weight of 0.75 and an arc from the char1 to the terminal  // node with a weight of -0.75  //  cstr_arc = (GraphArc<Char>*)NULL;  if ((cstr_arc = assn_graph_1.getStart()->getFirst())      == (GraphArc<Char>*)NULL) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex()->getItem()->ne(*char1)) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual(cstr_arc->getWeight(), 0.75)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }  assn_graph_1.gotoFirst();  assn_graph_1.getCurr()->gotoFirst();  if ((cstr_arc = assn_graph_1.getCurr()->getCurr())      == (GraphArc<Char>*)NULL) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex() != assn_graph_1.getStart()) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual(cstr_arc->getWeight(), 0.75)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc = assn_graph_1.getCurr()->getNext())      == (GraphArc<Char>*)NULL) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex() != assn_graph_1.getTerm()) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual(cstr_arc->getWeight(), -0.75)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }    if ((cstr_arc = assn_graph_1.getTerm()->getFirst())      == (GraphArc<Char>*)NULL) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }  if ((cstr_arc->getVertex()->getItem()->ne(*char1)) ||      cstr_arc->getEpsilon() ||      !Integral::almostEqual(cstr_arc->getWeight(), -0.75)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__,			 __LINE__);  }    // clean up memory  //  delete char1;  {    // test assign method in USER-allocation mode    //    UGraph<Char> assn_graph_0(USER);        // create an arc from the first to a common node    //    Char* char1 = new Char('k');    assn_graph_0.insertArc(assn_graph_0.getStart(),			   assn_graph_0.insertVertex(char1),			   false, 0.75);        GraphVertex<Char>* tmp_vertex;    if ((tmp_vertex = assn_graph_0.getFirst()) == (GraphVertex<Char>*)NULL) {      return Error::handle(name(), L"insertArc", Error::TEST, __FILE__,			   __LINE__);    }    assn_graph_0.insertArc(tmp_vertex, assn_graph_0.getTerm(),

⌨️ 快捷键说明

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