예제 #1
0
파일: mazerbla.cpp 프로젝트: rfka01/mame
void mazerbla_state::greatgun(machine_config &config)
{
	/* basic machine hardware */
	Z80(config, m_maincpu, MASTER_CLOCK);  /* 4 MHz, no NMI, IM2 - vectors at 0xf8, 0xfa, 0xfc */
	m_maincpu->set_addrmap(AS_PROGRAM, &mazerbla_state::mazerbla_map);
	m_maincpu->set_addrmap(AS_IO, &mazerbla_state::greatgun_io_map);
	m_maincpu->set_irq_acknowledge_callback(FUNC(mazerbla_state::irq_callback));

	Z80(config, m_subcpu, SOUND_CLOCK / 4);   /* 3.579500 MHz, NMI - caused by sound command write, periodic INT */
	m_subcpu->set_addrmap(AS_PROGRAM, &mazerbla_state::greatgun_sound_map);
	m_subcpu->set_periodic_int(FUNC(mazerbla_state::sound_interrupt), attotime::from_hz((double)14318180/16/16/16/16 ));

	z80_device &sub2(Z80(config, "sub2", MASTER_CLOCK)); /* 4 MHz, no  NMI, IM1 INT */
	sub2.set_addrmap(AS_PROGRAM, &mazerbla_state::mazerbla_cpu3_map);
	sub2.set_addrmap(AS_IO, &mazerbla_state::greatgun_cpu3_io_map);
/* (vblank related ??) int generated by a custom video processor
    and cleared on ANY port access.
    but handled differently for now
    */
	sub2.set_vblank_int("screen", FUNC(mazerbla_state::irq0_line_hold));

	MB_VCU(config, m_vcu, SOUND_CLOCK/4);
	m_vcu->set_cpu_tag("sub2");
	m_vcu->set_palette_tag("palette");

	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);

	/* video hardware */
	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	m_screen->set_refresh_hz(60);
	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500) /* not accurate */);
	m_screen->set_size(40*8, 32*8);
	m_screen->set_visarea(0*8, 32*8-1, 0*8, 28*8-1);
	m_screen->set_screen_update(FUNC(mazerbla_state::screen_update_mazerbla));
	m_screen->screen_vblank().set(FUNC(mazerbla_state::screen_vblank));

	PALETTE(config, "palette", FUNC(mazerbla_state::mazerbla_palette), 246+1);

	/* sound hardware */
	SPEAKER(config, "mono").front_center();

	ay8910_device &ay1(AY8910(config, "ay1", SOUND_CLOCK / 8));
	ay1.port_b_read_callback().set(m_soundlatch, FUNC(generic_latch_8_device::read));
	ay1.add_route(ALL_OUTPUTS, "mono", 0.30);

	ay8910_device &ay2(AY8910(config, "ay2", SOUND_CLOCK / 8));
	ay2.port_b_write_callback().set(FUNC(mazerbla_state::gg_led_ctrl_w));
	ay2.add_route(ALL_OUTPUTS, "mono", 1.0);

	GENERIC_LATCH_8(config, m_soundlatch);
	m_soundlatch->data_pending_callback().set_inputline(m_subcpu, INPUT_LINE_NMI);
	m_soundlatch->set_separate_acknowledge(true);
}
예제 #2
0
void WordList::mergeSort(vector<string> &subWordList)
// recursive merge sort
{
	if (subWordList.size() > 1)
	{
		vector<string> sub1(subWordList.begin(), subWordList.begin() + subWordList.size() / 2);
		mergeSort(sub1);
		vector<string> sub2(subWordList.begin() + subWordList.size() / 2, subWordList.end());
		mergeSort(sub2);
		merge(subWordList, sub1, sub2);
	}
}
예제 #3
0
파일: top.cpp 프로젝트: ctessum/fable-go
void
program_prog(
  int argc,
  char const* argv[])
{
  common cmn(argc, argv);
  common_write write(cmn);
  int num = fem::int0;
  sub1(num);
  write(6, star), "num after sub1:", num;
  int n = 1;
  sub2(num, n);
  write(6, star), "num after sub2", num;
  arr_1d<2, int> nums(fem::fill0);
  sub1(nums);
  write(6, star), "nums after sub1:", nums(1), nums(2);
  n = 2;
  sub2(nums, n);
  write(6, star), "nums after sub2:", nums(1), nums(2);
  sub3(nums, n);
  write(6, star), "nums after sub3:", nums(1), nums(2);
}
void
testTortureExecute (void)
{
  if (sub1 (20) != 35)
    ASSERT (0);
  if (sub2 (20) != 45)
    ASSERT (0);
  if (sub3 (20) != -5)
    ASSERT (0);
  if (sub4 (20) != 5)
    ASSERT (0);
  return;
}
예제 #5
0
파일: bf64-1.c 프로젝트: MaxKellermann/gcc
main()
{
  struct tmp tmp = {0x123, 0xFFF000FFF000FLL};
  struct tmp2 tmp2 = {0xFFF000FFF000FLL, 0x123};

  tmp = sub (tmp);
  tmp2 = sub2 (tmp2);

  if (tmp.pad != 0x123 || tmp.field != 0xFFFFFF541FFF567FLL)
    abort ();
  if (tmp2.pad != 0x123 || tmp2.field != 0xFFFFFF541FFF567FLL)
    abort ();
  exit (0);
}
예제 #6
0
파일: 961206-1.c 프로젝트: alpine9000/BitOS
main()
{
    if (sub1 (0x80000000ULL))
        abort ();

    if (sub2 (0x80000000ULL))
        abort ();

    if (sub3 (0x80000000ULL))
        abort ();

    if (sub4 (0x80000000ULL))
        abort ();

    exit (0);
}
void
testTortureExecute (void)
{
#if !defined(__SDCC_ds390) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16)
  if (sub1 (0x80000000ULL))
    ASSERT (0);

  if (sub2 (0x80000000ULL))
    ASSERT (0);

  if (sub3 (0x80000000ULL))
    ASSERT (0);

  if (sub4 (0x80000000ULL))
    ASSERT (0);

  return;
#endif
}
예제 #8
0
파일: mazerbla.cpp 프로젝트: rfka01/mame
void mazerbla_state::mazerbla(machine_config &config)
{
	/* basic machine hardware */
	Z80(config, m_maincpu, MASTER_CLOCK);  /* 4 MHz, no NMI, IM2 - vectors at 0xf8, 0xfa, 0xfc */
	m_maincpu->set_addrmap(AS_PROGRAM, &mazerbla_state::mazerbla_map);
	m_maincpu->set_addrmap(AS_IO, &mazerbla_state::mazerbla_io_map);
	m_maincpu->set_irq_acknowledge_callback(FUNC(mazerbla_state::irq_callback));

	Z80(config, m_subcpu, MASTER_CLOCK);  /* 4 MHz, NMI, IM1 INT */
	m_subcpu->set_addrmap(AS_PROGRAM, &mazerbla_state::mazerbla_cpu2_map);
	m_subcpu->set_addrmap(AS_IO, &mazerbla_state::mazerbla_cpu2_io_map);
	m_subcpu->set_periodic_int(FUNC(mazerbla_state::irq0_line_hold), attotime::from_hz(400)); /* frequency in Hz */

	z80_device &sub2(Z80(config, "sub2", MASTER_CLOCK)); /* 4 MHz, no  NMI, IM1 INT */
	sub2.set_addrmap(AS_PROGRAM, &mazerbla_state::mazerbla_cpu3_map);
	sub2.set_addrmap(AS_IO, &mazerbla_state::mazerbla_cpu3_io_map);
/* (vblank related ??) int generated by a custom video processor
    and cleared on ANY port access.
    but handled differently for now
    */
	sub2.set_vblank_int("screen", FUNC(mazerbla_state::irq0_line_hold));

	/* synchronization forced on the fly */
	MB_VCU(config, m_vcu, SOUND_CLOCK/4);
	m_vcu->set_cpu_tag("sub2");
	m_vcu->set_palette_tag("palette");

	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);

	/* video hardware */
	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	m_screen->set_refresh_hz(60);
	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500) /* not accurate */);
	m_screen->set_size(40*8, 32*8);
	m_screen->set_visarea(0*8, 32*8-1, 0*8, 28*8-1);
	m_screen->set_screen_update(FUNC(mazerbla_state::screen_update_mazerbla));
	m_screen->screen_vblank().set(FUNC(mazerbla_state::screen_vblank));

	PALETTE(config, "palette", FUNC(mazerbla_state::mazerbla_palette), 256+1);

	/* sound hardware */
}
예제 #9
0
void main() {
    debug();
    Describe("RGBAImage<byte>", []() {
        It("should be able to read data from bmp file", []() {
            RGBAImage<byte> image("TestResources/rgbw_2x2.bmp");
            Expect(image.GetPixel(0, 0)).ToBe(RGBAColor<byte>(255, 0, 0, 255));
            Expect(image.GetPixel(1, 0)).ToBe(RGBAColor<byte>(0, 255, 0, 255));
            Expect(image.GetPixel(0, 1)).ToBe(RGBAColor<byte>(0, 0, 255, 255));
            Expect(image.GetPixel(1, 1)).ToBe(RGBAColor<byte>(255, 255, 255, 255));
        });
        Describe("when read lena.bmp finished", []() {
            RGBAImage<byte> image("TestResources/Lena.bmp");
            It("should be able to get width and height", [&image]() {
                Expect(image.Height()).ToBe(512);
                Expect(image.Width()).ToBe(512);
            });
            It("should be able to get pixel", [&image]() {
                Expect(image.GetPixel(0, 0)).ToBe(RGBAColor<byte>(225, 138, 128, 255));
            });
            It("should be able to indexof sub image", [&image]() {
                RGBAImage<byte> sub1("TestResources/IndexOf/sub1.bmp");
                RGBAImage<byte> sub2("TestResources/IndexOf/sub2.bmp");
                RGBAImage<byte> sub3("TestResources/IndexOf/sub3.bmp");
                Expect(image.IndexOf(sub1)).ToBe(Coord<short>(0, 0));
                Expect(image.IndexOf(sub2)).ToBe(Coord<short>(1, 500));
                Expect(image.IndexOf(sub3)).ToBe(Coord<short>(122, 237));
            });
        });
    });
    Benchmark("read lene.bmp", []() {
        RGBAImage<byte> image("TestResources/Lena.bmp");
    });
    Benchmark("indexof lene.bmp", []() {
        RGBAImage<byte> sub3("TestResources/IndexOf/sub3.bmp");
        RGBAImage<byte> image("TestResources/Lena.bmp");
        image.IndexOf(sub3);
    });
}
예제 #10
0
    TEST( NorOp, ElemMatchKey ) {
        BSONObj baseOperand1 = BSON( "a" << 1 );
        BSONObj baseOperand2 = BSON( "b" << 2 );
        auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() );
        ASSERT( sub1->init( "a", ComparisonMatchExpression::EQ, baseOperand1[ "a" ] ).isOK() );
        auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() );
        ASSERT( sub2->init( "b", ComparisonMatchExpression::EQ, baseOperand2[ "b" ] ).isOK() );

        NorMatchExpression norOp;
        norOp.add( sub1.release() );
        norOp.add( sub2.release() );

        MatchDetails details;
        details.requestElemMatchKey();
        ASSERT( !norOp.matches( BSON( "a" << 1 ), &details ) );
        ASSERT( !details.hasElemMatchKey() );
        ASSERT( !norOp.matches( BSON( "a" << BSON_ARRAY( 1 ) << "b" << BSON_ARRAY( 10 ) ),
                                &details ) );
        ASSERT( !details.hasElemMatchKey() );
        ASSERT( norOp.matches( BSON( "a" << BSON_ARRAY( 3 ) << "b" << BSON_ARRAY( 4 ) ),
                               &details ) );
        // The elem match key feature is not implemented for $nor.
        ASSERT( !details.hasElemMatchKey() );
    }
