File indexing completed on 2026-11-07 10:15:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef D_MAT_H
0015 #define D_MAT_H
0016
0017 #ifdef D_MAT_INLINES_C
0018 #define D_MAT_INLINE
0019 #else
0020 #define D_MAT_INLINE static inline
0021 #endif
0022
0023 #include "flint.h"
0024
0025 #ifdef __cplusplus
0026 extern "C" {
0027 #endif
0028
0029 typedef struct
0030 {
0031 double * entries;
0032 slong r;
0033 slong c;
0034 double ** rows;
0035 } d_mat_struct;
0036
0037 typedef d_mat_struct d_mat_t[1];
0038
0039 #define d_mat_entry(mat,i,j) (*((mat)->rows[i] + (j)))
0040
0041 D_MAT_INLINE
0042 slong d_mat_nrows(const d_mat_t mat)
0043 {
0044 return mat->r;
0045 }
0046
0047 D_MAT_INLINE
0048 slong d_mat_ncols(const d_mat_t mat)
0049 {
0050 return mat->c;
0051 }
0052
0053
0054
0055 void d_mat_init(d_mat_t mat, slong rows, slong cols);
0056
0057 D_MAT_INLINE void
0058 d_mat_swap_entrywise(d_mat_t mat1, d_mat_t mat2)
0059 {
0060 slong i, j;
0061 for (i = 0; i < d_mat_nrows(mat1); i++)
0062 {
0063 double * row1 = mat1->rows[i];
0064 double * row2 = mat2->rows[i];
0065 for (j = 0; j < d_mat_ncols(mat1); j++)
0066 FLINT_SWAP(double, row1[j], row2[j]);
0067 }
0068 }
0069
0070 void d_mat_set(d_mat_t mat1, const d_mat_t mat2);
0071
0072 void d_mat_clear(d_mat_t mat);
0073
0074 int d_mat_equal(const d_mat_t mat1, const d_mat_t mat2);
0075
0076 int d_mat_approx_equal(const d_mat_t mat1, const d_mat_t mat2, double eps);
0077
0078 D_MAT_INLINE
0079 int d_mat_is_square(const d_mat_t mat)
0080 {
0081 return (mat->r == mat->c);
0082 }
0083
0084 void d_mat_zero(d_mat_t mat);
0085
0086
0087
0088 void d_mat_print(const d_mat_t mat);
0089
0090
0091
0092 void d_mat_randtest(d_mat_t mat, flint_rand_t state, slong minexp, slong maxexp);
0093
0094
0095
0096 void d_mat_transpose(d_mat_t B, const d_mat_t A);
0097
0098
0099
0100 void d_mat_mul_classical(d_mat_t C, const d_mat_t A, const d_mat_t B);
0101
0102 #ifdef __cplusplus
0103 }
0104 #endif
0105
0106 #endif