Jump to content

Random dynamic_bitset - using Boost library

- - - - -

  • Please log in to reply
3 replies to this topic

#1
samonek11

samonek11

    Newbie

  • Members
  • Pip
  • 4 posts
Hello

I want to write function that initialize dynamic_bitset with radom bits.

Can sombody help me ?

#2
samonek11

samonek11

    Newbie

  • Members
  • Pip
  • 4 posts
I write such code but it;s very slow:

void Chromosom::makeRandom()
{
  bool r = 0;
  for( int i = 0 ;i < chromSet.size() ;i++ )
  {
		r = rand() % 2;
		if (r)
		   chromSet[i] = 1;
		else
		   chromSet[i] = 0;
  }
}


#3
samonek11

samonek11

    Newbie

  • Members
  • Pip
  • 4 posts
Where:

boost::dynamic_bitset<> chromSet;

#4
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
Here and here are some answers.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users