예제 #11
0
    TEST( OrOp, MatchesThreeClauses ) {
        BSONObj baseOperand1 = BSON( "$gt" << 10 );
        BSONObj baseOperand2 = BSON( "$lt" << 0 );
        BSONObj baseOperand3 = BSON( "b" << 100 );
        auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() );
        ASSERT( sub1->init( "a", ComparisonMatchExpression::GT, baseOperand1[ "$gt" ] ).isOK() );
        auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() );
        ASSERT( sub2->init( "a", ComparisonMatchExpression::LT, baseOperand2[ "$lt" ] ).isOK() );
        auto_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() );
        ASSERT( sub3->init( "b", ComparisonMatchExpression::EQ, baseOperand3[ "b" ] ).isOK() );

        OrMatchExpression orOp;
        orOp.add( sub1.release() );
        orOp.add( sub2.release() );
        orOp.add( sub3.release() );

        ASSERT( orOp.matches( BSON( "a" << -1 ), NULL ) );
        ASSERT( orOp.matches( BSON( "a" << 11 ), NULL ) );
        ASSERT( !orOp.matches( BSON( "a" << 5 ), NULL ) );
        ASSERT( orOp.matches( BSON( "b" << 100 ), NULL ) );
        ASSERT( !orOp.matches( BSON( "b" << 101 ), NULL ) );
        ASSERT( !orOp.matches( BSONObj(), NULL ) );
        ASSERT( orOp.matches( BSON( "a" << 11 << "b" << 100 ), NULL ) );
    }
