Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:15:05

0001 /*
0002     Copyright (C) 2012 Fredrik Johansson
0003 
0004     This file is part of FLINT.
0005 
0006     FLINT is free software: you can redistribute it and/or modify it under
0007     the terms of the GNU Lesser General Public License (LGPL) as published
0008     by the Free Software Foundation; either version 3 of the License, or
0009     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
0010 */
0011 
0012 #ifndef ACB_MAT_H
0013 #define ACB_MAT_H
0014 
0015 #ifdef ACB_MAT_INLINES_C
0016 #define ACB_MAT_INLINE
0017 #else
0018 #define ACB_MAT_INLINE static inline
0019 #endif
0020 
0021 #include "fmpq_types.h"
0022 #include "acb_types.h"
0023 
0024 #ifdef __cplusplus
0025 extern "C" {
0026 #endif
0027 
0028 #define acb_mat_entry(mat,i,j) ((mat)->entries + (i) * (mat)->stride + (j))
0029 #define acb_mat_nrows(mat) ((mat)->r)
0030 #define acb_mat_ncols(mat) ((mat)->c)
0031 
0032 ACB_MAT_INLINE acb_ptr
0033 acb_mat_entry_ptr(acb_mat_t mat, slong i, slong j)
0034 {
0035     return acb_mat_entry(mat, i, j);
0036 }
0037 
0038 /* Memory management */
0039 
0040 void acb_mat_init(acb_mat_t mat, slong r, slong c);
0041 
0042 void acb_mat_clear(acb_mat_t mat);
0043 
0044 ACB_MAT_INLINE void
0045 acb_mat_swap(acb_mat_t mat1, acb_mat_t mat2)
0046 {
0047     FLINT_SWAP(acb_mat_struct, *mat1, *mat2);
0048 }
0049 
0050 void acb_mat_swap_entrywise(acb_mat_t mat1, acb_mat_t mat2);
0051 
0052 /* Window matrices */
0053 
0054 void acb_mat_window_init(acb_mat_t window, const acb_mat_t mat, slong r1, slong c1, slong r2, slong c2);
0055 
0056 ACB_MAT_INLINE void
0057 acb_mat_window_clear(acb_mat_t FLINT_UNUSED(window))
0058 {
0059 }
0060 
0061 /* Conversions */
0062 
0063 void acb_mat_set(acb_mat_t dest, const acb_mat_t src);
0064 
0065 void acb_mat_set_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src);
0066 
0067 void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, slong prec);
0068 
0069 void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, slong prec);
0070 
0071 void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src);
0072 
0073 void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, slong prec);
0074 
0075 void acb_mat_get_real(arb_mat_t re, const acb_mat_t mat);
0076 
0077 void acb_mat_get_imag(arb_mat_t im, const acb_mat_t mat);
0078 
0079 void acb_mat_set_real_imag(acb_mat_t mat, const arb_mat_t re, const arb_mat_t im);
0080 
0081 /* Random generation */
0082 
0083 void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, slong prec, slong mag_bits);
0084 
0085 void acb_mat_randtest_eig(acb_mat_t A, flint_rand_t state, acb_srcptr E, slong prec);
0086 
0087 /* I/O */
0088 
0089 #ifdef FLINT_HAVE_FILE
0090 void acb_mat_fprintd(FILE * file, const acb_mat_t mat, slong digits);
0091 #endif
0092 
0093 void acb_mat_printd(const acb_mat_t mat, slong digits);
0094 
0095 /* Comparisons */
0096 
0097 int acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2);
0098 
0099 int acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2);
0100 
0101 int acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2);
0102 
0103 int acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2);
0104 
0105 int acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2);
0106 
0107 int acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2);
0108 
0109 int acb_mat_contains_fmpz_mat(const acb_mat_t mat1, const fmpz_mat_t mat2);
0110 
0111 int acb_mat_is_real(const acb_mat_t mat);
0112 
0113 ACB_MAT_INLINE int
0114 acb_mat_is_empty(const acb_mat_t mat)
0115 {
0116     return (mat->r == 0) || (mat->c == 0);
0117 }
0118 
0119 ACB_MAT_INLINE int
0120 acb_mat_is_square(const acb_mat_t mat)
0121 {
0122     return (mat->r == mat->c);
0123 }
0124 
0125 int acb_mat_is_exact(const acb_mat_t mat);
0126 
0127 int acb_mat_is_zero(const acb_mat_t mat);
0128 int acb_mat_is_finite(const acb_mat_t mat);
0129 int acb_mat_is_triu(const acb_mat_t mat);
0130 int acb_mat_is_tril(const acb_mat_t mat);
0131 
0132 ACB_MAT_INLINE int
0133 acb_mat_is_diag(const acb_mat_t mat)
0134 {
0135     return acb_mat_is_tril(mat) && acb_mat_is_triu(mat);
0136 }
0137 
0138 /* Radius and interval operations */
0139 
0140 void acb_mat_get_mid(acb_mat_t B, const acb_mat_t A);
0141 
0142 void acb_mat_add_error_mag(acb_mat_t mat, const mag_t err);
0143 
0144 /* Special matrices */
0145 
0146 void acb_mat_zero(acb_mat_t mat);
0147 
0148 void acb_mat_one(acb_mat_t mat);
0149 
0150 void acb_mat_ones(acb_mat_t mat);
0151 
0152 void acb_mat_onei(acb_mat_t mat);
0153 
0154 void acb_mat_indeterminate(acb_mat_t mat);
0155 
0156 void acb_mat_dft(acb_mat_t res, int kind, slong prec);
0157 
0158 void acb_mat_transpose(acb_mat_t mat1, const acb_mat_t mat2);
0159 
0160 void acb_mat_conjugate(acb_mat_t mat1, const acb_mat_t mat2);
0161 
0162 ACB_MAT_INLINE void
0163 acb_mat_conjugate_transpose(acb_mat_t mat1, const acb_mat_t mat2)
0164 {
0165     acb_mat_transpose(mat1, mat2);
0166     acb_mat_conjugate(mat1, mat1);
0167 }
0168 
0169 /* Norms */
0170 
0171 void acb_mat_bound_inf_norm(mag_t b, const acb_mat_t A);
0172 
0173 void acb_mat_frobenius_norm(arb_t res, const acb_mat_t A, slong prec);
0174 
0175 void acb_mat_bound_frobenius_norm(mag_t b, const acb_mat_t A);
0176 
0177 /* Arithmetic */
0178 
0179 void acb_mat_neg(acb_mat_t dest, const acb_mat_t src);
0180 
0181 void acb_mat_add(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec);
0182 
0183 void acb_mat_sub(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec);
0184 
0185 void acb_mat_mul_classical(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec);
0186 void acb_mat_mul_threaded(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec);
0187 void acb_mat_mul_reorder(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec);
0188 void acb_mat_mul(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec);
0189 
0190 void acb_mat_mul_entrywise(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec);
0191 
0192 void acb_mat_sqr_classical(acb_mat_t res, const acb_mat_t mat, slong prec);
0193 void acb_mat_sqr(acb_mat_t res, const acb_mat_t mat, slong prec);
0194 
0195 void acb_mat_pow_ui(acb_mat_t B, const acb_mat_t A, ulong exp, slong prec);
0196 
0197 /* Scalar arithmetic */
0198 
0199 void acb_mat_scalar_mul_2exp_si(acb_mat_t B, const acb_mat_t A, slong c);
0200 
0201 void acb_mat_scalar_mul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec);
0202 void acb_mat_scalar_mul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec);
0203 void acb_mat_scalar_mul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec);
0204 void acb_mat_scalar_mul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec);
0205 
0206 void acb_mat_scalar_addmul_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec);
0207 void acb_mat_scalar_addmul_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec);
0208 void acb_mat_scalar_addmul_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec);
0209 void acb_mat_scalar_addmul_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec);
0210 
0211 void acb_mat_scalar_div_si(acb_mat_t B, const acb_mat_t A, slong c, slong prec);
0212 void acb_mat_scalar_div_fmpz(acb_mat_t B, const acb_mat_t A, const fmpz_t c, slong prec);
0213 void acb_mat_scalar_div_arb(acb_mat_t B, const acb_mat_t A, const arb_t c, slong prec);
0214 void acb_mat_scalar_div_acb(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec);
0215 
0216 /* Vector arithmetic */
0217 
0218 void _acb_mat_vector_mul_row(acb_ptr res, acb_srcptr v, const acb_mat_t A, slong prec);
0219 
0220 void _acb_mat_vector_mul_col(acb_ptr res, const acb_mat_t A, acb_srcptr v, slong prec);
0221 
0222 void acb_mat_vector_mul_row(acb_ptr res, acb_srcptr v, const acb_mat_t A, slong prec);
0223 
0224 void acb_mat_vector_mul_col(acb_ptr res, const acb_mat_t A, acb_srcptr v, slong prec);
0225 
0226 /* Solving */
0227 
0228 void acb_mat_swap_rows(acb_mat_t mat, slong * perm, slong r, slong s);
0229 
0230 slong acb_mat_find_pivot_partial(const acb_mat_t mat,
0231                                     slong start_row, slong end_row, slong c);
0232 
0233 void acb_mat_solve_tril_classical(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec);
0234 void acb_mat_solve_tril_recursive(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec);
0235 void acb_mat_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec);
0236 
0237 void acb_mat_solve_triu_classical(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec);
0238 void acb_mat_solve_triu_recursive(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec);
0239 void acb_mat_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec);
0240 
0241 int acb_mat_lu_classical(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec);
0242 int acb_mat_lu_recursive(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec);
0243 int acb_mat_lu(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec);
0244 
0245 void acb_mat_solve_lu_precomp(acb_mat_t X, const slong * perm,
0246     const acb_mat_t A, const acb_mat_t B, slong prec);
0247 
0248 int acb_mat_solve_lu(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec);
0249 
0250 int acb_mat_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec);
0251 
0252 int acb_mat_solve_precond(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec);
0253 
0254 void acb_mat_approx_mul(acb_mat_t C, const acb_mat_t A, const acb_mat_t B, slong prec);
0255 void acb_mat_approx_solve_triu(acb_mat_t X, const acb_mat_t U, const acb_mat_t B, int unit, slong prec);
0256 void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B, int unit, slong prec);
0257 int acb_mat_approx_lu(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec);
0258 void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t A, const acb_mat_t B, slong prec);
0259 int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec);
0260 int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, slong prec);
0261 
0262 int acb_mat_inv(acb_mat_t X, const acb_mat_t A, slong prec);
0263 
0264 void acb_mat_det_lu(acb_t det, const acb_mat_t A, slong prec);
0265 void acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec);
0266 void acb_mat_det(acb_t det, const acb_mat_t A, slong prec);
0267 
0268 /* Eigenvalues and eigenvectors */
0269 
0270 int acb_mat_approx_eig_qr(acb_ptr E, acb_mat_t L, acb_mat_t R, const acb_mat_t A, const mag_t tol, slong maxiter, slong prec);
0271 
0272 void acb_mat_eig_global_enclosure(mag_t eps, const acb_mat_t A, acb_srcptr E, const acb_mat_t R, slong prec);
0273 
0274 void acb_mat_eig_enclosure_rump(acb_t lambda, acb_mat_t J, acb_mat_t X, const acb_mat_t A,
0275     const acb_t lambda_approx, const acb_mat_t X_approx, slong prec);
0276 
0277 int acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R,
0278     const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec);
0279 int acb_mat_eig_simple_vdhoeven_mourrain(acb_ptr E, acb_mat_t L, acb_mat_t R,
0280     const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec);
0281 int acb_mat_eig_simple(acb_ptr E, acb_mat_t L, acb_mat_t R,
0282     const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec);
0283 
0284 int acb_mat_eig_multiple_rump(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec);
0285 int acb_mat_eig_multiple(acb_ptr E, const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec);
0286 
0287 /* Special functions */
0288 
0289 void acb_mat_exp_taylor_sum(acb_mat_t S, const acb_mat_t A, slong N, slong prec);
0290 
0291 void acb_mat_exp(acb_mat_t B, const acb_mat_t A, slong prec);
0292 
0293 void _acb_mat_charpoly(acb_ptr poly, const acb_mat_t mat, slong prec);
0294 void acb_mat_charpoly(acb_poly_t poly, const acb_mat_t mat, slong prec);
0295 void _acb_mat_companion(acb_mat_t mat, acb_srcptr poly, slong prec);
0296 void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, slong prec);
0297 
0298 void acb_mat_trace(acb_t trace, const acb_mat_t mat, slong prec);
0299 
0300 void _acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong a, slong b, slong prec);
0301 void acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong prec);
0302 
0303 slong acb_mat_allocated_bytes(const acb_mat_t x);
0304 
0305 #ifdef __cplusplus
0306 }
0307 #endif
0308 
0309 #endif