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 
394 CMR_EXPORT
396  CMR* cmr,
397  CMR_CHRMAT* first,
398  CMR_CHRMAT* second,
399  size_t* firstSpecialRows,
402  size_t* firstSpecialColumns,
406  size_t* secondSpecialRows,
409  size_t* secondSpecialColumns,
413  int8_t characteristic,
414  CMR_CHRMAT** presult
415 );
416 
436 CMR_EXPORT
438  CMR* cmr,
439  CMR_CHRMAT* matrix,
440  CMR_CHRMAT* transpose,
441  CMR_SEPA* sepa,
442  char* pepsilon
443 );
444 
467 CMR_EXPORT
469  CMR* cmr,
470  CMR_CHRMAT* matrix,
471  CMR_SEPA* sepa,
472  char epsilon,
473  CMR_CHRMAT** pfirst,
474  size_t* firstRowsOrigin,
476  size_t* firstColumnsOrigin,
478  size_t* rowsToFirst,
480  size_t* columnsToFirst,
482  size_t* firstSpecialRows,
485  size_t* firstSpecialColumns
489 );
490 
514 CMR_EXPORT
516  CMR* cmr,
517  CMR_CHRMAT* matrix,
518  CMR_SEPA* sepa,
519  char epsilon,
520  CMR_CHRMAT** psecond,
521  size_t* secondRowsOrigin,
523  size_t* secondColumnsOrigin,
525  size_t* rowsToSecond,
527  size_t* columnsToSecond,
529  size_t* secondSpecialRows,
532  size_t* secondSpecialColumns
536 );
537 
594 CMR_EXPORT
596  CMR* cmr,
597  CMR_CHRMAT* first,
598  CMR_CHRMAT* second,
599  size_t* firstSpecialRows,
600  size_t* firstSpecialColumns,
601  size_t* secondSpecialRows,
602  size_t* secondSpecialColumns,
603  int8_t characteristic,
604  CMR_CHRMAT** presult
605 );
606 
607 
647 CMR_EXPORT
649  CMR* cmr,
650  CMR_CHRMAT* matrix,
651  CMR_CHRMAT* transpose,
652  CMR_SEPA* sepa,
653  size_t* specialRows,
654  size_t* specialColumns,
656  char* pgamma,
657  char* pbeta
658 );
659 
660 
704 CMR_EXPORT
706  CMR* cmr,
707  CMR_CHRMAT* matrix,
708  CMR_SEPA* sepa,
709  size_t* specialRows,
710  size_t* specialColumns,
711  char beta,
712  CMR_CHRMAT** pfirst,
713  size_t* firstRowsOrigin,
715  size_t* firstColumnsOrigin,
717  size_t* rowsToFirst,
719  size_t* columnsToFirst,
721  size_t* firstSpecialRows,
723  size_t* firstSpecialColumns
726 );
727 
772 CMR_EXPORT
774  CMR* cmr,
775  CMR_CHRMAT* matrix,
776  CMR_SEPA* sepa,
777  size_t* specialRows,
778  size_t* specialColumns,
780  char gamma,
781  CMR_CHRMAT** psecond,
782  size_t* secondRowsOrigin,
784  size_t* secondColumnsOrigin,
786  size_t* rowsToSecond,
788  size_t* columnsToSecond,
790  size_t* secondSpecialRows,
792  size_t* secondSpecialColumns
794 );
795 
796 #ifdef __cplusplus
797 }
798 #endif
799 
800 #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:1032
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:1398
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:2386
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:720
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:954
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:982
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:1248
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:47
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:629
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 via firstMarker1,...
Definition: separation.c:1574
CMR_EXPORT CMR_ERROR CMRsepaFree(CMR *cmr, CMR_SEPA **psepa)
Frees a separation.
Definition: separation.c:31
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:3277
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:2051
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:13
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:3149
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:1936
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:654
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:3135
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:673
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:2210
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:924
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