-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomizations.cpp
More file actions
51 lines (39 loc) · 887 Bytes
/
randomizations.cpp
File metadata and controls
51 lines (39 loc) · 887 Bytes
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
//
//
#include "Randomizations.h"
#include <iomanip>
//#include "fortify.h"
void Randomizations::Randomize(simplmat<double>& data,simplmat<double>& rdata)
{
int dimX = data.getRows();
int dimY = data.getCols();
rdata.resize(dimX,dimY);
int max = dimX*dimY;
int x,y,p=0;
randomizePosXY * pos = new randomizePosXY[max];
for(x=0; x<dimX; x++)
for(y=0; y<dimY; y++)
{
pos[p].x=x;
pos[p].y=y;
p++;
}
random_shuffle(pos, pos + max, rnd);
// JumbleXY(pos, max);
p=0;
for(x=0; x<dimX; x++)
for(y=0; y<dimY; y++)
{
int px = pos[p].x;
int py = pos[p].y;
rdata(x,y) = data(px,py);
p++;
}
delete []pos;
}
void Randomizations::Randomize(simplmat<double>& data)
{
double * pdata = data.pointer();
int max = data.getRows()*data.getCols();
random_shuffle(pdata, pdata + max, rnd);
}