SLIKMC
1.0
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Pages
Utility.h
1
/*
2
* Utility.h
3
*
4
* Created on: Jul 11, 2012
5
* Author: Yajia
6
*/
7
8
#ifndef UTILITY_H_
9
#define UTILITY_H_
10
11
#include <string.h>
12
#include <vector.h>
13
using namespace
std;
14
15
#define PI 3.14159265
16
20
class
Utility
{
21
public
:
22
23
// static void print_Double2D( int m, int n, double** values, int start = 0, string name = "");
24
35
static
void
matrix_multiply_trash(
int
m,
int
n,
int
p,
double
** val1,
double
** val2,
double
** res,
double
cov = 1);
36
37
static
void
matrix_square_transposeA(
int
m,
int
n,
double
** A,
double
** res);
38
39
static
double
** new_Double2D(
int
m,
int
n);
40
41
static
void
delete_Double2D(
double
** values,
int
m);
42
43
static
void
setZero_Double2D(
int
m,
int
n,
double
** values);
44
45
// static void print_vector( vector<double>& v, string delim = " ");
46
47
// static void record_vector( vector<double>& v, string filename, string delim = "\n");
48
49
// static string itoa( const int& i);
50
51
static
double
dist(
const
vector<double>& a,
const
vector<double>& b,
const
int
minsize);
52
53
};
54
58
class
StringTokenizer
{
59
public
:
65
StringTokenizer
(
string
s,
string
delims =
"\t\n "
);
66
71
string
nextToken();
72
77
bool
hasMoreTokens()
const
;
78
83
void
getAllTokens( vector<string>& tokens);
84
private
:
85
string
s;
86
vector<char> delims;
87
int
index;
88
};
89
90
class
String
{
91
public
:
92
static
string
toUpper(
const
string
&);
93
static
string
toLower(
const
string
&);
94
};
95
96
97
class
Debug
{
98
public
:
99
static
void
check(
const
bool
assertion,
string
comment);
100
};
101
105
class
Random
106
{
107
public
:
113
static
int
nextInt(
const
int
r);
114
121
static
int
nextInt(
const
int
r1,
const
int
r2);
122
128
static
double
nextDouble(
const
double
range);
129
136
static
double
nextDouble(
const
double
r1,
const
double
r2);
137
142
static
double
nextNormal();
143
150
static
double
nextNormal(
const
double
mean,
const
double
std);
151
};
152
153
157
class
BinarySearch
{
158
public
:
162
static
int
search(
const
vector<double>& dataset,
const
double
& v);
163
private
:
164
168
static
int
search(
const
vector<double>& dataset,
const
double
& v,
const
int
s,
const
int
e);
169
};
170
171
#endif
/* UTILITY_H_ */
Generated on Thu May 2 2013 04:05:35 for SLIKMC by
1.8.3.1-20130209