MIDAPACK - MIcrowave Data Analysis PACKage
1.1b
Parallel software tools for high performance CMB DA analysis
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Groups
Pages
als.c
Go to the documentation of this file.
1
9
#include <stdlib.h>
10
17
int
card
(
int
*A,
int
nA){
18
int
i;
19
int
tmp=A[0];
20
int
c=1;
21
for
(i=1; i<nA; i++){
22
if
(A[i] != tmp){
23
c++;
24
tmp=A[i];
25
}
26
}
27
return
c;
28
}
29
30
39
void
merge
(
int
*A,
int
nA,
int
*B){
40
int
i=0, j=0;
41
B[0]=A[0];
42
for
(i=1; i<nA; i++){
43
if
(A[i] != B[j]){
44
j++;
45
B[j]=A[i];
46
}
47
}
48
}
49
50
60
int
card_or
(
int
*A1,
int
n1,
int
*A2,
int
n2){
61
int
i=0, j=0, k= 0;
62
while
( i<n1 || j<n2){
63
if
(A1[i] < A2[j]){
64
if
(i<n1){ i++; }
65
else
{ j++; }
66
}
67
else
if
(A1[i] > A2[j]){
68
if
(j<n2){ j++; }
69
else
{ i++; }
70
}
71
else
{
72
if
(i<n1){ i++; }
73
if
(j<n2){ j++; }
74
}
75
k++;
76
}
77
return
k;
78
}
79
89
int
card_and
(
int
*A1,
int
n1,
int
*A2,
int
n2){
90
int
i=0, j=0, k= 0;
91
while
( i<n1 && j<n2){
92
if
(A1[i] < A2[j]){
93
i++;
94
}
95
else
if
(A1[i] > A2[j]){
96
j++;
97
}
98
else
{
99
k++;
100
i++;
101
j++;
102
}
103
}
104
return
k;
105
}
106
118
int
set_or
(
int
*A1,
int
n1,
int
*A2,
int
n2,
int
*A1orA2){
119
int
i=0, j=0, k= 0;
120
while
( i<n1 || j<n2){
121
if
(A1[i] < A2[j]){
122
if
(i<n1){
123
A1orA2[k]=A1[i];
124
i++;
125
}
126
else
{
127
A1orA2[k]=A2[j];
128
j++;
129
}
130
}
131
else
if
(A1[i] > A2[j]){
132
if
(j<n2){
133
A1orA2[k]=A2[j];
134
j++;
135
}
136
else
{
137
A1orA2[k]=A1[i];
138
i++;
139
}
140
}
141
else
{
142
A1orA2[k]=A1[i];
143
i++;
144
j++;
145
}
146
k++;
147
}
148
return
k;
149
}
150
162
int
set_and
(
int
*A1,
int
n1,
int
*A2,
int
n2,
int
*A1andA2){
163
int
i=0, j=0, k= 0;
164
while
( i<n1 && j<n2){
165
if
(A1[i] < A2[j]){
166
i++;
167
}
168
else
if
(A1[i] > A2[j]){
169
j++;
170
}
171
else
{
172
A1andA2[k]=A1[i];
173
k++;
174
i++;
175
j++;
176
}
177
}
178
return
k;
179
}
180
188
int
map_and
(
int
*A1,
int
n1,
int
*A2,
int
n2,
int
*mapA1andA2){
189
int
i=0, j=0, k= 0;
190
while
( i<n1 && j<n2){
191
if
(A1[i] < A2[j]){
192
i++;
193
}
194
else
if
(A1[i] > A2[j]){
195
j++;
196
}
197
else
{
198
mapA1andA2[k]=i;
199
k++;
200
i++;
201
j++;
202
}
203
}
204
return
k;
205
}
206
207
217
void
subset2map
(
int
*A,
int
nA,
int
*subA,
int
nsubA){
218
int
i=0, j=0;
219
while
( i<nA && j<nsubA){
220
if
(A[i] < subA[j]){
221
i++;
222
}
223
else
{
224
subA[j]=i;
225
i++;
226
j++;
227
}
228
}
229
}
230
src
mapmat
als.c
Generated on Wed Jul 10 2013 14:51:21 for MIDAPACK - MIcrowave Data Analysis PACKage by
1.8.1.1