예제 #12
0
    TEST( OrOp, ElemMatchKey ) {
        BSONObj baseOperand1 = BSON( "a" << 1 );
        BSONObj baseOperand2 = BSON( "b" << 2 );
        auto_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() );
        ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() );
        auto_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() );
        ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() );

        OrMatchExpression orOp;
        orOp.add( sub1.release() );
        orOp.add( sub2.release() );

        MatchDetails details;
        details.requestElemMatchKey();
        ASSERT( !orOp.matchesBSON( BSONObj(), &details ) );
        ASSERT( !details.hasElemMatchKey() );
        ASSERT( !orOp.matchesBSON( BSON( "a" << BSON_ARRAY( 10 ) << "b" << BSON_ARRAY( 10 ) ),
                               &details ) );
        ASSERT( !details.hasElemMatchKey() );
        ASSERT( orOp.matchesBSON( BSON( "a" << BSON_ARRAY( 1 ) << "b" << BSON_ARRAY( 1 << 2 ) ),
                              &details ) );
        // The elem match key feature is not implemented for $or.
        ASSERT( !details.hasElemMatchKey() );
    }
예제 #13
0
void main()
{
   time_t t;
   int i;
   char s[35];
   clrscr();

   time(&t);
   strcpy(s,ctime(&t));
//*//
   printf("\nSTD Time:\n\n");
   printf("%s\n",ctime(&t));
//*/

   //TEST Input Section

/*//
   s[11]='2';   s[12]='3';   s[14]='1';   s[15]='0';   s[17]='3';   s[18]='5';

   printf("\nOld:\n");
   printf("%c\t",s[11]);
   printf("%c:\t",s[12]);
   printf("%c\t",s[14]);
   printf("%c:\t",s[15]);
   printf("%c\t",s[17]);
   printf("%c\n",s[18]);
//*/

   //ascii()//0=48:1=49:2=50:3=51:4=52:5=53:6=54:7=55:8=56:9=57

   //Extra Space Intro
   for(i=27;i>=22;i--)
   {
   s[i]=s[i-2];
   s[26]=s[24];
   }

   //Space intro btw am/pm field and yr field
   for(i=27;i>=21;i--)
   {
   s[i]=s[i-1];
   s[21]=' ';
   }

   //default definition as AM
   s[20]='A';
   s[21]='M';

   //---------------------CONVERSION---------------------------
   //conversion of hours field to invert time
   //PM conversion
   if(s[11]==49&&s[12]>=50)
   s[20]='P';
   else if(s[11]==50)
   s[20]='P';


   //Hours conversion//without edge value tapering

   if(s[11]==48&&s[12]<=52)
   {
   s[11]='2';
   s[12]=sub3(s[12]);
   }
   else if(s[11]==48&&s[12]>52&&s[12]<=57)
   {
   s[11]='1';
   s[12]=sub4(s[12]);
   }
   else if(s[11]==49&&s[12]<=52)
   {
   s[12]=sub3(s[12]);
   }
   else if(s[11]==49&&s[12]>52&&s[12]<=57)
   {
   s[11]='0';
   s[12]=sub4(s[12]);
   }
   else if(s[11]==50&&s[12]<=52)
   {
   s[11]='0';
   s[12]=sub3(s[12]);
   }

//*//

   //12 format conversion//without edge value tapering
   //case xx:00:00
   if(s[11]==50&&s[12]==52)
   {
   s[11]='1';
   s[12]='2';
   }
   else if(s[11]==50&&s[12]>=50)
   {

   s[11]='1';
   s[12]=sub5(s[12]);
   }
   else if(s[11]==50&&s[12]>=48&&s[12]<50)
   {
   s[11]='0';
   s[12]=sub6(s[12]);
   }
   else if(s[11]==49&&s[12]>=51&&s[12]<=57)
   {
   s[11]='0';
   s[12]=sub5(s[12]);
   }

/*//
   printf("\n\n12 converted:\n\n");
   printf("%c\t",s[11]);
   printf("%c:\t",s[12]);
   printf("%c\t",s[14]);
   printf("%c:\t",s[15]);
   printf("%c\t",s[17]);
   printf("%c\n",s[18]);
//*/

 //----------------------------------------------------------
   //minutes conversion
   if(s[14]!=48)
   {
   s[15]=sub1(s[15]);
   s[14]=sub2(s[14],s[15]);
   }
   else if(s[14]==48&&s[15]!=48)
   {
   s[14]='5';
   s[15]=sub1(s[15]);
   }

/*//
   printf("\n\nMinutes Converted:\n\n");
   printf("%c\t",s[11]);
   printf("%c:\t",s[12]);
   printf("%c\t",s[14]);
   printf("%c:\t",s[15]);
   printf("%c\t",s[17]);
   printf("%c\n",s[18]);
//*/

/*
   else
   {
   s[15]='5';
   s[14]=sub2(s[14],s[15]);
   }

//*/

   //seconds conversion
   if(s[17]!=48)
   {
   s[18]=sub1(s[18]);
   s[17]=sub2(s[17],s[18]);
   }
   else if(s[17]==48&&s[18]!=48)
   {
   s[17]='5';
   s[18]=sub1(s[18]);
   }

/*//
   printf("\n\nSeconds Converted:\n\n");
   printf("%c\t",s[11]);
   printf("%c:\t",s[12]);
   printf("%c\t",s[14]);
   printf("%c:\t",s[15]);
   printf("%c\t",s[17]);
   printf("%c\n",s[18]);
//*/

   //----------------------------------------------------------
   //edge tapering

   //case xx:xx:00
   if(s[18]==48&&s[17]==48)
   {
    if(!(s[11]==48&&s[12]==48))
     {
      if(s[14]!=48||s[15]!=48)
      {
	if(s[11]==49&&s[12]>48)
	s[12]=sub7(s[12]);
	else if(s[11]==49&&s[12]==48)
	{s[11]='0';s[12]='9';}
	else if(s[11]==48&&s[12]>=49)
	s[12]=sub7(s[12]);
      }
     }
/*//
   printf("\n\nPost tapering case xx:xx:00:\n\n");
   printf("%c\t",s[11]);
   printf("%c:\t",s[12]);
   printf("%c\t",s[14]);
   printf("%c:\t",s[15]);
   printf("%c\t",s[17]);
   printf("%c\n",s[18]);
//*/
   goto output;
   }


   //case xx:00:xx
   if(s[14]==48&&s[15]==48)
   {
    if(s[17]!=48||s[18]!=48)
     {
     s[14]='5';          //printf("\nValue of s[14]:%c",s[14]);
     s[15]='9';     	 //printf("\nValue of s[15]:%c",s[15]);
      ///*
      if(s[11]==49&&s[12]>48)
      s[12]=sub7(s[12]);

      else if(s[11]==49&&s[12]==48)
      {s[11]='0';s[12]='9';}

      else if(s[11]==48&&s[12]>=49)
      s[12]=sub7(s[12]);

     }
/*//
   printf("\n\nPost tapering case xx:00:xx:\n\n");
   printf("%c\t",s[11]);
   printf("%c:\t",s[12]);
   printf("%c\t",s[14]);
   printf("%c:\t",s[15]);
   printf("%c\t",s[17]);
   printf("%c\n",s[18]);
//*/
   goto output;
   }

   //case xx:xx:xx//prev cases excluded
   if(s[17]!=48||s[18]!=48)
   {
    if(s[14]==53)
    {
      s[15]=sub7(s[15]);
      if(s[11]==49&&s[12]>48)
      s[12]=sub7(s[12]);

      else if(s[11]==49&&s[12]==48)
      {s[11]='0';s[12]='9';}

      else if(s[11]==48&&s[12]>=49)
      s[12]=sub7(s[12]);

      if(s[15]==48)
      {
      s[15]='9';
      s[14]=sub7(s[14]);
      }
    }
    else if(s[14]!=53)
    {
     if(s[15]==48)
     {
     s[15]='9';
     s[14]=sub7(s[14]);
     if(s[11]==49&&s[12]>48)
      s[12]=sub7(s[12]);

      else if(s[11]==49&&s[12]==48)
      {s[11]='0';s[12]='9';}

      else if(s[11]==48&&s[12]>=49)
      s[12]=sub7(s[12]);
     }
     else
     {
     s[15]=sub7(s[15]);
     if(s[11]==49&&s[12]>48)
      s[12]=sub7(s[12]);

      else if(s[11]==49&&s[12]==48)
      {s[11]='0';s[12]='9';}

      else if(s[11]==48&&s[12]>=49)
      s[12]=sub7(s[12]);
     }
    }

/*//
    if(s[14]!=48||s[15]!=48)
    {
     s[15]=sub1(s[15]);
     s[15]=sub7(s[15]);
      {
       if(s[11]==49&&s[12]>48)
       s[12]=sub7(s[12]);

       else if(s[11]==49&&s[12]==48)
       {s[11]='0';s[12]='9';}

       else if(s[11]==48&&s[12]>=49&&s[15]!=48)
       {s[12]=sub7(s[12]);}
      }

     if(s[15]==48)
     {
     //s[14]=sub7(s[14]);
     s[15]='9';
     }
    }

    if(s[17]==48)
    {
    s[17]='5';
    s[18]=sub1(s[18]);
    }
//*/
/*//
   printf("\n\nPost tapering case xx:xx:xx:\n\n");
   printf("%c\t",s[11]);
   printf("%c:\t",s[12]);
   printf("%c\t",s[14]);
   printf("%c:\t",s[15]);
   printf("%c\t",s[17]);
   printf("%c\n",s[18]);
//*/
   }

   //----------------OUTPUT Section----------------------------
   output:
   printf("\n\n");
   printf("Invert TIME:\n\n");
   for(i=0;i<=26;i++)
   {
   printf("%c",s[i]);
   }

 getch();
}
예제 #14
0
/*funzione per sostituire vecchie sol con i figli
 riceve vet pop vet figli, row e col (dim matrice gioco)*/
