1 /* ========================================================================== */
2 /* === UMFPACK_report_triplet =============================================== */
3 /* ========================================================================== */
4 
5 /* -------------------------------------------------------------------------- */
6 /* Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com.   */
7 /* All Rights Reserved.  See ../Doc/License.txt for License.                  */
8 /* -------------------------------------------------------------------------- */
9 
10 /*
11     User-callable.  Prints a matrix in triplet form.  See
12     umfpack_report_triplet.h for details.
13 */
14 
15 #include "umf_internal.h"
16 
UMFPACK_report_triplet(Int n_row,Int n_col,Int nz,const Int Ti[],const Int Tj[],const double Tx[],const double Tz[],const double Control[UMFPACK_CONTROL])17 GLOBAL Int UMFPACK_report_triplet
18 (
19     Int n_row,
20     Int n_col,
21     Int nz,
22     const Int Ti [ ],
23     const Int Tj [ ],
24     const double Tx [ ],
25 #ifdef COMPLEX
26     const double Tz [ ],
27 #endif
28     const double Control [UMFPACK_CONTROL]
29 )
30 {
31     Entry t ;
32     Int prl, prl1, k, i, j, do_values ;
33 #ifdef COMPLEX
34     Int split = SPLIT (Tz) ;
35 #endif
36 
37     prl = GET_CONTROL (UMFPACK_PRL, UMFPACK_DEFAULT_PRL) ;
38 
39     if (prl <= 2)
40     {
41 	return (UMFPACK_OK) ;
42     }
43 
44     PRINTF (("triplet-form matrix, n_row = "ID", n_col = "ID" nz = "ID". ",
45 	n_row, n_col, nz)) ;
46 
47     if (!Ti || !Tj)
48     {
49 	PRINTF (("ERROR: indices not present\n\n")) ;
50 	return (UMFPACK_ERROR_argument_missing) ;
51     }
52 
53     if (n_row <= 0 || n_col <= 0)
54     {
55 	PRINTF (("ERROR: n_row or n_col is <= 0\n\n")) ;
56 	return (UMFPACK_ERROR_n_nonpositive) ;
57     }
58 
59     if (nz < 0)
60     {
61 	PRINTF (("ERROR: nz is < 0\n\n")) ;
62 	return (UMFPACK_ERROR_invalid_matrix) ;
63     }
64 
65     PRINTF4 (("\n")) ;
66 
67     do_values = Tx != (double *) NULL ;
68 
69     prl1 = prl ;
70     for (k = 0 ; k < nz ; k++)
71     {
72 	i = Ti [k] ;
73 	j = Tj [k] ;
74 	PRINTF4 (("    "ID" : "ID" "ID" ", INDEX (k), INDEX (i), INDEX (j))) ;
75 	if (do_values && prl >= 4)
76 	{
77 	    ASSIGN (t, Tx, Tz, k, split) ;
78 	    PRINT_ENTRY (t) ;
79 	}
80 	PRINTF4 (("\n")) ;
81 	if (i < 0 || i >= n_row || j < 0 || j >= n_col)
82 	{
83 	    /* invalid triplet */
84 	    PRINTF (("ERROR: invalid triplet\n\n")) ;
85 	    return (UMFPACK_ERROR_invalid_matrix) ;
86 	}
87 	if (prl == 4 && k == 9 && nz > 10)
88 	{
89 	    PRINTF (("    ...\n")) ;
90 	    prl-- ;
91 	}
92     }
93     prl = prl1 ;
94 
95     PRINTF4 (("    triplet-form matrix ")) ;
96     PRINTF (("OK\n\n")) ;
97     return (UMFPACK_OK) ;
98 }
99