File indexing completed on 2026-11-07 10:15:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOL_MAT_H
0013 #define BOOL_MAT_H
0014
0015 #ifdef BOOL_MAT_INLINES_C
0016 #define BOOL_MAT_INLINE
0017 #else
0018 #define BOOL_MAT_INLINE static inline
0019 #endif
0020
0021 #include "fmpz_types.h"
0022
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026
0027 typedef struct
0028 {
0029 int *entries;
0030 slong r;
0031 slong c;
0032 int **rows;
0033 }
0034 bool_mat_struct;
0035
0036 typedef bool_mat_struct bool_mat_t[1];
0037
0038 #define bool_mat_nrows(mat) ((mat)->r)
0039 #define bool_mat_ncols(mat) ((mat)->c)
0040
0041 BOOL_MAT_INLINE int
0042 bool_mat_get_entry(const bool_mat_t mat, slong i, slong j)
0043 {
0044 return mat->rows[i][j];
0045 }
0046
0047 BOOL_MAT_INLINE void
0048 bool_mat_set_entry(bool_mat_t mat, slong i, slong j, int value)
0049 {
0050 mat->rows[i][j] = value;
0051 }
0052
0053
0054
0055 void bool_mat_init(bool_mat_t mat, slong r, slong c);
0056
0057 void bool_mat_clear(bool_mat_t mat);
0058
0059 BOOL_MAT_INLINE void
0060 bool_mat_swap(bool_mat_t mat1, bool_mat_t mat2)
0061 {
0062 FLINT_SWAP(bool_mat_struct, *mat1, *mat2);
0063 }
0064
0065
0066
0067 void bool_mat_set(bool_mat_t dest, const bool_mat_t src);
0068
0069
0070
0071 void bool_mat_randtest(bool_mat_t mat, flint_rand_t state);
0072
0073 void bool_mat_randtest_diagonal(bool_mat_t mat, flint_rand_t state);
0074
0075 void bool_mat_randtest_nilpotent(bool_mat_t mat, flint_rand_t state);
0076
0077
0078
0079 #ifdef FLINT_HAVE_FILE
0080 void bool_mat_fprint(FILE * file, const bool_mat_t mat);
0081 #endif
0082
0083 void bool_mat_print(const bool_mat_t mat);
0084
0085
0086
0087 int bool_mat_equal(const bool_mat_t mat1, const bool_mat_t mat2);
0088
0089 int bool_mat_any(const bool_mat_t mat);
0090
0091 int bool_mat_all(const bool_mat_t mat);
0092
0093 int bool_mat_is_diagonal(const bool_mat_t mat);
0094
0095 int bool_mat_is_lower_triangular(const bool_mat_t mat);
0096
0097 int bool_mat_is_transitive(const bool_mat_t mat);
0098
0099 int bool_mat_is_nilpotent(const bool_mat_t mat);
0100
0101 BOOL_MAT_INLINE int
0102 bool_mat_is_empty(const bool_mat_t mat)
0103 {
0104 return (mat->r == 0) || (mat->c == 0);
0105 }
0106
0107 BOOL_MAT_INLINE int
0108 bool_mat_is_square(const bool_mat_t mat)
0109 {
0110 return (mat->r == mat->c);
0111 }
0112
0113
0114
0115 void bool_mat_zero(bool_mat_t mat);
0116
0117 void bool_mat_one(bool_mat_t mat);
0118
0119 void bool_mat_directed_path(bool_mat_t mat);
0120
0121 void bool_mat_directed_cycle(bool_mat_t mat);
0122
0123
0124
0125 void bool_mat_transpose(bool_mat_t mat1, const bool_mat_t mat2);
0126
0127
0128
0129 void bool_mat_complement(bool_mat_t mat1, const bool_mat_t mat2);
0130
0131 void bool_mat_add(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2);
0132
0133 void bool_mat_mul(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2);
0134
0135 void bool_mat_mul_entrywise(bool_mat_t res, const bool_mat_t mat1, const bool_mat_t mat2);
0136
0137 void bool_mat_pow_ui(bool_mat_t B, const bool_mat_t A, ulong exp);
0138
0139 BOOL_MAT_INLINE void
0140 bool_mat_sqr(bool_mat_t B, const bool_mat_t A)
0141 {
0142 bool_mat_mul(B, A, A);
0143 }
0144
0145
0146
0147 int bool_mat_trace(const bool_mat_t mat);
0148
0149 slong bool_mat_nilpotency_degree(const bool_mat_t mat);
0150
0151 void bool_mat_transitive_closure(bool_mat_t dest, const bool_mat_t src);
0152
0153 slong bool_mat_get_strongly_connected_components(slong *partition, const bool_mat_t A);
0154
0155 slong bool_mat_all_pairs_longest_walk(fmpz_mat_t B, const bool_mat_t A);
0156
0157 #ifdef __cplusplus
0158 }
0159 #endif
0160
0161 #endif