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#define DESCMULT 100
104#define BIGNUM 10000
105
106
107
108 Int descpos, ExtraColBlock, ExtraRowBlock, icpos, ixpos,
109 jxpos, MyColBlock, MyColDist, MyRowBlock, MyRowDist,
110 NColBlock, np, npos, nq, NRowBlock;
111
112
113
115
116
117
118 if( *info >= 0 )
121 *info = -(*info);
122 else
124
125
126
127
133
134
135
137
138
139
140 if( n < 0 )
141 *info =
MIN( *info, npos );
142 else if( ix < 1 )
143 *info =
MIN( *info, ixpos );
144 else if( jx < 1 )
145 *info =
MIN( *info, jxpos );
146 else if( desc_X[
MB_] < 1 )
147 *info =
MIN( *info, descpos +
MB_ );
148 else if( desc_X[
NB_] < 1 )
149 *info =
MIN( *info, descpos +
NB_ );
150 else if( ( desc_X[
RSRC_] < 0 ) || ( desc_X[
RSRC_] >= nprow ) )
151 *info =
MIN( *info, descpos +
RSRC_ );
152 else if( ( desc_X[
CSRC_] < 0 ) || ( desc_X[
CSRC_] >= npcol ) )
153 *info =
MIN( *info, descpos +
CSRC_ );
154 else if( incx != 1 && incx != desc_X[
M_] )
155 *info =
MIN( *info, icpos );
156 else if( desc_X[
LLD_] < 1 )
157 *info =
MIN( *info, descpos +
LLD_ );
158
159 if( n == 0 )
160 {
161
162
163
165 *info =
MIN( *info, descpos +
M_ );
167 *info =
MIN( *info, descpos +
N_ );
168 }
169 else
170 {
171
172
173
175 *info =
MIN( *info, descpos +
M_ );
176 else if( desc_X[
N_] < 1 )
177 *info =
MIN( *info, descpos +
N_ );
178 else if( ( incx == desc_X[
M_] ) && ( jx+n-1 > desc_X[
N_] ) )
179 *info =
MIN( *info, jxpos );
180 else if( ( incx == 1 ) && ( incx != desc_X[
M_] ) &&
181 ( ix+n-1 > desc_X[
M_] ) )
182 *info =
MIN( *info, ixpos );
183 else
184 {
185 if( ix > desc_X[
M_] )
186 *info =
MIN( *info, ixpos );
187 else if( jx > desc_X[
N_] )
188 *info =
MIN( *info, jxpos );
189 }
190 }
191
192
193
194
195
197 {
198 MyRowDist = ( myrow + nprow - desc_X[
RSRC_] ) % nprow;
199 MyColDist = ( mycol + npcol - desc_X[
CSRC_] ) % npcol;
200 NRowBlock = desc_X[
M_] / desc_X[
MB_];
201 NColBlock = desc_X[
N_] / desc_X[
NB_];
202 np = ( NRowBlock / nprow ) * desc_X[
MB_];
203 nq = ( NColBlock / npcol ) * desc_X[
NB_];
204 ExtraRowBlock = NRowBlock % nprow;
205 ExtraColBlock = NColBlock % npcol;
206
207 ix--;
208 jx--;
209 MyRowBlock = ix / desc_X[
MB_];
210 MyColBlock = jx / desc_X[
NB_];
211 *ixrow = ( MyRowBlock + desc_X[
RSRC_] ) % nprow;
212 *ixcol = ( MyColBlock + desc_X[
CSRC_] ) % npcol;
213
214 *iix = ( MyRowBlock / nprow + 1 ) * desc_X[
MB_] + 1;
215 *jjx = ( MyColBlock / npcol + 1 ) * desc_X[
NB_] + 1;
216
217 if( MyRowDist >= ( MyRowBlock % nprow ) )
218 {
219 if( myrow == *ixrow )
220 *iix += ix % desc_X[
MB_];
222 }
223 if( MyRowDist < ExtraRowBlock )
225 else if( MyRowDist == ExtraRowBlock )
226 np += ( desc_X[
M_] % desc_X[
MB_] );
228
229 if( MyColDist >= ( MyColBlock % npcol ) )
230 {
231 if( mycol == *ixcol )
232 *jjx += jx % desc_X[
NB_];
234 }
235 if( MyColDist < ExtraColBlock )
237 else if( MyColDist == ExtraColBlock )
238 nq += ( desc_X[
N_] % desc_X[
NB_] );
240
241 *iix =
MIN( *iix, np );
242 *jjx =
MIN( *jjx, nq );
243
244 if( desc_X[
LLD_] < np )
245 {
246 if( numroc_(&desc_X[
N_], &desc_X[
NB_], &mycol, &desc_X[
CSRC_], &npcol) )
247 *info = -( descpos +
LLD_ );
248 else *info = 0;
249 }
250 else *info = 0;
251 }
253 {
255 }
256 else
257 {
258 *info = -(*info);
259 }
260}