File: gengraph_header.h

package info (click to toggle)
r-cran-igraph 1.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,984 kB
  • sloc: ansic: 117,319; cpp: 22,287; fortran: 4,551; yacc: 1,150; tcl: 931; lex: 478; makefile: 149; sh: 9
file content (86 lines) | stat: -rw-r--r-- 3,056 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 *
 * gengraph - generation of random simple connected graphs with prescribed
 *            degree sequence
 *
 * Copyright (C) 2006  Fabien Viger
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "gengraph_definitions.h"
#include <cstdlib>
#include <stdio.h>

#include "gengraph_random.h"

namespace gengraph {

static KW_RNG::RNG _my_random;
int my_random() { return _my_random.rand_int31(); }
void my_srandom(int x) { _my_random.init(x,!x*13,x*x+1,(x>>16)+(x<<16)); }
int my_binomial(double pp, int n) { return _my_random.binomial(pp,n); }
double my_random01() { return _my_random.rand_halfopen01(); }

}

#ifdef _WIN32
#include <process.h>
#include <windows.h>
void set_priority_low() {
  HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,TRUE,_getpid());
  SetPriorityClass(hProcess,IDLE_PRIORITY_CLASS);
}
#else
#include <unistd.h>
#endif

namespace gengraph {

static int VERB;
int VERBOSE() { return VERB; }
void SET_VERBOSE(int v) { VERB = v; } 

//Hash profiling
static unsigned long _hash_rm_i   = 0;
static unsigned long _hash_rm_c   = 0;
static unsigned long _hash_add_i  = 0;
static unsigned long _hash_add_c  = 0;
static unsigned long _hash_put_i  = 0;
static unsigned long _hash_put_c  = 0;
static unsigned long _hash_find_i = 0;
static unsigned long _hash_find_c = 0;
static unsigned long _hash_rand_i = 0;
static unsigned long _hash_rand_c = 0;
static unsigned long _hash_expand = 0;
inline void _hash_add_iter()  { _hash_add_i++;  }
inline void _hash_add_call()  { _hash_add_c++;  }
inline void _hash_put_iter()  { _hash_put_i++;  }
inline void _hash_put_call()  { _hash_put_c++;  }
inline void _hash_rm_iter()   { _hash_rm_i++;   }
inline void _hash_rm_call()   { _hash_rm_c++;   }
inline void _hash_find_iter() { _hash_find_i++; }
inline void _hash_find_call() { _hash_find_c++; }
inline void _hash_rand_iter() { _hash_rand_i++; }
inline void _hash_rand_call() { _hash_rand_c++; }
inline void _hash_expand_call() { _hash_expand++; }
// void _hash_prof() {
//   fprintf(stderr,"HASH_ADD : %lu / %lu\n", _hash_add_c , _hash_add_i);
//   fprintf(stderr,"HASH_PUT : %lu / %lu\n", _hash_put_c , _hash_put_i);
//   fprintf(stderr,"HASH_FIND: %lu / %lu\n", _hash_find_c, _hash_find_i);
//   fprintf(stderr,"HASH_RM  : %lu / %lu\n", _hash_rm_c  , _hash_rm_i);
//   fprintf(stderr,"HASH_RAND: %lu / %lu\n", _hash_rand_c, _hash_rand_i);
//   fprintf(stderr,"HASH_EXPAND : %lu calls\n", _hash_expand);
// }

} // namespace gengraph