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

📄 bigraphdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 5 页
字号:
  // read them back  //  Sof in_utext_01;      in_utext_01.open(file_utext_01);    read_graph_utext_02.read(in_utext_01, 0);  read_graph_utext_03.read(in_utext_01, 0);    // the graph that were read in must be equal  //  if (!read_graph_utext_02.eq(read_graph_utext_00)) {    return Error::handle(name(), L"read/eq", Error::TEST,			 __FILE__, __LINE__);  }  if (!read_graph_utext_03.eq(read_graph_utext_01)) {    return Error::handle(name(), L"read/eq", Error::TEST,			 __FILE__, __LINE__);  }      // close file descriptors  //  in_utext_01.close();    {    // read in two graph text files with different indeces for the    // vertices but the same structure and compare them for equality    // in USER-allocation    //    BiGraph<Char> read_graph_utext_00(USER);    BiGraph<Char> read_graph_utext_01(USER);    BiGraph<Char> read_graph_utext_02(USER);    BiGraph<Char> read_graph_utext_03(USER);      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();        // read them back    //    Sof in_utext_01;        in_utext_01.open(file_utext_01);        read_graph_utext_02.read(in_utext_01, 0);    read_graph_utext_03.read(in_utext_01, 0);          // the graph that were read in must be equal    //    if (!read_graph_utext_02.eq(read_graph_utext_00)) {      return Error::handle(name(), L"read/eq", Error::TEST,			   __FILE__, __LINE__);    }    if (!read_graph_utext_03.eq(read_graph_utext_01)) {    return Error::handle(name(), L"read/eq", Error::TEST,			 __FILE__, __LINE__);    }          // close file descriptors    //    in_utext_01.close();    // free allocated memory    //    read_graph_utext_00.clear(Integral::FREE);    read_graph_utext_01.clear(Integral::FREE);    read_graph_utext_02.clear(Integral::FREE);    read_graph_utext_03.clear(Integral::FREE);      }    {    // testing i/o methods in USER mode    //    // -------------------------------------------------    // START    -> a     //          -> b    //          -> c    // a        -> d    // b        -> d    // c        -> d    // d        -> e    // a        -> f    // e        -> f    // c        -> g    // e        -> g            // f        -> TERM    // g        -> TERM       // -------------------------------------------------        BiGraph<Char> write_graph(USER);    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);        chr = new Char(L'b');    BiGraphVertex<Char>* ptr_b = write_graph.insertVertex(chr);    write_graph.insertArc(write_graph.getStart(), ptr_b, true);        chr = new Char(L'c');    BiGraphVertex<Char>* ptr_c = write_graph.insertVertex(chr);    write_graph.insertArc(write_graph.getStart(), ptr_c, true);        chr = new Char(L'd');    BiGraphVertex<Char>* ptr_d = write_graph.insertVertex(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);        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);        chr = new Char(L'g');    BiGraphVertex<Char>* ptr_g = write_graph.insertVertex(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;        Filename file_text_01;    Filename file_bin_01;    Integral::makeTemp(file_text_00);    Integral::makeTemp(file_bin_00);    Integral::makeTemp(file_text_01);    Integral::makeTemp(file_bin_01);    File::registerTemp(file_text_00);    File::registerTemp(file_bin_00);    File::registerTemp(file_text_01);    File::registerTemp(file_bin_01);        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();        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);    }  // test the equality method in SYSTEM-allocated mode  //  // -------------------------------------------------  // START    -> A   // A -(0.3) -> A  //   -(0.3) -> R  //   -(epi) -> B  //   -(epi) -> C  // B -(0.2) -> L  // C -(3.6) -> K  // M -(0.6) -> K  // M -(1.2) -> A  // L -(-0.7)-> R  // L -(0.4) -> C  // S -(-0.2)-> K  // S -(-0.6)-> S  // R        -> TERM  //  // START    <- A   // A <-(0.3) - A  //   <-(0.3) - R  //   <-(epi) - B  //   <-(epi) - C  // B <-(0.2) - L  // C <-(3.6) - K  // M <-(0.6) - K  // M <-(1.2) - A  // L <-(-0.7)- R  // L <-(0.4) - C  // S <-(-0.2)- K  // S <-(-0.6)- S  // R        <- TERM   // -------------------------------------------------    // create the graph items  //  Char* A = new Char('A');  Char* B = new Char('B');  Char* C = new Char('C');  Char* K = new Char('K');  Char* L = new Char('L');  Char* M = new Char('M');  Char* S = new Char('S');    Char* R = new Char('R');  // create the graph  //  BiGraph<Char>* graph_00 = new BiGraph<Char>();    // create the verteices  //  BiGraphVertex<Char>* VA = graph_00->insertVertex(A);  BiGraphVertex<Char>* VB = graph_00->insertVertex(B);  BiGraphVertex<Char>* VC = graph_00->insertVertex(C);      BiGraphVertex<Char>* VK = graph_00->insertVertex(K);  BiGraphVertex<Char>* VL = graph_00->insertVertex(L);  BiGraphVertex<Char>* VM = graph_00->insertVertex(M);      BiGraphVertex<Char>* VS = graph_00->insertVertex(S);  BiGraphVertex<Char>* VR = graph_00->insertVertex(R);  // connect the graph  //  graph_00->insertArc(graph_00->getStart(), VA, true);  graph_00->insertArc(VA, VA, false, 0.3);  graph_00->insertArc(VA, VR, false, 0.3);  graph_00->insertArc(VA, VB, true);  graph_00->insertArc(VA, VC, true);    graph_00->insertArc(VB, VL, false, 0.2);  graph_00->insertArc(VC, VK, false, 3.6);  graph_00->insertArc(VM, VK, false, 0.6);  graph_00->insertArc(VM, VA, false, 1.2);  graph_00->insertArc(VL, VR, false, -0.7);  graph_00->insertArc(VL, VC, false, 0.4);  graph_00->insertArc(VS, VK, false, -0.2);  graph_00->insertArc(VS, VS, false, -0.6);  graph_00->insertArc(VR, graph_00->getTerm(), true);    // create the graph  //  BiGraph<Char>* graph_01 = new BiGraph<Char>(*graph_00);    // create the graph  //  BiGraph<Char>* graph_02 = new BiGraph<Char>();    VA = graph_02->insertVertex(A);  VB = graph_02->insertVertex(B);  VC = graph_02->insertVertex(C);      VK = graph_02->insertVertex(K);  VL = graph_02->insertVertex(L);  VM = graph_02->insertVertex(M);      VS = graph_02->insertVertex(S);  VR = graph_02->insertVertex(R);  // connect the graph  //  graph_02->insertArc(graph_02->getStart(), VA, true);    graph_02->insertArc(VA, VA, false, 0.3);  graph_02->insertArc(VA, VR, false, 0.3);  graph_02->insertArc(VA, VB, true);  graph_02->insertArc(VA, VC, true);    graph_02->insertArc(VB, VL, false, 0.2);  graph_02->insertArc(VC, VK, false, 3.6);  graph_02->insertArc(VM, VK, false, 0.6);  graph_02->insertArc(VM, VA, false, -1.2);  graph_02->insertArc(VL, VR, false, -0.7);  graph_02->insertArc(VL, VC, false, 0.4);  graph_02->insertArc(VS, VK, false, -0.2);  graph_02->insertArc(VS, VS, false, -0.6);      graph_02->insertArc(VR, graph_02->getTerm(), true);    // graph_00 and graph_01 should be equal  //  if (!graph_00->eq(*graph_01)) {    return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);  }  // graph_00 and graph_01 should not be equal  //  if (graph_00->eq(*graph_02)) {    return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);  }    // delete the character objects  //  delete A;  delete B;  delete C;  delete K;  delete L;  delete M;  delete S;  delete R;    // clean up memory  //  graph_00->clear(Integral::FREE);  graph_01->clear(Integral::FREE);  graph_02->clear(Integral::FREE);  delete graph_00;  delete graph_01;  delete graph_02;    {    // test the equality method in USER-allocated mode    //        // -------------------------------------------------    // START    -> A     // A -(0.3) -> A    //   -(0.3) -> R    //   -(epi) -> B    //   -(epi) -> C    // B -(0.2) -> L    // C -(3.6) -> K    // M -(0.6) -> K    // M -(1.2) -> A    // L -(-0.7)-> R    // L -(0.4) -> C    // S -(-0.2)-> K    // S -(-0.6)-> S    // R        -> TERM     // -------------------------------------------------          // create the graph items    //    Char* A = new Char('A');    Char* B = new Char('B');    Char* C = new Char('C');    Char* K = new Char('K');    Char* L = new Char('L');    Char* M = new Char('M');    Char* S = new Char('S');      Char* R = new Char('R');        // create the graph    //    BiGraph<Char>* graph_00 = new BiGraph<Char>(USER);

⌨️ 快捷键说明

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