SCM

SCM Repository

[matrix] Annotation of /pkg/src/R_ldl.c
ViewVC logotype

Annotation of /pkg/src/R_ldl.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 369 - (view) (download) (as text)

1 : bates 369 /* This is a modified version of the ldl.c file released by Timothy A. Davis */
2 :     /* in the LDL package and carrying the copyright shown below. The */
3 :     /* modifications are to replace scratch arrays passed as arguments by */
4 :     /* dynamically allocated arrays. */
5 :     /* Douglas Bates (Nov., 2004) */
6 :    
7 :     /* ========================================================================== */
8 :     /* === ldl.c: sparse LDL' factorization and solve package =================== */
9 :     /* ========================================================================== */
10 :    
11 :     /* LDL: a simple set of routines for sparse LDL' factorization. These routines
12 :     * are not terrifically fast (they do not use dense matrix kernels), but the
13 :     * code is very short. The purpose is to illustrate the algorithms in a very
14 :     * concise manner, primarily for educational purposes. Although the code is
15 :     * very concise, this package is slightly faster than the built-in sparse
16 :     * Cholesky factorization in MATLAB 6.5 (chol), when using the same input
17 :     * permutation.
18 :     *
19 :     * The routines compute the LDL' factorization of a real sparse symmetric
20 :     * matrix A (or PAP' if a permutation P is supplied), and solve upper
21 :     * and lower triangular systems with the resulting L and D factors. If A is
22 :     * positive definite then the factorization will be accurate. A can be
23 :     * indefinite (with negative values on the diagonal D), but in this case no
24 :     * guarantee of accuracy is provided, since no numeric pivoting is performed.
25 :     *
26 :     * The n-by-n sparse matrix A is in compressed-column form. The nonzero values
27 :     * in column j are stored in Ax [Ap [j] ... Ap [j+1]-1], with corresponding row
28 :     * indices in Ai [Ap [j] ... Ap [j+1]-1]. Ap [0] = 0 is required, and thus
29 :     * nz = Ap [n] is the number of nonzeros in A. Ap is an int array of size n+1.
30 :     * The int array Ai and the double array Ax are of size nz. This data structure
31 :     * is identical to the one used by MATLAB, except for the following
32 :     * generalizations. The row indices in each column of A need not be in any
33 :     * particular order, although they must be in the range 0 to n-1. Duplicate
34 :     * entries can be present; any duplicates are summed. That is, if row index i
35 :     * appears twice in a column j, then the value of A (i,j) is the sum of the two
36 :     * entries. The data structure used here for the input matrix A is more
37 :     * flexible than MATLAB's, which requires sorted columns with no duplicate
38 :     * entries.
39 :     *
40 :     * Only the diagonal and upper triangular part of A (or PAP' if a permutation
41 :     * P is provided) is accessed. The lower triangular parts of the matrix A or
42 :     * PAP' can be present, but they are ignored.
43 :     *
44 :     * The optional input permutation is provided as an array P of length n. If
45 :     * P [k] = j, the row and column j of A is the kth row and column of PAP'.
46 :     * If P is present then the factorization is LDL' = PAP' or L*D*L' = A(P,P) in
47 :     * 0-based MATLAB notation. If P is not present (a null pointer) then no
48 :     * permutation is performed, and the factorization is LDL' = A.
49 :     *
50 :     * The lower triangular matrix L is stored in the same compressed-column
51 :     * form (an int Lp array of size n+1, an int Li array of size Lp [n], and a
52 :     * double array Lx of the same size as Li). It has a unit diagonal, which is
53 :     * not stored. The row indices in each column of L are always returned in
54 :     * ascending order, with no duplicate entries. This format is compatible with
55 :     * MATLAB, except that it would be more convenient for MATLAB to include the
56 :     * unit diagonal of L. Doing so here would add additional complexity to the
57 :     * code, and is thus omitted in the interest of keeping this code short and
58 :     * readable.
59 :     *
60 :     * The elimination tree is held in the Parent [0..n-1] array. It is normally
61 :     * not required by the user, but it is required by R_ldl_numeric. The diagonal
62 :     * matrix D is held as an array D [0..n-1] of size n.
63 :     *
64 :     * --------------------
65 :     * C-callable routines:
66 :     * --------------------
67 :     *
68 :     * R_ldl_symbolic: Given the pattern of A, computes the Lp and Parent arrays
69 :     * required by R_ldl_numeric. Takes time proportional to the number of
70 :     * nonzeros in L. Computes the inverse Pinv of P if P is provided.
71 :     * Also returns Lnz, the count of nonzeros in each column of L below
72 :     * the diagonal (this is not required by R_ldl_numeric).
73 :     * R_ldl_numeric: Given the pattern and numerical values of A, the Lp array,
74 :     * the Parent array, and P and Pinv if applicable, computes the
75 :     * pattern and numerical values of L and D.
76 :     * R_ldl_lsolve: Solves Lx=b for a dense vector b.
77 :     * R_ldl_dsolve: Solves Dx=b for a dense vector b.
78 :     * R_ldl_ltsolve: Solves L'x=b for a dense vector b.
79 :     * R_ldl_perm: Computes x=Pb for a dense vector b.
80 :     * R-ldl_permt: Computes x=P'b for a dense vector b.
81 :     * R_ldl_valid_perm: checks the validity of a permutation vector
82 :     * R_ldl_valid_matrix: checks the validity of the sparse matrix A
83 :     *
84 :     * ----------------------------
85 :     * Limitations of this package:
86 :     * ----------------------------
87 :     *
88 :     * In the interest of keeping this code simple and readable, R_ldl_symbolic and
89 :     * R_ldl_numeric assume their inputs are valid. You can check your own inputs
90 :     * prior to calling these routines with the R_ldl_valid_perm and R_ldl_valid_matrix
91 :     * routines. Except for the two R_ldl_valid_* routines, no routine checks to see
92 :     * if the array arguments are present (non-NULL). Like all C routines, no
93 :     * routine can determine if the arrays are long enough and don't overlap.
94 :     *
95 :     * The R_ldl_numeric does check the numerical factorization, however. It returns
96 :     * n if the factorization is successful. If D (k,k) is zero, then k is
97 :     * returned, and L is only partially computed.
98 :     *
99 :     * No pivoting to control fill-in is performed, which is often critical for
100 :     * obtaining good performance. I recommend that you compute the permutation P
101 :     * using AMD or SYMAMD (approximate minimum degree ordering routines), or an
102 :     * appropriate graph-partitioning based ordering. See the ldldemo.m routine for
103 :     * an example in MATLAB, and the ldlmain.c stand-alone C program for examples of
104 :     * how to find P. Routines for manipulating compressed-column matrices are
105 :     * available in UMFPACK. AMD, SYMAMD, UMFPACK, and this LDL package are all
106 :     * available at http://www.cise.ufl.edu/research/sparse.
107 :     *
108 :     * -------------------------
109 :     * Possible simplifications:
110 :     * -------------------------
111 :     *
112 :     * These routines could be made even simpler with a few additional assumptions.
113 :     * If no input permutation were performed, the caller would have to permute the
114 :     * matrix first, but the computation of Pinv, and the use of P and Pinv could be
115 :     * removed. If only the diagonal and upper triangular part of A or PAP' are
116 :     * present, then the tests in the "if (i < k)" statement in R_ldl_symbolic and
117 :     * "if (i <= k)" in R_ldl_numeric, are always true, and could be removed (i can
118 :     * equal k in R_ldl_symbolic, but then the body of the if statement would
119 :     * correctly do no work since Flag [k] == k). If we could assume that no
120 :     * duplicate entries are present, then the statement Y [i] += Ax [p] could be
121 :     * replaced with Y [i] = Ax [p] in R_ldl_numeric.
122 :     *
123 :     * --------------------------
124 :     * Description of the method:
125 :     * --------------------------
126 :     *
127 :     * LDL computes the symbolic factorization by finding the pattern of L one row
128 :     * at a time. It does this based on the following theory. Consider a sparse
129 :     * system Lx=b, where L, x, and b, are all sparse, and where L comes from a
130 :     * Cholesky (or LDL') factorization. The elimination tree (etree) of L is
131 :     * defined as follows. The parent of node j is the smallest k > j such that
132 :     * L (k,j) is nonzero. Node j has no parent if column j of L is completely zero
133 :     * below the diagonal (j is a root of the etree in this case). The nonzero
134 :     * pattern of x is the union of the paths from each node i to the root, for
135 :     * each nonzero b (i). To compute the numerical solution to Lx=b, we can
136 :     * traverse the columns of L corresponding to nonzero values of x. This
137 :     * traversal does not need to be done in the order 0 to n-1. It can be done in
138 :     * any "topological" order, such that x (i) is computed before x (j) if i is a
139 :     * descendant of j in the elimination tree.
140 :     *
141 :     * The row-form of the LDL' factorization is shown in the MATLAB function
142 :     * ldlrow.m in this LDL package. Note that row k of L is found via a sparse
143 :     * triangular solve of L (1:k-1, 1:k-1) \ A (1:k-1, k), to use 1-based MATLAB
144 :     * notation. Thus, we can start with the nonzero pattern of the kth column of
145 :     * A (above the diagonal), follow the paths up to the root of the etree of the
146 :     * (k-1)-by-(k-1) leading submatrix of L, and obtain the pattern of the kth row
147 :     * of L. Note that we only need the leading (k-1)-by-(k-1) submatrix of L to
148 :     * do this. The elimination tree can be constructed as we go.
149 :     *
150 :     * The symbolic factorization does the same thing, except that it discards the
151 :     * pattern of L as it is computed. It simply counts the number of nonzeros in
152 :     * each column of L and then constructs the Lp index array when it's done. The
153 :     * symbolic factorization does not need to do this in topological order.
154 :     * Compare R_ldl_symbolic with the first part of R_ldl_numeric, and note that the
155 :     * while (len > 0) loop is not present in R_ldl_symbolic.
156 :     *
157 :     * LDL Version 1.0 (Dec. 31, 2003), Copyright (c) 2003 by Timothy A Davis,
158 :     * University of Florida. All Rights Reserved. Developed while on sabbatical
159 :     * at Stanford University and Lawrence Berkeley National Laboratory. Refer to
160 :     * the README file for the License. Available at
161 :     * http://www.cise.ufl.edu/research/sparse.
162 :     */
163 :    
164 :     #include "R_ldl.h"
165 :    
166 :     /* ========================================================================== */
167 :     /* === R_ldl_symbolic ========================================================= */
168 :     /* ========================================================================== */
169 :    
170 :     /**
171 :     * The input to this routine is a sparse matrix A, stored in column form, and
172 :     * an optional permutation P. The output is the elimination tree
173 :     * and the number of nonzeros in each column of L. Parent [i] = k if k is the
174 :     * parent of i in the tree. The Parent array is required by R_ldl_numeric.
175 :     * Lnz [k] gives the number of nonzeros in the kth column of L, excluding the
176 :     * diagonal.
177 :     *
178 :     * If P is NULL, then it is ignored. The factorization will be LDL' = A.
179 :     * Pinv is not computed. In this case, neither P nor Pinv are required by
180 :     * R_ldl_numeric.
181 :     *
182 :     * If P is not NULL, then it is assumed to be a valid permutation. If
183 :     * row and column j of A is the kth pivot, the P [k] = j. The factorization
184 :     * will be LDL' = PAP', or A (p,p) in MATLAB notation. The inverse permutation
185 :     * Pinv is computed, where Pinv [j] = k if P [k] = j. In this case, both P
186 :     * and Pinv are required as inputs to R_ldl_numeric.
187 :     *
188 :     * The floating-point operation count of the subsequent call to R_ldl_numeric
189 :     * is not returned, but could be computed after R_ldl_symbolic is done. It is
190 :     * the sum of (Lnz [k]) * (Lnz [k] + 2) for k = 0 to n-1.
191 :     *
192 :     * @param n A and L are n-by-n, where n >= 0
193 :     * @param Ap column pointers of size n+1
194 :     * @param Ai row indices of size nz=Ap[n]
195 :     * @param Lp column pointers of size n+1
196 :     * @param Parent elimination tree of size n
197 :     * @param P optional permutation vector of size n [use (int *) NULL for none]
198 :     * @param Pinv optional inverse permutation [not used if P is NULL]
199 :     */
200 :     void
201 :     R_ldl_symbolic(int n, const int Ap[], const int Ai[], int Lp[],
202 :     int Parent[], const int P[], int Pinv[])
203 :     {
204 :     int i, k, p, kk, p2;
205 :     int *Flag = Calloc(n, int);
206 :     int *Lnz = Calloc(n, int);
207 :     if (P)
208 :     {
209 :     /* If P is present then compute Pinv, the inverse of P */
210 :     for (k = 0 ; k < n ; k++)
211 :     {
212 :     Pinv [P [k]] = k ;
213 :     }
214 :     }
215 :     for (k = 0 ; k < n ; k++)
216 :     {
217 :     /* L(k,:) pattern: all nodes reachable in etree from nz in A(0:k-1,k) */
218 :     Parent [k] = -1 ; /* parent of k is not yet known */
219 :     Flag [k] = k ; /* mark node k as visited */
220 :     Lnz [k] = 0 ; /* count of nonzeros in column k of L */
221 :     kk = (P) ? (P [k]) : (k) ; /* kth original, or permuted, column */
222 :     p2 = Ap [kk+1] ;
223 :     for (p = Ap [kk] ; p < p2 ; p++)
224 :     {
225 :     /* A (i,k) is nonzero (original or permuted A) */
226 :     i = (Pinv) ? (Pinv [Ai [p]]) : (Ai [p]) ;
227 :     if (i < k)
228 :     {
229 :     /* follow path from i to root of etree, stop at flagged node */
230 :     for ( ; Flag [i] != k ; i = Parent [i])
231 :     {
232 :     /* find parent of i if not yet determined */
233 :     if (Parent [i] == -1)
234 :     {
235 :     Parent [i] = k ;
236 :     }
237 :     Lnz [i]++ ; /* L (k,i) is nonzero */
238 :     Flag [i] = k ; /* mark i as visited */
239 :     }
240 :     }
241 :     }
242 :     }
243 :     /* construct Lp index array from Lnz column counts */
244 :     Lp [0] = 0 ;
245 :     for (k = 0 ; k < n ; k++)
246 :     {
247 :     Lp [k+1] = Lp [k] + Lnz [k] ;
248 :     }
249 :     Free(Flag); Free(Lnz);
250 :     }
251 :    
252 :     /**
253 :     * Given a sparse matrix A (the arguments n, Ap, Ai, and Ax) and its symbolic
254 :     * analysis (Lp and Parent, and optionally P and Pinv), compute the numeric LDL'
255 :     * factorization of A or PAP'. The outputs of this routine are arguments Li,
256 :     * Lx, and D.
257 :     *
258 :     * @param n A and L are n-by-n, where n >= 0
259 :     * @param Ap column pointer array of size n+1
260 :     * @param Ai row index array of size nz=Ap[n] (upper triangle only)
261 :     * @param Ax array of non-zero matrix elements of size nz=Ap[n]
262 :     * @param Lp column pointer array of size n+1
263 :     * @param Parent elimination tree of size n
264 :     * @param Li row index array of size lnz=Lp[n]
265 :     * @param Lx non-zero off-diagonal elements of L (size lnz=Lp[n])
266 :     * @param D vector of diagonal elements (size n)
267 :     * @param P optional permutation vector of size n [use (int *) NULL for none]
268 :     * @param Pinv optional inverse permutation [use (int *) NULL for none]
269 :     *
270 :     * @return n if successful, k if D (k,k) is zero
271 :     */
272 :     int
273 :     R_ldl_numeric(int n,
274 :     const int Ap[], const int Ai[], const double Ax[],
275 :     const int Lp[], const int Parent[],
276 :     int Li[], double Lx[], double D[],
277 :     const int P[], const int Pinv[])
278 :     {
279 :     double yi, l_ki ;
280 :     int i, k, p, kk, p2, len, top ;
281 :     int *Lnz = Calloc(n, int),
282 :     *Pattern = Calloc(n, int),
283 :     *Flag = Calloc(n, int);
284 :     double *Y = Calloc(n, double);
285 :    
286 :     for (k = 0 ; k < n ; k++)
287 :     {
288 :     /* compute nonzero Pattern of kth row of L, in topological order */
289 :     Y [k] = 0.0 ; /* Y (0:k) is now all zero */
290 :     top = n ; /* stack for pattern is empty */
291 :     Flag [k] = k ; /* mark node k as visited */
292 :     Lnz [k] = 0 ; /* count of nonzeros in column k of L */
293 :     kk = (P) ? (P [k]) : (k) ; /* kth original, or permuted, column */
294 :     p2 = Ap [kk+1] ;
295 :     for (p = Ap [kk] ; p < p2 ; p++)
296 :     {
297 :     i = (Pinv) ? (Pinv [Ai [p]]) : (Ai [p]) ; /* get A(i,k) */
298 :     if (i <= k)
299 :     {
300 :     Y [i] += Ax [p] ; /* scatter A(i,k) into Y (sum duplicates) */
301 :     /* follow path from i to root of etree, stop at flagged node */
302 :     for (len = 0 ; Flag [i] != k ; i = Parent [i])
303 :     {
304 :     Pattern [len++] = i ; /* L (k,i) is nonzero */
305 :     Flag [i] = k ; /* mark i as visited */
306 :     }
307 :     while (len > 0) /* push path on top of stack */
308 :     {
309 :     Pattern [--top] = Pattern [--len] ;
310 :     }
311 :     }
312 :     }
313 :     /* Pattern [top ... n-1] now contains nonzero pattern of L (:,k) */
314 :     /* compute numerical values kth row of L (a sparse triangular solve) */
315 :     D [k] = Y [k] ; /* get D (k,k) and clear Y (k) */
316 :     Y [k] = 0.0 ;
317 :     for ( ; top < n ; top++)
318 :     {
319 :     i = Pattern [top] ;
320 :     yi = Y [i] ; /* get and clear Y (i) */
321 :     Y [i] = 0.0 ;
322 :     p2 = Lp [i] + Lnz [i] ;
323 :     for (p = Lp [i] ; p < p2 ; p++)
324 :     {
325 :     Y [Li [p]] -= Lx [p] * yi ;
326 :     }
327 :     l_ki = yi / D [i] ; /* the nonzero entry L (k,i) */
328 :     D [k] -= l_ki * yi ;
329 :     Li [p] = k ; /* store L(k,k )in column form of L */
330 :     Lx [p] = l_ki ;
331 :     Lnz [i]++ ; /* increment count of nonzeros in col i */
332 :     }
333 :     if (D [k] == 0.0)
334 :     {
335 :     Free(Y); Free(Pattern); Free(Flag); Free(Lnz);
336 :     return (k) ; /* failure, D (k,k) is zero */
337 :     }
338 :     }
339 :     Free(Y); Free(Pattern); Free(Flag); Free(Lnz);
340 :     return (n) ; /* success, diagonal of D is all nonzero */
341 :     }
342 :    
343 :     /**
344 :     * solve Lx=b
345 :     *
346 :     * @param n L is n-by-n, where n >= 0
347 :     * @param X size n. right-hand-side on input, soln. on output
348 :     * @param Lp column pointer array of size n+1
349 :     * @param Li row index array of size lnz=Lp[n]
350 :     * @param Lx non-zero off-diagonal elements (size lnz=Lp[n])
351 :     */
352 :     void
353 :     R_ldl_lsolve (int n, double X[],
354 :     const int Lp[], const int Li[], const double Lx[])
355 :     {
356 :     int j, p, p2 ;
357 :     for (j = 0 ; j < n ; j++)
358 :     {
359 :     p2 = Lp [j+1] ;
360 :     for (p = Lp [j] ; p < p2 ; p++)
361 :     {
362 :     X [Li [p]] -= Lx [p] * X [j] ;
363 :     }
364 :     }
365 :     }
366 :    
367 :     /**
368 :     * solve Dx=b
369 :     *
370 :     * @param n L is n-by-n, where n >= 0
371 :     * @param X size n. right-hand-side on input, soln. on output
372 :     * @param D diagonal elements of size n
373 :     */
374 :     void
375 :     R_ldl_dsolve(int n, double X[], const double D[])
376 :     {
377 :     int j ;
378 :     for (j = 0 ; j < n ; j++)
379 :     {
380 :     X [j] /= D [j] ;
381 :     }
382 :     }
383 :    
384 :     /**
385 :     * solve L'x=b
386 :     *
387 :     * @param n L is n-by-n, where n >= 0
388 :     * @param X size n. right-hand-side on input, soln. on output
389 :     * @param Lp column pointer array of size n+1
390 :     * @param Li row index array of size lnz=Lp[n]
391 :     * @param Lx non-zero off-diagonal elements (size lnz=Lp[n])
392 :     */
393 :     void
394 :     R_ldl_ltsolve (int n, double X[],
395 :     const int Lp[], const int Li[], const double Lx[])
396 :     {
397 :     int j, p, p2 ;
398 :     for (j = n-1 ; j >= 0 ; j--)
399 :     {
400 :     p2 = Lp [j+1] ;
401 :     for (p = Lp [j] ; p < p2 ; p++)
402 :     {
403 :     X [j] -= Lx [p] * X [Li [p]] ;
404 :     }
405 :     }
406 :     }
407 :    
408 :     /**
409 :     * permute a vector, x=Pb
410 :     *
411 :     * @param n size of X, B, and P
412 :     * @param X output of size n
413 :     * @param B input of size n
414 :     * @param P input permutation array of size n
415 :     */
416 :     void
417 :     R_ldl_perm(int n, double X[], const double B[], const int P[])
418 :     {
419 :     int j ;
420 :     for (j = 0 ; j < n ; j++)
421 :     {
422 :     X [j] = B [P [j]] ;
423 :     }
424 :     }
425 :    
426 :     /**
427 :     * permute a vector, x=P'b
428 :     *
429 :     * @param n size of X, B, and P
430 :     * @param X output of size n
431 :     * @param B input of size n
432 :     * @param P input permutation array of size n
433 :     */
434 :     void
435 :     R_ldl_permt(int n, double X[], const double B[], const int P[])
436 :     {
437 :     int j ;
438 :     for (j = 0 ; j < n ; j++)
439 :     {
440 :     X [P [j]] = B [j] ;
441 :     }
442 :     }
443 :    
444 :     /**
445 :     * Check if a permutation vector is valid
446 :     *
447 :     * @param n size of permutation
448 :     * @param P input of size n, a permutation of 0:n-1
449 :     *
450 :     * @return 1 if valid, otherwise 0
451 :     */
452 :     int
453 :     R_ldl_valid_perm (int n, const int P[])
454 :     {
455 :    
456 :     int j, k ;
457 :     int *Flag = (int *) R_alloc(n, sizeof(int));
458 :    
459 :     if (n < 0 || !Flag)
460 :     {
461 :     return (0) ; /* n must be >= 0, and Flag must be present */
462 :     }
463 :     if (!P)
464 :     {
465 :     return (1) ; /* If NULL, P is assumed to be the identity perm. */
466 :     }
467 :     for (j = 0 ; j < n ; j++)
468 :     {
469 :     Flag [j] = 0 ; /* clear the Flag array */
470 :     }
471 :     for (k = 0 ; k < n ; k++)
472 :     {
473 :     j = P [k] ;
474 :     if (j < 0 || j >= n || Flag [j] != 0)
475 :     {
476 :     return (0) ; /* P is not valid */
477 :     }
478 :     Flag [j] = 1 ;
479 :     }
480 :     return (1) ; /* P is valid */
481 :     }
482 :    
483 :     /**
484 :     * This routine checks to see if a sparse matrix A is valid for input to
485 :     * R_ldl_symbolic and R_ldl_numeric. It returns 1 if the matrix is valid, 0
486 :     * otherwise. A is in sparse column form. The numerical values in column j
487 :     * are stored in Ax [Ap [j] ... Ap [j+1]-1], with row indices in
488 :     * Ai [Ap [j] ... Ap [j+1]-1]. The Ax array is not checked.
489 :     *
490 :     * @param n A is n by n (n >= 0)
491 :     * @param Ap column pointer array of size n+1
492 :     * @param Ai row index array of size nz=Ap[n]
493 :     *
494 :     * @return 1 if valid sparse matrix, otherwise 0
495 :     */
496 :     int
497 :     R_ldl_valid_matrix (int n, const int Ap[], const int Ai[])
498 :     {
499 :     int j, p ;
500 :     if (n < 0 || !Ap || !Ai || Ap [0] != 0)
501 :     {
502 :     return (0) ; /* n must be >= 0, and Ap and Ai must be present */
503 :     }
504 :     for (j = 0 ; j < n ; j++)
505 :     {
506 :     if (Ap [j] > Ap [j+1])
507 :     {
508 :     return (0) ; /* Ap must be monotonically nondecreasing */
509 :     }
510 :     }
511 :     for (p = 0 ; p < Ap [n] ; p++)
512 :     {
513 :     if (Ai [p] < 0 || Ai [p] >= n)
514 :     {
515 :     return (0) ; /* row indices must be in the range 0 to n-1 */
516 :     }
517 :     }
518 :     return (1) ; /* matrix is valid */
519 :     }

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge