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

📄 bigraphdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 5 页
字号:
  arc_01 = ver_00->getNextParent();  if (!arc_01->getVertex()->getItem()->eq(*a)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }  // 'b' should have an epsilon transition to the term vertex and itself  //  assgn_graph.gotoNext();  BiGraphVertex<Char>* ver_01 = (BiGraphVertex<Char>*)assgn_graph.getCurr();  ver_01->gotoFirstChild();  BiGraphArc<Char>* arc_02 = ver_01->getCurrChild();  if (!arc_02->getVertex()->getItem()->eq(*b)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }  BiGraphArc<Char>* arc_03 = ver_01->getNextChild();  if (arc_03->getVertex() != assgn_graph.getTerm()) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }  // 'b' should have an a transition to 'a' and itself  //  ver_01 = (BiGraphVertex<Char>*)assgn_graph.getCurr();  ver_01->gotoFirstParent();  arc_02 = ver_01->getCurrParent();  if (!arc_02->getVertex()->getItem()->eq(*a)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }  arc_03 = ver_01->getNextParent();  if (!arc_03->getVertex()->getItem()->eq(*b)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }    // the term vertex should have a transition to 'b'  //  ver_01 = assgn_graph.getTerm();  ver_01->gotoFirstParent();  arc_02 = ver_01->getCurrParent();  if (!arc_02->getVertex()->getItem()->eq(*b)) {    return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }      // clean up  //  delete a;  delete b;  arcs.clear(Integral::FREE);  dlist.clear(Integral::FREE);  assgn_graph.clear(Integral::FREE);  {    // -------------------------------------------------    // START -(epi) -> a    // a     -(0.1) -> a    // a     -(0.5) -> b    // b     -(0.7) -> b    // b     -(epi) -> TERM     //    // START <-(epi) - a    // a     <-(0.1) - a    // a     <-(0.5) - b    // b     <-(0.7) - b    // b     <-(epi) - TERM       // -------------------------------------------------        // create the graph items    //    Char* a = new Char('a');    Char* b = new Char('b');    TopoTriple* triple;      // create the list of arcs    //    DoubleLinkedList<TopoTriple> arcs;        Float float_00(0.0);    Boolean bool_00(true);    Pair<Long, Long> pair_00(BiGraph<Char>::START_INDEX, 0);    triple = new TopoTriple(pair_00, float_00, bool_00);    arcs.insert(triple);    delete triple;        Float float_01(0.1);    Boolean bool_01(false);    Pair<Long, Long> pair_01(0, 0);    triple = new TopoTriple(pair_01, float_01, bool_01);    arcs.insert(triple);    delete triple;        Float float_02(0.5);    Boolean bool_02(false);    Pair<Long, Long> pair_02(0, 1);    triple = new TopoTriple(pair_02, float_02, bool_02);    arcs.insert(triple);    delete triple;        Float float_03(0.7);    Boolean bool_03(false);    Pair<Long, Long> pair_03(1, 1);    triple = new TopoTriple(pair_03, float_03, bool_03);    arcs.insert(triple);    delete triple;        Float float_04(0.0);    Boolean bool_04(true);    Pair<Long, Long> pair_04(1, BiGraph<Char>::TERM_INDEX);    triple = new TopoTriple(pair_04, float_04, bool_04);    arcs.insert(triple);    delete triple;        // create the list of data elements    //    DoubleLinkedList<Char> dlist;    dlist.insert(a);    dlist.insert(b);          // create the graph using the lists    //    BiGraph<Char> assgn_graph(USER);    assgn_graph.assign(dlist, arcs);        // the graph should contain 'a' and 'b'    //    if (!assgn_graph.contains(a)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    if (!assgn_graph.contains(b)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }          // the start vertex should have an epsilon transition to 'a'    //    assgn_graph.gotoFirst();    if (!assgn_graph.getStart()->getFirstChild()->getVertex()->getItem()->eq(*a)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    // the 'a' vertex should have an epsilon transition to start    //    BiGraphVertex<Char>* ver_test =      assgn_graph.getStart()->getFirstChild()->getVertex();    if (ver_test->getFirstParent()->getVertex() != assgn_graph.getStart()) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }        // 'a' should have a transition to 'b' and itself    //    assgn_graph.gotoFirst();    BiGraphVertex<Char>* ver_00 = (BiGraphVertex<Char>*)assgn_graph.getCurr();    ver_00->gotoFirstChild();    BiGraphArc<Char>* arc_00 = ver_00->getCurrChild();    if (!Integral::almostEqual((double)arc_00->getWeight(), 0.1)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    if (!arc_00->getVertex()->getItem()->eq(*a)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    BiGraphArc<Char>* arc_01 = ver_00->getNextChild();    if (!Integral::almostEqual((double)arc_01->getWeight(), 0.5)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    if (!arc_01->getVertex()->getItem()->eq(*b)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }      // 'a' should have transition to start and itself    //    ver_00->gotoFirstParent();    arc_00 = ver_00->getCurrParent();    if (arc_00->getVertex() != assgn_graph.getStart()) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    arc_01 = ver_00->getNextParent();    if (!Integral::almostEqual((double)arc_01->getWeight(), 0.1)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }        if (!arc_01->getVertex()->getItem()->eq(*a)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }      // 'b' should have an epsilon transition to the term vertex and itself    //    assgn_graph.gotoNext();    BiGraphVertex<Char>* ver_01 = (BiGraphVertex<Char>*)assgn_graph.getCurr();    ver_01->gotoFirstChild();    BiGraphArc<Char>* arc_02 = ver_01->getCurrChild();    if (!Integral::almostEqual((double)arc_02->getWeight(), 0.7)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    if (!arc_02->getVertex()->getItem()->eq(*b)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    BiGraphArc<Char>* arc_03 = ver_01->getNextChild();    if (arc_03->getVertex() != assgn_graph.getTerm()) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    // 'b' should have an a transition to 'a' and itself    //    ver_01 = (BiGraphVertex<Char>*)assgn_graph.getCurr();    ver_01->gotoFirstParent();    arc_02 = ver_01->getCurrParent();    if (!Integral::almostEqual((double)arc_02->getWeight(), 0.5)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }    if (!arc_02->getVertex()->getItem()->eq(*a)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }        arc_03 = ver_01->getNextParent();    if (!Integral::almostEqual((double)arc_03->getWeight(), 0.7)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }        if (!arc_03->getVertex()->getItem()->eq(*b)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }          // the term vertex should have a transition to 'b'    //    ver_01 = assgn_graph.getTerm();    ver_01->gotoFirstParent();    arc_02 = ver_01->getCurrParent();    if (!arc_02->getVertex()->getItem()->eq(*b)) {      return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);    }        // clean up    //    delete a;    delete b;        arcs.clear(Integral::FREE);  }  // testing i/o methods in SYSTEM mode  //  // -------------------------------------------------  // START    -> a   //          -> b  //          -> c  // a        -> d  // a        -> f    // b        -> d  // c        -> g    // c        -> d  // d        -> e  // e        -> f  // e        -> g          // f        -> TERM  // g        -> TERM     // -------------------------------------------------    BiGraph<Char> write_graph;  write_graph.insertArc(write_graph.getStart(), write_graph.getTerm(), true);    Char* chr = new Char(L'a');  BiGraphVertex<Char>* ptr_a = write_graph.insertVertex(chr);  write_graph.insertArc(write_graph.getStart(), ptr_a, true);  delete chr;    chr = new Char(L'b');  BiGraphVertex<Char>* ptr_b = write_graph.insertVertex(chr);  write_graph.insertArc(write_graph.getStart(), ptr_b, true);  delete chr;    chr = new Char(L'c');  BiGraphVertex<Char>* ptr_c = write_graph.insertVertex(chr);  write_graph.insertArc(write_graph.getStart(), ptr_c, true);  delete chr;    chr = new Char(L'd');  BiGraphVertex<Char>* ptr_d = write_graph.insertVertex(chr);  delete chr;    write_graph.insertArc(ptr_a, ptr_d, false, (float)0.7);  write_graph.insertArc(ptr_b, ptr_d, false, (float)0.9);  write_graph.insertArc(ptr_c, ptr_d, false, (float)3.7);  chr = new Char(L'e');  BiGraphVertex<Char>* ptr_e = write_graph.insertVertex(chr);  write_graph.insertArc(ptr_d, ptr_e, false, (float)1.2);  delete chr;    chr = new Char(L'f');  BiGraphVertex<Char>* ptr_f = write_graph.insertVertex(chr);  write_graph.insertArc(ptr_a, ptr_f, false, (float)0.8);  write_graph.insertArc(ptr_e, ptr_f, false, (float)6.1);  delete chr;    chr = new Char(L'g');  BiGraphVertex<Char>* ptr_g = write_graph.insertVertex(chr);   delete chr;    write_graph.insertArc(ptr_c, ptr_g, false, (float)3.1);  write_graph.insertArc(ptr_e, ptr_g, false, (float)1.7);  write_graph.insertArc(ptr_f, write_graph.getTerm(), true);  write_graph.insertArc(ptr_g, write_graph.getTerm(), true);    Filename file_text_00;  Filename file_bin_00;  Integral::makeTemp(file_text_00);  Integral::makeTemp(file_bin_00);  File::registerTemp(file_text_00);  File::registerTemp(file_bin_00);    Sof out_text_00;  Sof out_bin_00;    out_text_00.open(file_text_00, File::WRITE_ONLY, File::TEXT);  out_bin_00.open(file_bin_00, File::WRITE_ONLY, File::BINARY);  write_graph.write(out_text_00, 0);  write_graph.write(out_bin_00, 0);  out_text_00.close();  out_bin_00.close();    Sof in_text_00;  Sof in_bin_00;  BiGraph<Char> read_graph_text_00;  BiGraph<Char> read_graph_bin_00;    in_text_00.open(file_text_00, File::READ_PLUS);  in_bin_00.open(file_bin_00, File::READ_PLUS);    read_graph_text_00.read(in_text_00, 0);  read_graph_bin_00.read(in_bin_00, 0);  in_text_00.close();  in_bin_00.close();    Filename file_text_01;  Filename file_bin_01;  Integral::makeTemp(file_text_01);  Integral::makeTemp(file_bin_01);  File::registerTemp(file_text_01);  File::registerTemp(file_bin_01);    Sof out_text_01;  Sof out_bin_01;  out_text_01.open(file_text_01, File::WRITE_ONLY, File::TEXT);  out_bin_01.open(file_bin_01, File::WRITE_ONLY, File::BINARY);      read_graph_text_00.write(out_text_01, 0);  read_graph_bin_00.write(out_bin_01, 0);  out_text_01.close();  out_bin_01.close();    // test to see if the graphs are equal  //  if (!write_graph.eq(read_graph_text_00)) {    return Error::handle(name(), L"i/o", Error::TEST,			 __FILE__, __LINE__);  }  if (!write_graph.eq(read_graph_bin_00)) {    return Error::handle(name(), L"i/o", Error::TEST,			 __FILE__, __LINE__);  }  Sof in_text_01;  Sof in_bin_01;  BiGraph<Char> read_graph_text_01;  BiGraph<Char> read_graph_bin_01;    in_text_01.open(file_text_01, File::READ_PLUS);  in_bin_01.open(file_bin_01, File::READ_PLUS);    read_graph_text_01.read(in_text_01, 0);  read_graph_bin_01.read(in_bin_01, 0);    // close file descriptors  //  in_text_01.close();  in_bin_01.close();  // test to see if the graphs are equal  //  if (!write_graph.eq(read_graph_text_01)) {    return Error::handle(name(), L"i/o", Error::TEST,			 __FILE__, __LINE__);  }  if (!write_graph.eq(read_graph_bin_01)) {    return Error::handle(name(), L"i/o", Error::TEST,			 __FILE__, __LINE__);  }    // clean up allocated memory  //  write_graph.clear(Integral::FREE);  read_graph_text_00.clear(Integral::FREE);  read_graph_bin_00.clear(Integral::FREE);  read_graph_text_01.clear(Integral::FREE);  read_graph_bin_01.clear(Integral::FREE);    // read in two graph text files with different indeces for the vertices  // but the same structure and compare them for equality in SYSTEM-allocation  //  BiGraph<Char> read_graph_utext_00;  BiGraph<Char> read_graph_utext_01;  BiGraph<Char> read_graph_utext_02;  BiGraph<Char> read_graph_utext_03;    Sof in_utext_00;    String file_utext_00(L"graph.sof");  in_utext_00.open(file_utext_00);  read_graph_utext_00.read(in_utext_00, 0);  read_graph_utext_01.read(in_utext_00, 1);  // the graph that were read in must be equal  //  if (!read_graph_utext_00.eq(read_graph_utext_01)) {    return Error::handle(name(), L"read/eq", Error::TEST,			 __FILE__, __LINE__);  }  // close file descriptors  //  in_utext_00.close();    Sof out_utext_00;  Filename file_utext_01;  Integral::makeTemp(file_utext_01);  File::registerTemp(file_utext_01);   out_utext_00.open(file_utext_01, File::WRITE_ONLY, File::TEXT);  read_graph_utext_00.write(out_utext_00, 0);  read_graph_utext_01.write(out_utext_00, 1);  // close file descriptors  //  out_utext_00.close();  

⌨️ 快捷键说明

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