-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataGen.cpp
76 lines (68 loc) · 1.72 KB
/
dataGen.cpp
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
/*
* File: dataGen.cpp
* Author: zhakov
*
* Created on 5 Декабрь 2012 г., 19:55
*/
#include "dataGen.h"
#include "ctime"
#include "cstdlib"
dataGen::dataGen() {
}
dataGen::dataGen(const dataGen& orig) {
}
dataGen::~dataGen() {
}
/**
* Function for simple initialization of the matrix and the vector elements
* @param pMatrix
* @param pVector
* @param Size
* @return
*/
int dataGen::dummyDataInitialization(double** pMatrix, double* pVector, int Size) {
int i, j; // Loop variables Отформатировано: русский
for (i = 0; i < Size; i++) {
pVector[i] = i + 1;
// for (j = 0; j < Size; j++) {
// if (j <= i) {
// pMatrix[i][j] = 1;
// } else {
// pMatrix[i][j] = 0;
// }
// }
for (j = 0; j < Size; j++) {
if (j == i) {
pMatrix[i][j] = (double) rand() / RAND_MAX * 1000;
} else {
pMatrix[i][j] = 0;
}
}
}
return 0;
}
/**
* Function for random initialization of the matrix and the vector elements
*
* @param pMatrix
* @param pVector
* @param Size
* @return
*/
int dataGen::randomDataInitialization(double** pMatrix, double* pVector, int Size) {
int i, j; // Loop variables
srand(unsigned(clock()));
for (i = 0; i < Size; i++) {
pVector[i] = rand() / double(1000);
for (j = 0; j < Size; j++) {
pMatrix[i][j] = pMatrix[j][i] = rand() / double(1000);
}
// for (j = 0; j < Size; j++) {
// if (j <= i)
// pMatrix[i][j] = rand() / double(1000);
// else
// pMatrix[i][j] = 0;
// }
}
return 0;
}