Amesos Package Browser (Single Doxygen Collection) Development
amesos_cholmod_l_csymamd.c
Go to the documentation of this file.
00001 /* ========================================================================== */
00002 /* === Partition/cholmod_csymamd ============================================ */
00003 /* ========================================================================== */
00004 
00005 /* -----------------------------------------------------------------------------
00006  * CHOLMOD/Partition Module.
00007  * Copyright (C) 2005-2006, Univ. of Florida.  Author: Timothy A. Davis
00008  * The CHOLMOD/Partition Module is licensed under Version 2.1 of the GNU
00009  * Lesser General Public License.  See lesser.txt for a text of the license.
00010  * CHOLMOD is also available under other licenses; contact authors for details.
00011  * http://www.cise.ufl.edu/research/sparse
00012  * -------------------------------------------------------------------------- */
00013 
00014 /* CHOLMOD interface to the CSYMAMD ordering routine.  Finds a permutation
00015  * p such that the Cholesky factorization of PAP' is sparser than A.
00016  * The column etree is found and postordered, and the CSYMAMD
00017  * ordering is then combined with its postordering.  If A is unsymmetric,
00018  * A+A' is ordered (A must be square).
00019  *
00020  * workspace: Head (nrow+1)
00021  *
00022  * Supports any xtype (pattern, real, complex, or zomplex).
00023  */
00024 
00025 #ifndef NPARTITION
00026 
00027 /* This file should make the long int version of CHOLMOD */
00028 #define DLONG 1
00029 
00030 #include "amesos_cholmod_internal.h"
00031 #include "amesos_ccolamd.h"
00032 #include "amesos_cholmod_partition.h"
00033 
00034 #if (CCOLAMD_VERSION < CCOLAMD_VERSION_CODE (2,5))
00035 #error "CCOLAMD v2.0 or later is required"
00036 #endif
00037 
00038 /* ========================================================================== */
00039 /* === cholmod_csymamd ====================================================== */
00040 /* ========================================================================== */
00041 
00042 int CHOLMOD(csymamd)
00043 (
00044     /* ---- input ---- */
00045     cholmod_sparse *A,  /* matrix to order */
00046     /* ---- output --- */
00047     Int *Cmember, /* size nrow.  see cholmod_ccolamd.c for description */
00048     Int *Perm,    /* size A->nrow, output permutation */
00049     /* --------------- */
00050     cholmod_common *Common
00051 )
00052 {
00053     double knobs [CCOLAMD_KNOBS] ;
00054     Int *perm, *Head ;
00055     Int ok, i, nrow, stats [CCOLAMD_STATS] ;
00056 
00057     /* ---------------------------------------------------------------------- */
00058     /* check inputs */
00059     /* ---------------------------------------------------------------------- */
00060 
00061     RETURN_IF_NULL_COMMON (FALSE) ;
00062     RETURN_IF_NULL (A, FALSE) ;
00063     RETURN_IF_NULL (Perm, FALSE) ;
00064     RETURN_IF_XTYPE_INVALID (A, CHOLMOD_PATTERN, CHOLMOD_ZOMPLEX, FALSE) ;
00065     Common->status = CHOLMOD_OK ;
00066 
00067     if (A->nrow != A->ncol || !(A->packed))
00068     {
00069   ERROR (CHOLMOD_INVALID, "matrix must be square and packed") ;
00070   return (FALSE) ;
00071     }
00072 
00073     /* ---------------------------------------------------------------------- */
00074     /* get inputs */
00075     /* ---------------------------------------------------------------------- */
00076 
00077     nrow = A->nrow ;
00078 
00079     /* ---------------------------------------------------------------------- */
00080     /* allocate workspace */
00081     /* ---------------------------------------------------------------------- */
00082 
00083     CHOLMOD(allocate_work) (nrow, 0, 0, Common) ;
00084     if (Common->status < CHOLMOD_OK)
00085     {
00086   return (FALSE) ;
00087     }
00088 
00089     /* ---------------------------------------------------------------------- */
00090     /* order the matrix (does not affect A->p or A->i) */
00091     /* ---------------------------------------------------------------------- */
00092 
00093     perm = Common->Head ; /* size nrow+1 (i/l/l) */
00094 
00095     /* get parameters */
00096 #ifdef LONG
00097     amesos_ccolamd_l_set_defaults (knobs) ;
00098 #else
00099     amesos_ccolamd_set_defaults (knobs) ;
00100 #endif
00101     if (Common->current >= 0 && Common->current < CHOLMOD_MAXMETHODS)
00102     {
00103   /* get the knobs from the Common parameters */
00104   knobs [CCOLAMD_DENSE_ROW] =Common->method[Common->current].prune_dense ;
00105   knobs [CCOLAMD_AGGRESSIVE]=Common->method[Common->current].aggressive ;
00106     }
00107 
00108     {
00109 #ifdef LONG
00110   amesos_csymamd_l (nrow, A->i, A->p, perm, knobs, stats, Common->calloc_memory,
00111     Common->free_memory, Cmember, A->stype) ;
00112 #else
00113   amesos_csymamd (nrow, A->i, A->p, perm, knobs, stats, Common->calloc_memory,
00114     Common->free_memory, Cmember, A->stype) ;
00115 #endif
00116   ok = stats [CCOLAMD_STATUS] ;
00117     }
00118 
00119     if (ok == CCOLAMD_ERROR_out_of_memory)
00120     {
00121   ERROR (CHOLMOD_OUT_OF_MEMORY, "out of memory") ; 
00122     }
00123     ok = (ok == CCOLAMD_OK || ok == CCOLAMD_OK_BUT_JUMBLED) ;
00124 
00125     /* ---------------------------------------------------------------------- */
00126     /* free the workspace and return result */
00127     /* ---------------------------------------------------------------------- */
00128 
00129     /* permutation returned in perm [0..n-1] */
00130     for (i = 0 ; i < nrow ; i++)
00131     {
00132   Perm [i] = perm [i] ;
00133     }
00134 
00135     /* clear Head workspace (used for perm, in csymamd): */
00136     Head = Common->Head ;
00137     for (i = 0 ; i <= nrow ; i++)
00138     {
00139   Head [i] = EMPTY ;
00140     }
00141 
00142     return (ok) ;
00143 }
00144 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines