Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

RandomCombination Class Reference

#include <newran.h>

Inheritance diagram for RandomCombination:

Inheritance graph
[legend]
Collaboration diagram for RandomCombination:

Collaboration graph
[legend]

Public Member Functions

void Next (int N, int M, int p[], int start=0)
void Next (int N, int p[], int start=0)

Private Member Functions

void SortAscending (int n, int gm[])

Member Function Documentation

void RandomCombination::Next int  N,
int  p[],
int  start = 0
[inline]
 

Reimplemented from RandomPermutation.

Definition at line 668 of file newran.h.

00668 { Next(N, N, p, start); }

void RandomCombination::Next int  N,
int  M,
int  p[],
int  start = 0
[inline]
 

Reimplemented from RandomPermutation.

Definition at line 666 of file newran.h.

References Ars::Graf::M, RandomPermutation::Next(), and SortAscending().

Referenced by test4().

00667       { RandomPermutation::Next(N, M, p, start); SortAscending(M, p); }

void RandomCombination::SortAscending int  n,
int  gm[]
[private]
 

Definition at line 944 of file newran.cpp.

00945 {
00946    // from numerical recipies in C - Shell sort
00947 
00948    const double aln2i = 1.442695022; const double tiny = 1.0e-5;
00949    int m = n; int lognb2 = (int)(aln2i * log((double)n) + tiny);
00950    while (lognb2--)
00951    {
00952       m >>= 1;
00953       for (int j = m; j<n; j++)
00954       {
00955          int* gmj = gm+j; int i = j-m; int* gmi = gmj-m; int t = *gmj;
00956          while (i>=0 && *gmi>t)  { *gmj = *gmi; gmj = gmi; gmi -= m; i -= m; }
00957          *gmj = t;
00958       }
00959    }
00960 }


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 04:06:34 2003 for Borqueror by doxygen 1.3.3