CMR  1.3.0
separation.h
Go to the documentation of this file.
1 #ifndef CMR_SEPARATION_H
2 #define CMR_SEPARATION_H
3 
4 #include <cmr/env.h>
5 #include <cmr/matrix.h>
6 #include <cmr/element.h>
7 
8 #include <assert.h>
9 #include <stdint.h>
10 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 typedef enum
24 {
25  CMR_SEPA_FIRST = 0,
27  CMR_SEPA_SECOND = 1,
40 
41 typedef enum
42 {
50 
51 typedef struct
52 {
53  size_t numRows;
54  size_t numColumns;
55  int* rowsFlags;
56  int* columnsFlags;
58 } CMR_SEPA;
59 
66 CMR_EXPORT
68  CMR* cmr,
69  size_t numRows,
70  size_t numColumns,
71  CMR_SEPA** psepa
72 );
73 
78 CMR_EXPORT
80  CMR* cmr,
81  CMR_SEPA** psepa
82 );
83 
88 CMR_EXPORT
90  CMR_SEPA* sepa,
91  size_t* pnumRowsTopLeft,
92  size_t* pnumColumnsTopLeft,
93  size_t* pnumRowsBottomRight,
94  size_t* pnumColumnsBottomRight
95 );
96 
105 CMR_EXPORT
107  CMR* cmr,
108  CMR_SEPA* sepa,
109  CMR_CHRMAT* matrix,
110  CMR_CHRMAT* transpose,
111  bool* pswapped,
112  CMR_SUBMAT** pviolator
113 );
114 
124 CMR_EXPORT
126  CMR* cmr,
127  CMR_SEPA* sepa,
128  CMR_CHRMAT* matrix,
129  CMR_CHRMAT* transpose,
130  CMR_SUBMAT* submatrix,
131  bool* pswapped,
132  CMR_SUBMAT** pviolator
133 );
134 
139 CMR_EXPORT
141  CMR_SEPA* sepa,
142  size_t reprRows[2][3],
143  size_t reprColumns[2][3]
144 );
145 
150 CMR_EXPORT
152  CMR_SEPA* sepa,
153  size_t part,
154  size_t* rowsToPart,
155  size_t* columnsToPart,
156  size_t* pnumPartRows,
157  size_t* pnumPartColumns
158 );
159 
169 CMR_EXPORT
171  CMR* cmr,
172  CMR_SEPA* sepa,
173  CMR_CHRMAT* matrix,
174  bool* pisTernary,
175  CMR_SUBMAT** pviolator
176 );
177 
188 CMR_EXPORT
190  CMR* cmr,
191  CMR_SEPA* sepa,
192  CMR_CHRMAT* matrix,
193  CMR_SUBMAT* submatrix,
194  bool* pisTernary,
195  CMR_SUBMAT** pviolator
196 );
197 
216 CMR_EXPORT
218  CMR* cmr,
219  size_t numMatrices,
220  CMR_CHRMAT** matrices,
221  CMR_CHRMAT** presult
222 );
223 
259 CMR_EXPORT
261  CMR* cmr,
262  CMR_CHRMAT* first,
263  CMR_CHRMAT* second,
264  size_t* firstSpecialRows,
265  size_t* firstSpecialColumns,
266  size_t* secondSpecialRows,
267  size_t* secondSpecialColumns,
268  int8_t characteristic,
269  CMR_CHRMAT** presult
270 );
271 
294 CMR_EXPORT
296  CMR* cmr,
297  CMR_CHRMAT* matrix,
298  CMR_SEPA* sepa,
299  CMR_CHRMAT** pfirst,
300  size_t* firstRowsOrigin,
302  size_t* firstColumnsOrigin,
304  size_t* rowsToFirst,
306  size_t* columnsToFirst,
308  size_t* firstSpecialRows,
310  size_t* firstSpecialColumns
312 );
313 
337 CMR_EXPORT
339  CMR* cmr,
340  CMR_CHRMAT* matrix,
341  CMR_SEPA* sepa,
342  CMR_CHRMAT** psecond,
343  size_t* secondRowsOrigin,
345  size_t* secondColumnsOrigin,
347  size_t* rowsToSecond,
349  size_t* columnsToSecond,
351  size_t* secondSpecialRows,
353  size_t* secondSpecialColumns
355 );
356 
393 CMR_EXPORT
395  CMR* cmr,
396  CMR_CHRMAT* first,
397  CMR_CHRMAT* second,
398  size_t* firstSpecialRows,
401  size_t* firstSpecialColumns,
405  size_t* secondSpecialRows,
408  size_t* secondSpecialColumns,
412  int8_t characteristic,
413  CMR_CHRMAT** presult
414 );
415 
435 CMR_EXPORT
437  CMR* cmr,
438  CMR_CHRMAT* matrix,
439  CMR_CHRMAT* transpose,
440  CMR_SEPA* sepa,
441  char* pepsilon
442 );
443 
466 CMR_EXPORT
468  CMR* cmr,
469  CMR_CHRMAT* matrix,
470  CMR_SEPA* sepa,
471  char epsilon,
472  CMR_CHRMAT** pfirst,
473  size_t* firstRowsOrigin,
475  size_t* firstColumnsOrigin,
477  size_t* rowsToFirst,
479  size_t* columnsToFirst,
481  size_t* firstSpecialRows,
484  size_t* firstSpecialColumns
488 );
489 
513 CMR_EXPORT
515  CMR* cmr,
516  CMR_CHRMAT* matrix,
517  CMR_SEPA* sepa,
518  char epsilon,
519  CMR_CHRMAT** psecond,
520  size_t* secondRowsOrigin,
522  size_t* secondColumnsOrigin,
524  size_t* rowsToSecond,
526  size_t* columnsToSecond,
528  size_t* secondSpecialRows,
531  size_t* secondSpecialColumns
535 );
536 
593 CMR_EXPORT
595  CMR* cmr,
596  CMR_CHRMAT* first,
597  CMR_CHRMAT* second,
598  size_t* firstSpecialRows,
599  size_t* firstSpecialColumns,
600  size_t* secondSpecialRows,
601  size_t* secondSpecialColumns,
602  int8_t characteristic,
603  CMR_CHRMAT** presult
604 );
605 
606 
646 CMR_EXPORT
648  CMR* cmr,
649  CMR_CHRMAT* matrix,
650  CMR_CHRMAT* transpose,
651  CMR_SEPA* sepa,
652  size_t* specialRows,
653  size_t* specialColumns,
655  char* pgamma,
656  char* pbeta
657 );
658 
659 
703 CMR_EXPORT
705  CMR* cmr,
706  CMR_CHRMAT* matrix,
707  CMR_SEPA* sepa,
708  size_t* specialRows,
709  size_t* specialColumns,
710  char beta,
711  CMR_CHRMAT** pfirst,
712  size_t* firstRowsOrigin,
714  size_t* firstColumnsOrigin,
716  size_t* rowsToFirst,
718  size_t* columnsToFirst,
720  size_t* firstSpecialRows,
722  size_t* firstSpecialColumns
725 );
726 
771 CMR_EXPORT
773  CMR* cmr,
774  CMR_CHRMAT* matrix,
775  CMR_SEPA* sepa,
776  size_t* specialRows,
777  size_t* specialColumns,
779  char gamma,
780  CMR_CHRMAT** psecond,
781  size_t* secondRowsOrigin,
783  size_t* secondColumnsOrigin,
785  size_t* rowsToSecond,
787  size_t* columnsToSecond,
789  size_t* secondSpecialRows,
791  size_t* secondSpecialColumns
793 );
794 
795 #ifdef __cplusplus
796 }
797 #endif
798 
799 #endif /* CMR_SEPARATION_H */
Functionality for the row and column elements of a matrix.
Basic functionality of the software library.
CMR_ERROR
Type for return codes of library functions.
Definition: env.h:32
Functionality for sparse matrices.
CMR_EXPORT CMR_ERROR CMRtwoSumCompose(CMR *cmr, CMR_CHRMAT *first, CMR_CHRMAT *second, size_t *firstSpecialRows, size_t *firstSpecialColumns, size_t *secondSpecialRows, size_t *secondSpecialColumns, int8_t characteristic, CMR_CHRMAT **presult)
Composes the 2-sum of the two matrices first and second with connecting elements firstMarker and seco...
Definition: separation.c:1033
CMR_EXPORT CMR_ERROR CMRtwoSumDecomposeSecond(CMR *cmr, CMR_CHRMAT *matrix, CMR_SEPA *sepa, CMR_CHRMAT **psecond, size_t *secondRowsOrigin, size_t *secondColumnsOrigin, size_t *rowsToSecond, size_t *columnsToSecond, size_t *secondSpecialRows, size_t *secondSpecialColumns)
Decomposes matrix as a 2-sum according to the 2-separation sepa, computing the second component.
Definition: separation.c:1399
CMR_EXPORT CMR_ERROR CMRthreeSumTruemperCompose(CMR *cmr, CMR_CHRMAT *first, CMR_CHRMAT *second, size_t *firstSpecialRows, size_t *firstSpecialColumns, size_t *secondSpecialRows, size_t *secondSpecialColumns, int8_t characteristic, CMR_CHRMAT **presult)
Constructs the Truemper 3-sum of the two matrices first and second at connecting rows firstSpecialRow...
Definition: separation.c:2399
CMR_EXPORT CMR_ERROR CMRsepaGetProjection(CMR_SEPA *sepa, size_t part, size_t *rowsToPart, size_t *columnsToPart, size_t *pnumPartRows, size_t *pnumPartColumns)
Creates mappings from rows/columns to those of part; also maps up to 3 representative rows/columns.
Definition: separation.c:721
CMR_EXPORT CMR_ERROR CMRsepaCheckTernarySubmatrix(CMR *cmr, CMR_SEPA *sepa, CMR_CHRMAT *matrix, CMR_SUBMAT *submatrix, bool *pisTernary, CMR_SUBMAT **pviolator)
Checks for a submatrix of a given matrix whether the binary k-separation is also a ternary one.
Definition: separation.c:955
CMR_EXPORT CMR_ERROR CMRoneSumCompose(CMR *cmr, size_t numMatrices, CMR_CHRMAT **matrices, CMR_CHRMAT **presult)
Composes the 1-sum of the several matrices.
Definition: separation.c:983
CMR_SEPA_TYPE
Definition: separation.h:42
@ CMR_SEPA_TYPE_TWO
Definition: separation.h:43
@ CMR_SEPA_TYPE_THREE_DISTRIBUTED_RANKS
Definition: separation.h:45
@ CMR_SEPA_TYPE_THREE_CONCENTRATED_RANK
Definition: separation.h:47
CMR_EXPORT CMR_ERROR CMRtwoSumDecomposeFirst(CMR *cmr, CMR_CHRMAT *matrix, CMR_SEPA *sepa, CMR_CHRMAT **pfirst, size_t *firstRowsOrigin, size_t *firstColumnsOrigin, size_t *rowsToFirst, size_t *columnsToFirst, size_t *firstSpecialRows, size_t *firstSpecialColumns)
Decomposes matrix as a 2-sum according to the 2-separation sepa, computing the first component.
Definition: separation.c:1249
CMR_EXPORT CMR_ERROR CMRsepaComputeSizes(CMR_SEPA *sepa, size_t *pnumRowsTopLeft, size_t *pnumColumnsTopLeft, size_t *pnumRowsBottomRight, size_t *pnumColumnsBottomRight)
Computes the sizes of the top-left and bottom-right parts.
Definition: separation.c:48
CMR_EXPORT CMR_ERROR CMRsepaFindBinaryRepresentatives(CMR *cmr, CMR_SEPA *sepa, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, bool *pswapped, CMR_SUBMAT **pviolator)
Scans the support of matrix to compute all representative rows/columns for sepa and sets the type.
Definition: separation.c:630
CMR_EXPORT CMR_ERROR CMRthreeSumSeymourCompose(CMR *cmr, CMR_CHRMAT *first, CMR_CHRMAT *second, size_t *firstSpecialRows, size_t *firstSpecialColumns, size_t *secondSpecialRows, size_t *secondSpecialColumns, int8_t characteristic, CMR_CHRMAT **presult)
Constructs the Seymour 3-sum of the two matrices first and second.
Definition: separation.c:1575
CMR_EXPORT CMR_ERROR CMRsepaFree(CMR *cmr, CMR_SEPA **psepa)
Frees a separation.
Definition: separation.c:32
CMR_SEPA_FLAGS
Definition: separation.h:24
@ CMR_SEPA_SECOND
Definition: separation.h:27
@ CMR_SEPA_MASK_EXTRA
Definition: separation.h:37
@ CMR_SEPA_FIRST
Definition: separation.h:25
@ CMR_SEPA_FLAG_RANK2
Definition: separation.h:31
@ CMR_SEPA_FLAG_RANK1
Definition: separation.h:29
@ CMR_SEPA_MASK_CHILD
Definition: separation.h:35
CMR_EXPORT CMR_ERROR CMRthreeSumTruemperDecomposeSecond(CMR *cmr, CMR_CHRMAT *matrix, CMR_SEPA *sepa, size_t *specialRows, size_t *specialColumns, char gamma, CMR_CHRMAT **psecond, size_t *secondRowsOrigin, size_t *secondColumnsOrigin, size_t *rowsToSecond, size_t *columnsToSecond, size_t *secondSpecialRows, size_t *secondSpecialColumns)
Decomposes matrix as a Truemper 3-sum according to the 3-separation sepa, computing the second compon...
Definition: separation.c:3351
CMR_EXPORT CMR_ERROR CMRthreeSumSeymourDecomposeFirst(CMR *cmr, CMR_CHRMAT *matrix, CMR_SEPA *sepa, char epsilon, CMR_CHRMAT **pfirst, size_t *firstRowsOrigin, size_t *firstColumnsOrigin, size_t *rowsToFirst, size_t *columnsToFirst, size_t *firstSpecialRows, size_t *firstSpecialColumns)
Decomposes matrix as a Seymour 3-sum according to the 3-separation sepa, computing the first componen...
Definition: separation.c:2064
CMR_EXPORT CMR_ERROR CMRsepaCreate(CMR *cmr, size_t numRows, size_t numColumns, CMR_SEPA **psepa)
Creates a 2- or 3-separation.
Definition: separation.c:14
CMR_EXPORT CMR_ERROR CMRthreeSumTruemperDecomposeFirst(CMR *cmr, CMR_CHRMAT *matrix, CMR_SEPA *sepa, size_t *specialRows, size_t *specialColumns, char beta, CMR_CHRMAT **pfirst, size_t *firstRowsOrigin, size_t *firstColumnsOrigin, size_t *rowsToFirst, size_t *columnsToFirst, size_t *firstSpecialRows, size_t *firstSpecialColumns)
Decomposes matrix as a Truemper 3-sum according to the 3-separation sepa, computing the first compone...
Definition: separation.c:3223
CMR_EXPORT CMR_ERROR CMRthreeSumSeymourDecomposeEpsilon(CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, CMR_SEPA *sepa, char *pepsilon)
Decomposes matrix as a Seymour 3-sum according to the 3-separation sepa, computing .
Definition: separation.c:1949
CMR_EXPORT CMR_ERROR CMRsepaFindBinaryRepresentativesSubmatrix(CMR *cmr, CMR_SEPA *sepa, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, CMR_SUBMAT *submatrix, bool *pswapped, CMR_SUBMAT **pviolator)
Scans the support of submatrix of matrix to compute all representative rows/columns for sepa and sets...
Definition: separation.c:655
CMR_EXPORT CMR_ERROR CMRthreeSumTruemperDecomposeConnecting(CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, CMR_SEPA *sepa, size_t *specialRows, size_t *specialColumns, char *pgamma, char *pbeta)
Decomposes matrix as a Truemper 3-sum according to the 3-separation sepa, computing the connecing mat...
Definition: separation.c:3209
CMR_EXPORT CMR_ERROR CMRsepaGetRepresentatives(CMR_SEPA *sepa, size_t reprRows[2][3], size_t reprColumns[2][3])
Returns representative rows/columns of the low-rank submatrices.
Definition: separation.c:674
CMR_EXPORT CMR_ERROR CMRthreeSumSeymourDecomposeSecond(CMR *cmr, CMR_CHRMAT *matrix, CMR_SEPA *sepa, char epsilon, CMR_CHRMAT **psecond, size_t *secondRowsOrigin, size_t *secondColumnsOrigin, size_t *rowsToSecond, size_t *columnsToSecond, size_t *secondSpecialRows, size_t *secondSpecialColumns)
Decomposes matrix as a Seymour 3-sum according to the 3-separation sepa, computing the second compone...
Definition: separation.c:2223
CMR_EXPORT CMR_ERROR CMRsepaCheckTernary(CMR *cmr, CMR_SEPA *sepa, CMR_CHRMAT *matrix, bool *pisTernary, CMR_SUBMAT **pviolator)
Checks for a given matrix whether the binary k-separation is also a ternary one.
Definition: separation.c:925
Row-wise representation of sparse char matrix.
Definition: matrix.h:220
Definition: env_internal.h:45
Definition: separation.h:52
int * columnsFlags
Array with each column's flags; logical OR of CMR_SEPA_TYPE.
Definition: separation.h:56
size_t numRows
Number of rows of the matrix.
Definition: separation.h:53
int * rowsFlags
Array with each row's flags; logical OR of CMR_SEPA_TYPE.
Definition: separation.h:55
size_t numColumns
Number of columns of the matrix.
Definition: separation.h:54
CMR_SEPA_TYPE type
Type of separation.
Definition: separation.h:57
Row and column indices for a submatrix.
Definition: matrix.h:28