Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion SSBA-4.0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ include (Config/v3d_macros.cmake)

include (Config/local_config.cmake)

include_directories(${V3D_INCLUDE_DIRS} ${EXTRA_INC_DIRS})
file(GLOB COLAMD_SRC
COLAMD/Source/*
COLAMD/Include/*
SuiteSparse_config/SuiteSparse_config.h
SuiteSparse_config/SuiteSparse_config.c
)
include_directories("SuiteSparse_config/")
add_library(colamd ${COLAMD_SRC})
set ( V3D_INCLUDE_DIRS ${V3D_INCLUDE_DIRS} "COLAMD/Include" )


include_directories(${V3D_INCLUDE_DIRS} ${EXTRA_INC_DIRS})

source_group("Base" REGULAR_EXPRESSION Base/.*cpp|Base.*h)
set (BASE_SRC
Expand Down
15 changes: 15 additions & 0 deletions SSBA-4.0/COLAMD/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project(colamd)
cmake_minimum_required(VERSION 2.8)

file(GLOB SRCS
Source/*
Include/*)

include_directories(
"Include"
"../SuiteSparse_config/"
)

add_library( colamd ${SRCS} )

target_link_libraries( colamd SuiteSparse_config )
44 changes: 44 additions & 0 deletions SSBA-4.0/COLAMD/Demo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#-----------------------------------------------------------------------------
# compile the COLAMD demo
#-----------------------------------------------------------------------------

default: colamd_example colamd_l_example

include ../../SuiteSparse_config/SuiteSparse_config.mk

I = -I../Include -I../../SuiteSparse_config

C = $(CC) $(CF) $(I)

library:
( cd ../Lib ; $(MAKE) )

#------------------------------------------------------------------------------
# Create the demo program, run it, and compare the output
#------------------------------------------------------------------------------

dist:

colamd_example: colamd_example.c library
$(C) -o colamd_example colamd_example.c ../Lib/libcolamd.a -lm
- ./colamd_example > my_colamd_example.out
- diff colamd_example.out my_colamd_example.out

colamd_l_example: colamd_l_example.c library
$(C) -o colamd_l_example colamd_l_example.c ../Lib/libcolamd.a -lm
- ./colamd_l_example > my_colamd_l_example.out
- diff colamd_l_example.out my_colamd_l_example.out

#------------------------------------------------------------------------------
# Remove all but the files in the original distribution
#------------------------------------------------------------------------------

clean:
- $(RM) $(CLEAN)

purge: distclean

distclean: clean
- $(RM) colamd_example colamd_l_example
- $(RM) my_colamd_example.out my_colamd_l_example.out
- $(RM) -r *.dSYM
180 changes: 180 additions & 0 deletions SSBA-4.0/COLAMD/Demo/colamd_example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/* ========================================================================== */
/* === colamd and symamd example ============================================ */
/* ========================================================================== */

/* COLAMD / SYMAMD example

colamd example of use, to order the columns of a 5-by-4 matrix with
11 nonzero entries in the following nonzero pattern, with default knobs.

x 0 x 0
x 0 x x
0 x x 0
0 0 x x
x x 0 0

symamd example of use, to order the rows and columns of a 5-by-5
matrix with 13 nonzero entries in the following nonzero pattern,
with default knobs.

x x 0 0 0
x x x x 0
0 x x 0 0
0 x 0 x x
0 0 0 x x

(where x denotes a nonzero value).

See the colamd.c for the routines this program calls, and for the License.
*/

/* ========================================================================== */

#include <stdio.h>
#include "colamd.h"

#define A_NNZ 11
#define A_NROW 5
#define A_NCOL 4
#define ALEN 150

#define B_NNZ 4
#define B_N 5

int main (void)
{

/* ====================================================================== */
/* input matrix A definition */
/* ====================================================================== */

int A [ALEN] = {

0, 1, 4, /* row indices of nonzeros in column 0 */
2, 4, /* row indices of nonzeros in column 1 */
0, 1, 2, 3, /* row indices of nonzeros in column 2 */
1, 3} ; /* row indices of nonzeros in column 3 */

int p [ ] = {

0, /* column 0 is in A [0..2] */
3, /* column 1 is in A [3..4] */
5, /* column 2 is in A [5..8] */
9, /* column 3 is in A [9..10] */
A_NNZ} ; /* number of nonzeros in A */

/* ====================================================================== */
/* input matrix B definition */
/* ====================================================================== */

int B [ ] = { /* Note: only strictly lower triangular part */
/* is included, since symamd ignores the */
/* diagonal and upper triangular part of B. */

1, /* row indices of nonzeros in column 0 */
2, 3, /* row indices of nonzeros in column 1 */
/* row indices of nonzeros in column 2 (none) */
4 /* row indices of nonzeros in column 3 */
} ; /* row indices of nonzeros in column 4 (none) */

int q [ ] = {

0, /* column 0 is in B [0] */
1, /* column 1 is in B [1..2] */
3, /* column 2 is empty */
3, /* column 3 is in B [3] */
4, /* column 4 is empty */
B_NNZ} ; /* number of nonzeros in strictly lower B */

/* ====================================================================== */
/* other variable definitions */
/* ====================================================================== */

int perm [B_N+1] ; /* note the size is N+1 */
int stats [COLAMD_STATS] ; /* for colamd and symamd output statistics */

int row, col, pp, length, ok ;

/* ====================================================================== */
/* dump the input matrix A */
/* ====================================================================== */

printf ("colamd %d-by-%d input matrix:\n", A_NROW, A_NCOL) ;
for (col = 0 ; col < A_NCOL ; col++)
{
length = p [col+1] - p [col] ;
printf ("Column %d, with %d entries:\n", col, length) ;
for (pp = p [col] ; pp < p [col+1] ; pp++)
{
row = A [pp] ;
printf (" row %d\n", row) ;
}
}

/* ====================================================================== */
/* order the matrix. Note that this destroys A and overwrites p */
/* ====================================================================== */

ok = colamd (A_NROW, A_NCOL, ALEN, A, p, (double *) NULL, stats) ;
colamd_report (stats) ;

if (!ok)
{
printf ("colamd error!\n") ;
exit (1) ;
}

/* ====================================================================== */
/* print the column ordering */
/* ====================================================================== */

printf ("colamd column ordering:\n") ;
printf ("1st column: %d\n", p [0]) ;
printf ("2nd column: %d\n", p [1]) ;
printf ("3rd column: %d\n", p [2]) ;
printf ("4th column: %d\n", p [3]) ;

/* ====================================================================== */
/* dump the strictly lower triangular part of symmetric input matrix B */
/* ====================================================================== */

printf ("\n\nsymamd %d-by-%d input matrix:\n", B_N, B_N) ;
printf ("Entries in strictly lower triangular part:\n") ;
for (col = 0 ; col < B_N ; col++)
{
length = q [col+1] - q [col] ;
printf ("Column %d, with %d entries:\n", col, length) ;
for (pp = q [col] ; pp < q [col+1] ; pp++)
{
row = B [pp] ;
printf (" row %d\n", row) ;
}
}

/* ====================================================================== */
/* order the matrix B. Note that this does not modify B or q. */
/* ====================================================================== */

ok = symamd (B_N, B, q, perm, (double *) NULL, stats, &calloc, &free) ;
symamd_report (stats) ;

if (!ok)
{
printf ("symamd error!\n") ;
exit (1) ;
}

/* ====================================================================== */
/* print the symmetric ordering */
/* ====================================================================== */

printf ("symamd column ordering:\n") ;
printf ("1st row/column: %d\n", perm [0]) ;
printf ("2nd row/column: %d\n", perm [1]) ;
printf ("3rd row/column: %d\n", perm [2]) ;
printf ("4th row/column: %d\n", perm [3]) ;
printf ("5th row/column: %d\n", perm [4]) ;

exit (0) ;
}

50 changes: 50 additions & 0 deletions SSBA-4.0/COLAMD/Demo/colamd_example.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
colamd 5-by-4 input matrix:
Column 0, with 3 entries:
row 0
row 1
row 4
Column 1, with 2 entries:
row 2
row 4
Column 2, with 4 entries:
row 0
row 1
row 2
row 3
Column 3, with 2 entries:
row 1
row 3

colamd version 2.8, Jun 1, 2012: OK.
colamd: number of dense or empty rows ignored: 0
colamd: number of dense or empty columns ignored: 0
colamd: number of garbage collections performed: 0
colamd column ordering:
1st column: 1
2nd column: 0
3rd column: 2
4th column: 3


symamd 5-by-5 input matrix:
Entries in strictly lower triangular part:
Column 0, with 1 entries:
row 1
Column 1, with 2 entries:
row 2
row 3
Column 2, with 0 entries:
Column 3, with 1 entries:
row 4
Column 4, with 0 entries:

symamd version 2.8, Jun 1, 2012: OK.
symamd: number of dense or empty rows ignored: 0
symamd: number of dense or empty columns ignored: 0
symamd: number of garbage collections performed: 0
symamd column ordering:
1st row/column: 0
2nd row/column: 2
3rd row/column: 1
4th row/column: 3
5th row/column: 4
Loading