-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utilities_clara.cpp
120 lines (105 loc) · 2.93 KB
/
Utilities_clara.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
Library of functions for lattice gas simulations and otherwise. C++ implemntations, making them classes.
*/
#include "Utilities.h"
using namespace std;
Utilities::Utilities(){}
fftw_complex** Utilities::twoDAllocatecomplexmatrix(int n1, int n2){
fftw_complex **matrix;
int loopi,loopj;
matrix=(fftw_complex **)malloc(n1*sizeof(fftw_complex*));
for (loopi=0;loopi<n1;loopi++){
matrix[loopi]=(fftw_complex *)malloc(n2*sizeof(fftw_complex));
}
return matrix;
}
double*** Utilities::threeDAllocatedoublematrix(int n1, int n2, int n3){
double ***matrix;
int loopi,loopj,loopk;
matrix=(double ***)malloc(n1*sizeof(double**));
for (loopi=0;loopi<n1;loopi++){
matrix[loopi]=(double **)malloc(n2*sizeof(double*));
for(loopj=0;loopj<n2;loopj++){
matrix[loopi][loopj]=(double *)malloc(n3*sizeof(double));
for(loopk=0;loopk<n3;loopk++){
matrix[loopi][loopj][loopk]=0;
}
}
}
return matrix;
}
double**** Utilities::fourDAllocatedoublematrix(int n1, int n2, int n3,int n4){
double ****matrix;
int loopi,loopj,loopk,loopl;
matrix=(double ****)malloc(n1*sizeof(double***));
for (loopl=0;loopl<n1;loopl++){
matrix[loopl]=(double ***)malloc(n2*sizeof(double**));
for (loopi=0;loopi<n2;loopi++){
matrix[loopl][loopi]=(double **)malloc(n3*sizeof(double*));
for(loopj=0;loopj<n3;loopj++){
matrix[loopl][loopi][loopj]=(double *)malloc(n4*sizeof(double));
for(loopk=0;loopk<n4;loopk++){
matrix[loopl][loopi][loopj][loopk]=0;
}
}
}
}
return matrix;
}
int*** Utilities::threeDAllocateintmatrix(int n1, int n2, int n3){
int ***matrix;
int loopi,loopj,loopk;
matrix=(int ***)malloc(n1*sizeof(int**));
for (loopi=0;loopi<n1;loopi++){
matrix[loopi]=(int **)malloc(n2*sizeof(int*));
for(loopj=0;loopj<n2;loopj++){
matrix[loopi][loopj]=(int *)malloc(n3*sizeof(int));
for(loopk=0;loopk<n3;loopk++){
matrix[loopi][loopj][loopk]=0;
}
}
}
return matrix;
}
int* Utilities::oneDAllocateintmatrix(int n1){
int *matrix;
int loopi,loopj;
matrix=(int *)malloc(n1*sizeof(int));
for (loopi=0;loopi<n1;loopi++){
matrix[loopi]=0;
}
return matrix;
}
double* Utilities::oneDAllocatedoublematrix(int n1){
double *matrix;
int loopi,loopj;
matrix=(double *)malloc(n1*sizeof(double));
for (loopi=0;loopi<n1;loopi++){
matrix[loopi]=0;
}
return matrix;
}
int** Utilities::twoDAllocateintmatrix(int n1, int n2){
int **matrix;
int loopi,loopj;
matrix=(int **)malloc(n1*sizeof(int*));
for (loopi=0;loopi<n1;loopi++){
matrix[loopi]=(int *)malloc(n2*sizeof(int));
for(loopj=0;loopj<n2;loopj++){
matrix[loopi][loopj]=0;
}
}
return matrix;
}
double** Utilities::twoDAllocatedoublematrix(int n1, int n2){
double **matrix;
int loopi,loopj;
matrix=(double **)malloc(n1*sizeof(double*));
for (loopi=0;loopi<n1;loopi++){
matrix[loopi]=(double *)malloc(n2*sizeof(double));
for(loopj=0;loopj<n2;loopj++){
matrix[loopi][loopj]=0;
}
}
return matrix;
}