void substitution(population_t *pop,solution_t *offspring,int row, int col){
    sub2(pop,offspring,row,col);
}
예제 #15
0
size_t rewire_sparse_ex(size_t *from, size_t *to,size_t *degree,size_t ncol, size_t nrow,size_t max_iter, size_t e,size_t verbose,size_t MAXITER,unsigned int seed)
{


	set_rand(seed);

 	size_t i,n,rand1,rand2,t=0;
    //copy of the original incidence matrix
	size_t a,b,c,d;
	size_t ad,cb,ac,bd;
	unsigned short *adj;
	size_t *cumdeg;
	do	cumdeg=(size_t *)calloc(nrow,sizeof(size_t)); while(cumdeg==NULL);
    cumdeg[0]=0;
	for(i=1;i<nrow;i++)
		{
			cumdeg[i]=cumdeg[i-1]+degree[i-1]+1;
		}
	adj=(unsigned short *)calloc(cumdeg[nrow-1]+degree[nrow-1]+1,sizeof(unsigned short)); while(adj==NULL);
	for(i=0;i<nrow;i++)
    	adj[cumdeg[i]+degree[i]]= degree[i];
    
	for(i=0;i<e;i++)
		{

			a=from[i];
			b=to[i];
			adj[cumdeg[a]+degree[a]-adj[cumdeg[a]+degree[a]]]=b;
			adj[cumdeg[a]+degree[a]]--;
			adj[cumdeg[b]+degree[b]-adj[cumdeg[b]+degree[b]]]=a;
			adj[cumdeg[b]+degree[b]]--;
    }

  //GetRNGstate();

  time_t  tin,tfin;
	tin = time (NULL);
	for(n=0;n<max_iter;t++)
	{
		if(verbose==1)
			loadBar( n,  max_iter, 100,  50);
		//random rewiring
		   rand1=(size_t) (unif_rand()*e);
        do   rand2=(size_t) (unif_rand()*e); while (rand1==rand2);
        a=from[rand1];
        c=from[rand2];
        b=to[rand1];
        d=to[rand2];

        ad=is_not(a,d,degree,adj,cumdeg);
        cb=is_not(c,b,degree,adj,cumdeg);
        ac=is_not(c,a,degree,adj,cumdeg);
        bd=is_not(b,d,degree,adj,cumdeg);
			if(t>MAXITER)
		{

			tfin = time (NULL);
			if(verbose==1)
		    printf("DONE in %d seconds \n",-(tin-tfin));
		   //PutRNGstate();
			return (-1);




			}
		  // printf("%d %d %d %d %d %d %d %d %d %d \n ",rand1, rand2,a+1,b+1,c+1,d+1,ad,cb,ac,bd);

        if( a!=c && b!=d & a!=d && c!=b && (( ad==1 && cb==1 )|| (ac==1 && bd==1) ))
        {
            if(ad==1 && cb==1 && ac==1 && bd==1 )
            {
                if(unif_rand()>=0.5)
                {

                    to[rand1]=d;
                    to[rand2]=b;
                    sub(a,b,c,d,degree,adj,cumdeg);

                    n++;
                }
                else
                {
                    sub2(a,b,c,d,degree,adj,cumdeg);

                    //	from[rand1]=d;
                    to[rand1]=c;
                    from[rand2]=b;
                    to[rand2]=d;
                               n++;

                }
            }
            else
                if(ad==1 && cb==1 )
                {

                    to[rand1]=d;
                    to[rand2]=b;
                    sub(a,b,c,d,degree,adj,cumdeg);


                    n++;
                }
                else
                {
                    sub2(a,b,c,d,degree,adj,cumdeg);


                    to[rand1]=c;
                    from[rand2]=b;
                    to[rand2]=d;
                    n++;
                }
        }


    }
  tfin = time (NULL);
  if(verbose==1)
 	 printf("DONE in %d seconds \n",-(tin-tfin));
  //PutRNGstate();
	return 0;
}
예제 #16
0
main ()
{
  sub1 ();
  sub2 ();
}
예제 #17
0
int
sub1 (void)
{
  sub2 ();  /* STOP HERE.  */
  return 5;
}