diff --git a/src/arith/test/t-stirling.c b/src/arith/test/t-stirling.c
index 0dc13dade0..2ef0cfb2d3 100644
--- a/src/arith/test/t-stirling.c
+++ b/src/arith/test/t-stirling.c
@@ -155,12 +155,12 @@ TEST_FUNCTION_START(arith_stirling, state)
{
row = _fmpz_vec_init(k);
arith_stirling_number_1u_vec(row, n, k);
- if (!_fmpz_vec_equal(row, mat->rows[n], k))
+ if (!_fmpz_vec_equal(row, fmpz_mat_row(mat, n), k))
{
flint_printf("stirling1u mat != vec ");
flint_printf("nn,n,k=%wd,%wd,%wd\n", nn, n, k);
flint_printf("mat: ");
- _fmpz_vec_print(mat->rows[n], k);
+ _fmpz_vec_print(fmpz_mat_row(mat, n), k);
flint_printf("\nvec: ");
_fmpz_vec_print(row, k);
fflush(stdout);
@@ -169,12 +169,12 @@ TEST_FUNCTION_START(arith_stirling, state)
_fmpz_vec_clear(row, k);
arith_stirling_number_1u(s, n, k);
- if (!fmpz_equal(mat->rows[n]+k, s))
+ if (!fmpz_equal(fmpz_mat_row(mat, n)+k, s))
{
flint_printf("stirling1u mat != single ");
flint_printf("nn,n,k=%wd,%wd,%wd\n", nn, n, k);
flint_printf("mat: ");
- fmpz_print(mat->rows[n]+k);
+ fmpz_print(fmpz_mat_row(mat, n)+k);
flint_printf("\nsingle: ");
fmpz_print(s);
fflush(stdout);
@@ -198,12 +198,12 @@ TEST_FUNCTION_START(arith_stirling, state)
{
row = _fmpz_vec_init(k);
arith_stirling_number_1_vec(row, n, k);
- if (!_fmpz_vec_equal(row, mat->rows[n], k))
+ if (!_fmpz_vec_equal(row, fmpz_mat_row(mat, n), k))
{
flint_printf("stirling1 mat != vec ");
flint_printf("nn,n,k=%wd,%wd,%wd\n", nn, n, k);
flint_printf("mat: ");
- _fmpz_vec_print(mat->rows[n], k);
+ _fmpz_vec_print(fmpz_mat_row(mat, n), k);
flint_printf("\nvec: ");
_fmpz_vec_print(row, k);
fflush(stdout);
@@ -212,12 +212,12 @@ TEST_FUNCTION_START(arith_stirling, state)
_fmpz_vec_clear(row, k);
arith_stirling_number_1(s, n, k);
- if (!fmpz_equal(mat->rows[n]+k, s))
+ if (!fmpz_equal(fmpz_mat_row(mat, n)+k, s))
{
flint_printf("stirling1 mat != single ");
flint_printf("nn,n,k=%wd,%wd,%wd\n", nn, n, k);
flint_printf("mat: ");
- fmpz_print(mat->rows[n]+k);
+ fmpz_print(fmpz_mat_row(mat, n)+k);
flint_printf("\nsingle: ");
fmpz_print(s);
fflush(stdout);
@@ -241,12 +241,12 @@ TEST_FUNCTION_START(arith_stirling, state)
{
row = _fmpz_vec_init(k);
arith_stirling_number_2_vec(row, n, k);
- if (!_fmpz_vec_equal(row, mat->rows[n], k))
+ if (!_fmpz_vec_equal(row, fmpz_mat_row(mat, n), k))
{
flint_printf("stirling2 mat != vec ");
flint_printf("nn,n,k=%wd,%wd,%wd\n", nn, n, k);
flint_printf("mat: ");
- _fmpz_vec_print(mat->rows[n], k);
+ _fmpz_vec_print(fmpz_mat_row(mat, n), k);
flint_printf("\nvec: ");
_fmpz_vec_print(row, k);
fflush(stdout);
@@ -255,12 +255,12 @@ TEST_FUNCTION_START(arith_stirling, state)
_fmpz_vec_clear(row, k);
arith_stirling_number_2(s, n, k);
- if (!fmpz_equal(mat->rows[n]+k, s))
+ if (!fmpz_equal(fmpz_mat_row(mat, n)+k, s))
{
flint_printf("stirling2 mat != single ");
flint_printf("nn,n,k=%wd,%wd,%wd\n", nn, n, k);
flint_printf("mat: ");
- fmpz_print(mat->rows[n]+k);
+ fmpz_print(fmpz_mat_row(mat, n)+k);
flint_printf("\nsingle: ");
fmpz_print(s);
fflush(stdout);
@@ -289,7 +289,7 @@ TEST_FUNCTION_START(arith_stirling, state)
{
for (k = 0; k < nn; k++)
{
- if (fmpz_get_ui(mat3->rows[n]+k) != (n == k))
+ if (fmpz_get_ui(fmpz_mat_row(mat3, n)+k) != (n == k))
{
flint_printf("not identity matrix: %wd, %wd, %wd\n", nn, n, k);
fflush(stdout);
diff --git a/src/fmpz_mat/mul_blas.c b/src/fmpz_mat/mul_blas.c
index ea2b39d741..2e809128c9 100644
--- a/src/fmpz_mat/mul_blas.c
+++ b/src/fmpz_mat/mul_blas.c
@@ -32,8 +32,10 @@ typedef struct {
slong Astoprow;
slong Bstartrow;
slong Bstoprow;
- fmpz ** Arows;
- fmpz ** Brows;
+ fmpz * Aentries;
+ slong Astride;
+ fmpz * Bentries;
+ slong Bstride;
double * dA;
double * dB;
} _red_worker_arg;
@@ -48,18 +50,20 @@ static void _red_worker(void * varg)
slong Astoprow = arg->Astoprow;
slong Bstartrow = arg->Bstartrow;
slong Bstoprow = arg->Bstoprow;
- fmpz ** Arows = arg->Arows;
- fmpz ** Brows = arg->Brows;
+ fmpz * Aentries = arg->Aentries;
+ slong Astride;
+ fmpz * Bentries = arg->Bentries;
+ slong Bstride;
double * dA = arg->dA;
double * dB = arg->dB;
for (i = Astartrow; i < Astoprow; i++)
for (j = 0; j < k; j++)
- dA[k*i + j] = (double)(Arows[i][j]);
+ dA[k*i + j] = (double)(Aentries[i * Astride + j]);
for (i = Bstartrow; i < Bstoprow; i++)
for (j = 0; j < n; j++)
- dB[n*i + j] = (double)(Brows[i][j]);
+ dB[n*i + j] = (double)(Bentries[i * Bstride + j]);
}
static int _fmpz_mat_mul_blas_direct(
@@ -85,8 +89,10 @@ static int _fmpz_mat_mul_blas_direct(
mainarg.m = m = A->r;
mainarg.k = k = A->c;
mainarg.n = n = B->c;
- mainarg.Arows = A->rows;
- mainarg.Brows = B->rows;
+ mainarg.Aentries = A->entries;
+ mainarg.Astride = A->stride;
+ mainarg.Bentries = B->entries;
+ mainarg.Bstride = B->stride;
mainarg.dA = dA;
mainarg.dB = dB;
@@ -140,7 +146,7 @@ static int _fmpz_mat_mul_blas_direct(
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
- fmpz_set_si(&C->rows[i][j], (slong)(dC[n*i + j]));
+ fmpz_set_si(fmpz_mat_entry(C, i, j), (slong)(dC[n*i + j]));
flint_free(dA);
flint_free(dB);
@@ -255,9 +261,12 @@ typedef struct {
double * dA;
double * dB;
double * dC;
- fmpz ** Arows;
- fmpz ** Brows;
- fmpz ** Crows;
+ fmpz * Aentries;
+ slong Astride;
+ fmpz * Bentries;
+ slong Bstride;
+ fmpz * Centries;
+ slong Cstride;
const fmpz_comb_struct * comb;
int sign;
} _worker_arg;
@@ -275,8 +284,10 @@ static void _mod_worker(void * arg_ptr)
slong Bstoprow = arg->Bstoprow;
uint32_t * bigA = arg->bigA;
uint32_t * bigB = arg->bigB;
- fmpz ** Arows = arg->Arows;
- fmpz ** Brows = arg->Brows;
+ fmpz * Aentries = arg->Aentries;
+ slong Astride = arg->Astride;
+ fmpz * Bentries = arg->Bentries;
+ slong Bstride = arg->Bstride;
const fmpz_comb_struct * comb = arg->comb;
fmpz_comb_temp_t comb_temp;
@@ -285,12 +296,12 @@ static void _mod_worker(void * arg_ptr)
for (i = Astartrow; i < Astoprow; i++)
for (j = 0; j < k; j++)
fmpz_multi_mod_uint32_stride(bigA + i*k*num_primes + j, k,
- &Arows[i][j], comb, comb_temp);
+ Aentries + i * Astride + j, comb, comb_temp);
for (i = Bstartrow; i < Bstoprow; i++)
for (j = 0; j < n; j++)
fmpz_multi_mod_uint32_stride(bigB + i*n*num_primes + j, n,
- &Brows[i][j], comb, comb_temp);
+ Bentries + i * Bstride + j, comb, comb_temp);
fmpz_comb_temp_clear(comb_temp);
}
@@ -360,7 +371,8 @@ void _crt_worker(void * arg_ptr)
slong Cstartrow = arg->Cstartrow;
slong Cstoprow = arg->Cstoprow;
uint32_t * bigC = arg->bigC;
- fmpz ** Crows = arg->Crows;
+ fmpz * Centries = arg->Centries;
+ slong Cstride = arg->Cstride;
const fmpz_comb_struct * comb = arg->comb;
fmpz_comb_temp_t comb_temp;
ulong * r;
@@ -376,7 +388,7 @@ void _crt_worker(void * arg_ptr)
for (k = 0; k < num_primes; k++)
r[k] = bigC[(i*num_primes + k)*n + j];
- fmpz_multi_CRT_ui(&Crows[i][j], r, comb, comb_temp, sign);
+ fmpz_multi_CRT_ui(Centries + i * Cstride + j, r, comb, comb_temp, sign);
}
}
@@ -510,9 +522,12 @@ int _fmpz_mat_mul_blas(
args[i].bigA = bigA;
args[i].bigB = bigB;
args[i].bigC = bigC;
- args[i].Arows = A->rows;
- args[i].Brows = B->rows;
- args[i].Crows = C->rows;
+ args[i].Aentries = A->entries;
+ args[i].Astride = A->stride;
+ args[i].Bentries = B->entries;
+ args[i].Bstride = B->stride;
+ args[i].Centries = C->entries;
+ args[i].Cstride = C->stride;
args[i].dA = dA;
args[i].dB = dB;
args[i].dC = dC;
diff --git a/src/fmpz_mat/test/t-col_partition.c b/src/fmpz_mat/test/t-col_partition.c
index dacdab24ed..47c579ccb0 100644
--- a/src/fmpz_mat/test/t-col_partition.c
+++ b/src/fmpz_mat/test/t-col_partition.c
@@ -34,9 +34,9 @@ TEST_FUNCTION_START(fmpz_mat_col_partition, state)
/* set first row */
for (j = 0; j < n; j++)
- fmpz_randtest(A->rows[0] + j, state, 100);
+ fmpz_randtest(fmpz_mat_entry(A, 0, j), state, 100);
/* ensure row is distinct */
- fmpz_set_ui(A->rows[0] + n_randint(state, n), 0);
+ fmpz_set_ui(fmpz_mat_entry(A, 0, n_randint(state, n)), 0);
/* fill remaining rows */
for (k = 1; k < m; k++)
@@ -45,15 +45,15 @@ TEST_FUNCTION_START(fmpz_mat_col_partition, state)
{
/* random row */
for (j = 0; j < n; j++)
- fmpz_randtest(A->rows[k] + j, state, 100);
+ fmpz_randtest(fmpz_mat_entry(A, k, j), state, 100);
/* ensure row is distinct */
- fmpz_set_ui(A->rows[k] + n_randint(state, n), k);
+ fmpz_set_ui(fmpz_mat_entry(A, k, n_randint(state, n)), k);
p1++;
} else
{
/* same as last row */
for (j = 0; j < n; j++)
- fmpz_set(A->rows[k] + j, A->rows[k - 1] + j);
+ fmpz_set(fmpz_mat_entry(A, k, j), fmpz_mat_entry(A, k - 1, j));
}
}
@@ -62,9 +62,7 @@ TEST_FUNCTION_START(fmpz_mat_col_partition, state)
{
slong r1 = n_randint(state, m);
slong r2 = n_randint(state, m);
- fmpz * t = A->rows[r1];
- A->rows[r1] = A->rows[r2];
- A->rows[r2] = t;
+ fmpz_mat_swap_rows(A, NULL, r1, r2);
}
/* transpose so rows are now columns */
diff --git a/src/fmpz_mat/test/t-howell_form_mod.c b/src/fmpz_mat/test/t-howell_form_mod.c
index d8da6f2e6a..1afb86dfb5 100644
--- a/src/fmpz_mat/test/t-howell_form_mod.c
+++ b/src/fmpz_mat/test/t-howell_form_mod.c
@@ -106,7 +106,7 @@ fmpz_mat_mod_is_in_howell_form(const fmpz_mat_t A, const fmpz_t mod)
{
fmpz_gcd(g, mod, fmpz_mat_entry(A, i, pivots[i]));
fmpz_divexact(g, mod, g);
- _fmpz_vec_scalar_mul_fmpz(extra_row, A->rows[i], A->c, g);
+ _fmpz_vec_scalar_mul_fmpz(extra_row, fmpz_mat_row(A, i), A->c, g);
_fmpz_vec_scalar_mod_fmpz(extra_row, extra_row, A->c, mod);
for ( j = pivots[i] + 1; j < A->c; j++)
@@ -121,7 +121,7 @@ fmpz_mat_mod_is_in_howell_form(const fmpz_mat_t A, const fmpz_t mod)
{
fmpz_divexact(g, extra_row + j, fmpz_mat_entry(A, r, pivots[r]));
fmpz_neg(g, g);
- _fmpz_vec_scalar_addmul_fmpz(extra_row, A->rows[r], A->c, g);
+ _fmpz_vec_scalar_addmul_fmpz(extra_row, fmpz_mat_row(A, r), A->c, g);
}
}
}
diff --git a/src/fmpz_mat/test/t-init_clear.c b/src/fmpz_mat/test/t-init_clear.c
index 6bd883de81..ea42b0a627 100644
--- a/src/fmpz_mat/test/t-init_clear.c
+++ b/src/fmpz_mat/test/t-init_clear.c
@@ -28,7 +28,7 @@ TEST_FUNCTION_START(fmpz_mat_init_clear, state)
for (j = 0; j < rows; j++)
for (k = 0; k < cols; k++)
- fmpz_zero(a->rows[j] + k);
+ fmpz_zero(fmpz_mat_entry(a, j, k));
fmpz_mat_clear(a);
}
diff --git a/src/fmpz_mat/test/t-inv.c b/src/fmpz_mat/test/t-inv.c
index 4f4eacc2e2..6910b7347b 100644
--- a/src/fmpz_mat/test/t-inv.c
+++ b/src/fmpz_mat/test/t-inv.c
@@ -18,7 +18,7 @@ TEST_FUNCTION_START(fmpz_mat_inv, state)
{
fmpz_mat_t A, B, C, I;
fmpz_t den;
- slong i, j, m, r;
+ slong i, m, r;
{
fmpz_t d;
@@ -50,8 +50,7 @@ TEST_FUNCTION_START(fmpz_mat_inv, state)
fmpz_mat_init(I, m, m);
fmpz_init(den);
- for (j = 0; j < m; j++)
- fmpz_set_ui(&I->rows[j][j], UWORD(1));
+ fmpz_mat_one(I);
/* Verify that A * A^-1 = I for random matrices */
diff --git a/src/fmpz_mat/test/t-scalar_smod.c b/src/fmpz_mat/test/t-scalar_smod.c
index 4f601a87ef..beaa28b025 100644
--- a/src/fmpz_mat/test/t-scalar_smod.c
+++ b/src/fmpz_mat/test/t-scalar_smod.c
@@ -44,15 +44,15 @@ TEST_FUNCTION_START(fmpz_mat_scalar_smod, state)
{
for (k = 0; k < A->c; k++)
{
- fmpz_smod(c, A->rows[j] + k, P);
+ fmpz_smod(c, fmpz_mat_entry(A, j, k), P);
- if (!fmpz_equal(c, B->rows[j] + k))
+ if (!fmpz_equal(c, fmpz_mat_entry(B, j, k)))
{
flint_printf("FAIL!\n");
flint_printf("%wd, %wd\n", j, k);
fmpz_print(c); flint_printf("\n");
- fmpz_print(A->rows[j] + k); flint_printf("\n");
- fmpz_print(B->rows[j] + k); flint_printf("\n");
+ fmpz_print(fmpz_mat_entry(A, j, k)); flint_printf("\n");
+ fmpz_print(fmpz_mat_entry(B, j, k)); flint_printf("\n");
fmpz_print(P); flint_printf("\n");
fflush(stdout);
flint_abort();
diff --git a/src/fmpz_mod_mat/test/t-howell_form.c b/src/fmpz_mod_mat/test/t-howell_form.c
index 866c2bf883..31c83f8999 100644
--- a/src/fmpz_mod_mat/test/t-howell_form.c
+++ b/src/fmpz_mod_mat/test/t-howell_form.c
@@ -107,7 +107,7 @@ fmpz_mod_mat_is_in_howell_form(const fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx)
{
fmpz_gcd(g, ctx->n, fmpz_mod_mat_entry(A, i, pivots[i]));
fmpz_divexact(g, ctx->n, g);
- _fmpz_vec_scalar_mul_fmpz(extra_row, A->rows[i], A->c, g);
+ _fmpz_vec_scalar_mul_fmpz(extra_row, fmpz_mod_mat_entry(A, i, 0), A->c, g);
_fmpz_vec_scalar_mod_fmpz(extra_row, extra_row, A->c, ctx->n);
for ( j = pivots[i] + 1; j < A->c; j++)
@@ -122,7 +122,7 @@ fmpz_mod_mat_is_in_howell_form(const fmpz_mod_mat_t A, const fmpz_mod_ctx_t ctx)
{
fmpz_divexact(g, extra_row + j, fmpz_mod_mat_entry(A, r, pivots[r]));
fmpz_neg(g, g);
- _fmpz_vec_scalar_addmul_fmpz(extra_row, A->rows[r], A->c, g);
+ _fmpz_vec_scalar_addmul_fmpz(extra_row, fmpz_mod_mat_entry(A, r, 0), A->c, g);
}
}
}
diff --git a/src/fmpz_mod_mat/test/t-lu.c b/src/fmpz_mod_mat/test/t-lu.c
index 4c16d2c2f2..7dc10cf6d8 100644
--- a/src/fmpz_mod_mat/test/t-lu.c
+++ b/src/fmpz_mod_mat/test/t-lu.c
@@ -10,6 +10,7 @@
(at your option) any later version. See .
*/
+#include
#include "test_helpers.h"
#include "fmpz.h"
#include "fmpz_mod.h"
@@ -18,17 +19,15 @@
void perm(fmpz_mod_mat_t A, slong * P)
{
slong i;
- fmpz ** tmp;
+ fmpz * tmp;
if (A->c == 0 || A->r == 0)
return;
- tmp = flint_malloc(sizeof(fmpz *) * A->r);
+ tmp = flint_malloc(sizeof(fmpz) * A->r * A->c);
- for (i = 0; i < A->r; i++)
- tmp[P[i]] = A->rows[i];
- for (i = 0; i < A->r; i++)
- A->rows[i] = tmp[i];
+ for (i = 0; i < A->r; i++) memcpy(tmp + P[i] * A->c, fmpz_mat_entry(A, i, 0), A->c * sizeof(fmpz));
+ for (i = 0; i < A->r; i++) memcpy(fmpz_mat_entry(A, i, 0), tmp + i * A->c, A->c * sizeof(fmpz));
flint_free(tmp);
}
diff --git a/src/fmpz_mod_mat/test/t-rref.c b/src/fmpz_mod_mat/test/t-rref.c
index bfd46aa514..0a56477805 100644
--- a/src/fmpz_mod_mat/test/t-rref.c
+++ b/src/fmpz_mod_mat/test/t-rref.c
@@ -29,7 +29,7 @@ check_rref(fmpz_mod_mat_t A)
for (j = 0; j < A->c; j++)
{
/* Found nonzero entry */
- if (!fmpz_is_zero(A->rows[i] + j))
+ if (!fmpz_is_zero(fmpz_mod_mat_entry(A, i, j)))
{
if (prev_row_zero)
{
diff --git a/src/fq_mat_templates.h b/src/fq_mat_templates.h
index c70771e3b1..8e49277264 100644
--- a/src/fq_mat_templates.h
+++ b/src/fq_mat_templates.h
@@ -45,7 +45,7 @@ TEMPLATE(T, mat_ncols)(const TEMPLATE(T, mat_t) mat,
FQ_MAT_TEMPLATES_INLINE TEMPLATE(T, struct) *
TEMPLATE(T, mat_entry)(const TEMPLATE(T, mat_t) mat, slong i, slong j)
{
- return mat->rows[i] + j;
+ return mat->entries + i * mat->stride + j;
}
void TEMPLATE(T, mat_entry_set)(TEMPLATE(T, mat_t) mat, slong i, slong j,
@@ -92,10 +92,17 @@ TEMPLATE(T, mat_swap_rows)(TEMPLATE(T, mat_t) mat, slong * perm, slong r, slong
{
if (r != s && !TEMPLATE(T, mat_is_empty)(mat, ctx))
{
+ slong i;
+ TEMPLATE(T, struct) *u, *v;
+
if (perm != NULL)
FLINT_SWAP(slong, perm[r], perm[s]);
- FLINT_SWAP(TEMPLATE(T, struct) *, mat->rows[r], mat->rows[s]);
+ u = TEMPLATE(T, mat_entry)(mat, r, 0);
+ v = TEMPLATE(T, mat_entry)(mat, s, 0);
+
+ for (i = 0; i < mat->c; i++)
+ FLINT_SWAP(TEMPLATE(T, struct), u[i], v[i]);
}
}
diff --git a/src/fq_mat_templates/add.c b/src/fq_mat_templates/add.c
index c85c8fc8fe..2b597bf460 100644
--- a/src/fq_mat_templates/add.c
+++ b/src/fq_mat_templates/add.c
@@ -26,8 +26,10 @@ TEMPLATE(T, mat_add) (TEMPLATE(T, mat_t) res,
return;
for (i = 0; i < res->r; i++)
- _TEMPLATE(T, vec_add) (res->rows[i], mat1->rows[i], mat2->rows[i],
- res->c, ctx);
+ _TEMPLATE(T, vec_add) (TEMPLATE(T, mat_entry)(res, i, 0),
+ TEMPLATE(T, mat_entry)(mat1, i, 0),
+ TEMPLATE(T, mat_entry)(mat2, i, 0),
+ res->c, ctx);
}
diff --git a/src/fq_mat_templates/can_solve.c b/src/fq_mat_templates/can_solve.c
index 3967009082..9b0a2b84f4 100644
--- a/src/fq_mat_templates/can_solve.c
+++ b/src/fq_mat_templates/can_solve.c
@@ -45,9 +45,9 @@ TEMPLATE(T, mat_can_solve)(TEMPLATE(T, mat_t) X, const TEMPLATE(T, mat_t) A,
rank = TEMPLATE(T, mat_lu)(perm, LU, 0, ctx);
- TEMPLATE(T, mat_window_init)(PB, B, 0, 0, B->r, B->c, ctx);
+ TEMPLATE(T, mat_init)(PB, B->r, B->c, ctx);
for (i = 0; i < B->r; i++)
- PB->rows[i] = B->rows[perm[i]];
+ _TEMPLATE(T, vec_set)(TEMPLATE(T, mat_entry)(PB, i, 0), TEMPLATE(T, mat_entry)(B, perm[i], 0), B->c, ctx);
TEMPLATE(T, mat_init)(LU2, rank, rank, ctx);
@@ -77,7 +77,7 @@ TEMPLATE(T, mat_can_solve)(TEMPLATE(T, mat_t) X, const TEMPLATE(T, mat_t) A,
{
TEMPLATE(T, mat_t) P;
- LU->rows += rank;
+ LU->entries += rank * LU->stride;
LU->r = A->r - rank;
X->r = LU->c;
@@ -86,14 +86,14 @@ TEMPLATE(T, mat_can_solve)(TEMPLATE(T, mat_t) X, const TEMPLATE(T, mat_t) A,
TEMPLATE(T, mat_mul)(P, LU, X, ctx);
PB->r = LU->r;
- PB->rows += rank;
+ PB->entries += rank * PB->stride;
result = TEMPLATE(T, mat_equal)(P, PB, ctx);
- PB->rows -= rank;
+ PB->entries -= rank * PB->stride;
TEMPLATE(T, mat_clear)(P, ctx);
- LU->rows -= rank;
+ LU->entries -= rank * LU->stride;
if (!result)
{
@@ -128,7 +128,7 @@ TEMPLATE(T, mat_can_solve)(TEMPLATE(T, mat_t) X, const TEMPLATE(T, mat_t) A,
TEMPLATE(T, mat_clear)(LU2, ctx);
PB->r = B->r;
- TEMPLATE(T, mat_window_clear)(PB, ctx);
+ TEMPLATE(T, mat_clear)(PB, ctx);
LU->r = A->r;
TEMPLATE(T, mat_clear)(LU, ctx);
diff --git a/src/fq_mat_templates/charpoly.c b/src/fq_mat_templates/charpoly.c
index 2a34983a37..da51304e90 100644
--- a/src/fq_mat_templates/charpoly.c
+++ b/src/fq_mat_templates/charpoly.c
@@ -89,11 +89,7 @@ TEMPLATE(T, mat_charpoly_danilevsky) (TEMPLATE(T, poly_t) p,
}
} else
{
- TEMPLATE(T, struct) * ptr;
-
- ptr = A->rows[n - i - k - 1];
- A->rows[n - i - k - 1] = A->rows[n - i - 1];
- A->rows[n - i - 1] = ptr;
+ TEMPLATE(T, mat_swap_rows) (A, NULL, n - i - 1, n - i - k - 1, ctx);
for (j = 1; j <= n - i + 1; j++)
{
diff --git a/src/fq_mat_templates/clear.c b/src/fq_mat_templates/clear.c
index ad5df0d934..7b0803f484 100644
--- a/src/fq_mat_templates/clear.c
+++ b/src/fq_mat_templates/clear.c
@@ -18,15 +18,8 @@
void
TEMPLATE(T, mat_clear) (TEMPLATE(T, mat_t) mat, const TEMPLATE(T, ctx_t) ctx)
{
- if (mat->entries)
- {
- slong i;
- for (i = 0; i < mat->r * mat->c; i++)
- TEMPLATE(T, clear) (mat->entries + i, ctx); /* Clear all coefficients */
- flint_free(mat->entries); /* Clean up array of entries */
- flint_free(mat->rows); /* Clean up row array */
- } else if (mat->r != 0)
- flint_free(mat->rows);
+ if (mat->entries != NULL)
+ _TEMPLATE(T, vec_clear)(mat->entries, mat->r * mat->c, ctx);
}
diff --git a/src/fq_mat_templates/concat_horizontal.c b/src/fq_mat_templates/concat_horizontal.c
index eb9365a74f..f324420165 100644
--- a/src/fq_mat_templates/concat_horizontal.c
+++ b/src/fq_mat_templates/concat_horizontal.c
@@ -26,9 +26,9 @@ TEMPLATE(T, mat_concat_horizontal) (TEMPLATE(T, mat_t) res,
for (i = 0; i < r1; i++) {
if (c1 > 0)
- _TEMPLATE(T, vec_set) (res->rows[i], mat1->rows[i], c1, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry)(res, i, 0), TEMPLATE(T, mat_entry)(mat1, i, 0), c1, ctx);
if (c2 > 0)
- _TEMPLATE(T, vec_set) (res->rows[i] + c1, mat2->rows[i], c2, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry)(res, i, c1), TEMPLATE(T, mat_entry)(mat2, i, 0), c2, ctx);
}
}
diff --git a/src/fq_mat_templates/concat_vertical.c b/src/fq_mat_templates/concat_vertical.c
index 8f098ecd46..350b237e83 100644
--- a/src/fq_mat_templates/concat_vertical.c
+++ b/src/fq_mat_templates/concat_vertical.c
@@ -27,9 +27,9 @@ TEMPLATE(T, mat_concat_vertical) (TEMPLATE(T, mat_t) res,
if (c1 > 0)
{
for (i = 0; i < r1; i++)
- _TEMPLATE(T, vec_set) (res->rows[i], mat1->rows[i], c1, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry)(res, i, 0), TEMPLATE(T, mat_entry)(mat1, i, 0), c1, ctx);
for (i = 0; i < r2; i++)
- _TEMPLATE(T, vec_set) (res->rows[i + r1], mat2->rows[i], c1, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry)(res, i + r1, 0), TEMPLATE(T, mat_entry)(mat2, i, 0), c1, ctx);
}
}
diff --git a/src/fq_mat_templates/equal.c b/src/fq_mat_templates/equal.c
index b3af715ba6..96256a0aee 100644
--- a/src/fq_mat_templates/equal.c
+++ b/src/fq_mat_templates/equal.c
@@ -31,7 +31,7 @@ int TEMPLATE(T, mat_equal) (const TEMPLATE(T, mat_t) mat1,
for (j = 0; j < mat1->r; j++)
{
if (!_TEMPLATE(T, vec_equal)
- (mat1->rows[j], mat2->rows[j], mat1->c, ctx))
+ (TEMPLATE(T, mat_entry)(mat1, j, 0), TEMPLATE(T, mat_entry)(mat2, j, 0), mat1->c, ctx))
{
return 0;
}
diff --git a/src/fq_mat_templates/init.c b/src/fq_mat_templates/init.c
index 78662bceb3..fdcb1580f7 100644
--- a/src/fq_mat_templates/init.c
+++ b/src/fq_mat_templates/init.c
@@ -18,19 +18,13 @@ void
TEMPLATE(T, mat_init)(TEMPLATE(T, mat_t) mat, slong rows, slong cols,
const TEMPLATE(T, ctx_t) ctx)
{
- slong i;
-
+ mat->entries = NULL;
mat->r = rows;
mat->c = cols;
-
- if (rows != 0)
- mat->rows = flint_malloc(rows * sizeof(TEMPLATE(T, struct) *));
- else
- mat->rows = NULL;
+ mat->stride = cols;
if (rows != 0 && cols != 0)
{
- slong j;
slong num;
int of;
@@ -39,23 +33,7 @@ TEMPLATE(T, mat_init)(TEMPLATE(T, mat_t) mat, slong rows, slong cols,
if (of)
flint_throw(FLINT_ERROR, "Overflow creating a %wd x %wd object\n", rows, cols);
- mat->entries = flint_malloc(num * sizeof(TEMPLATE(T, struct)));
-
- for (i = 0; i < rows; i++)
- {
- mat->rows[i] = mat->entries + i * cols;
- for (j = 0; j < cols; j++)
- TEMPLATE(T, init) (mat->rows[i] + j, ctx);
- }
- }
- else
- {
- mat->entries = NULL;
- if (rows != 0)
- {
- for (i = 0; i < rows; i++)
- mat->rows[i] = NULL;
- }
+ mat->entries = _TEMPLATE(T, vec_init)(num, ctx);
}
}
#endif
diff --git a/src/fq_mat_templates/io.c b/src/fq_mat_templates/io.c
index af0ff0937e..75213d3b3e 100644
--- a/src/fq_mat_templates/io.c
+++ b/src/fq_mat_templates/io.c
@@ -69,7 +69,7 @@ int TEMPLATE(T, mat_fprint) (FILE * file, const TEMPLATE(T, mat_t) mat,
{
for (j = 0; j < c; j++)
{
- xxx_T_print(mat->rows[i] + j, ctx);
+ xxx_T_print(TEMPLATE(T, mat_entry)(mat, i, j), ctx);
if (j != c - 1)
xxx_putc(' ');
}
@@ -94,7 +94,7 @@ int TEMPLATE(T, mat_fprint_pretty) (FILE * file, const TEMPLATE(T, mat_t) mat,
xxx_putc('[');
for (j = 0; j < c; j++)
{
- xxx_T_print_pretty(mat->rows[i] + j, ctx);
+ xxx_T_print_pretty(TEMPLATE(T, mat_entry)(mat, i, j), ctx);
if (j != c - 1)
xxx_putc(' ');
}
diff --git a/src/fq_mat_templates/is_zero.c b/src/fq_mat_templates/is_zero.c
index 77ea753785..a21e34b56c 100644
--- a/src/fq_mat_templates/is_zero.c
+++ b/src/fq_mat_templates/is_zero.c
@@ -25,7 +25,7 @@ TEMPLATE(T, mat_is_zero) (const TEMPLATE(T, mat_t) mat,
for (j = 0; j < mat->r; j++)
{
- if (!_TEMPLATE(T, vec_is_zero) (mat->rows[j], mat->c, ctx))
+ if (!_TEMPLATE(T, vec_is_zero) (TEMPLATE(T, mat_entry)(mat, j, 0), mat->c, ctx))
return 0;
}
diff --git a/src/fq_mat_templates/lu_classical.c b/src/fq_mat_templates/lu_classical.c
index 9d0e2f8289..8e04018199 100644
--- a/src/fq_mat_templates/lu_classical.c
+++ b/src/fq_mat_templates/lu_classical.c
@@ -19,8 +19,7 @@ static inline int
TEMPLATE(T, mat_pivot) (TEMPLATE(T, mat_t) A, slong * P, slong start_row,
slong col, const TEMPLATE(T, ctx_t) ctx)
{
- slong j, t;
- TEMPLATE(T, struct) * u;
+ slong j;
if (!TEMPLATE(T, is_zero)
(TEMPLATE(T, mat_entry) (A, start_row, col), ctx))
@@ -30,14 +29,7 @@ TEMPLATE(T, mat_pivot) (TEMPLATE(T, mat_t) A, slong * P, slong start_row,
{
if (!TEMPLATE(T, is_zero) (TEMPLATE(T, mat_entry) (A, j, col), ctx))
{
- u = A->rows[j];
- A->rows[j] = A->rows[start_row];
- A->rows[start_row] = u;
-
- t = P[j];
- P[j] = P[start_row];
- P[start_row] = t;
-
+ TEMPLATE(T, mat_swap_rows) (A, P, j, start_row, ctx);
return -1;
}
}
@@ -51,12 +43,10 @@ TEMPLATE(T, mat_lu_classical) (slong * P,
int rank_check, const TEMPLATE(T, ctx_t) ctx)
{
TEMPLATE(T, t) d, e, neg_e;
- TEMPLATE(T, struct) ** a;
slong i, m, n, rank, length, row, col;
m = A->r;
n = A->c;
- a = A->rows;
rank = row = col = 0;
@@ -82,23 +72,23 @@ TEMPLATE(T, mat_lu_classical) (slong * P,
rank++;
- TEMPLATE(T, inv) (d, a[row] + col, ctx);
+ TEMPLATE(T, inv) (d, TEMPLATE(T, mat_entry) (A, row, col), ctx);
length = n - col - 1;
for (i = row + 1; i < m; i++)
{
- TEMPLATE(T, mul) (e, a[i] + col, d, ctx);
+ TEMPLATE(T, mul) (e, TEMPLATE(T, mat_entry) (A, i, col), d, ctx);
if (length != 0)
{
TEMPLATE(T, neg) (neg_e, e, ctx);
- _TEMPLATE3(T, vec_scalar_addmul, T) (a[i] + col + 1,
- a[row] + col + 1,
+ _TEMPLATE3(T, vec_scalar_addmul, T) (TEMPLATE(T, mat_entry) (A, i, col + 1),
+ TEMPLATE(T, mat_entry) (A, row, col + 1),
length, neg_e, ctx);
}
- TEMPLATE(T, zero) (a[i] + col, ctx);
- TEMPLATE(T, set) (a[i] + rank - 1, e, ctx);
+ TEMPLATE(T, zero) (TEMPLATE(T, mat_entry) (A, i, col), ctx);
+ TEMPLATE(T, set) (TEMPLATE(T, mat_entry) (A, i, rank - 1), e, ctx);
}
row++;
col++;
diff --git a/src/fq_mat_templates/lu_recursive.c b/src/fq_mat_templates/lu_recursive.c
index 653dbffbf1..8975f5b432 100644
--- a/src/fq_mat_templates/lu_recursive.c
+++ b/src/fq_mat_templates/lu_recursive.c
@@ -12,31 +12,32 @@
#ifdef T
+#include
#include "templates.h"
static void
-_apply_permutation(slong * AP,
- TEMPLATE(T, mat_t) A, slong * P, slong n, slong offset)
+_apply_permutation(slong * AP, TEMPLATE(T, mat_t) A, const slong * P,
+ slong num_rows, slong row_offset, slong num_cols, slong col_offset)
{
- if (n != 0)
+ if (num_rows != 0)
{
- TEMPLATE(T, struct) ** Atmp;
- slong *APtmp;
+ TEMPLATE(T, struct) * Atmp;
+ slong * APtmp;
slong i;
- Atmp = flint_malloc(sizeof(TEMPLATE(T, struct) *) * n);
- APtmp = flint_malloc(sizeof(slong) * n);
+ /* todo: reduce memory allocation */
+ Atmp = flint_malloc(sizeof(TEMPLATE(T, struct)) * num_rows * num_cols);
+ /* todo: avoid temporary allocation when AP != P */
+ APtmp = flint_malloc(sizeof(slong) * num_rows);
- for (i = 0; i < n; i++)
- Atmp[i] = A->rows[P[i] + offset];
- for (i = 0; i < n; i++)
- A->rows[i + offset] = Atmp[i];
+ for (i = 0; i < num_rows; i++)
+ memcpy(Atmp + i * num_cols, TEMPLATE(T, mat_entry) (A, P[i] + row_offset, col_offset), num_cols * sizeof(TEMPLATE(T, struct)));
+ for (i = 0; i < num_rows; i++)
+ memcpy(TEMPLATE(T, mat_entry) (A, i + row_offset, col_offset), Atmp + i * num_cols, num_cols * sizeof(TEMPLATE(T, struct)));
- for (i = 0; i < n; i++)
- APtmp[i] = AP[P[i] + offset];
- for (i = 0; i < n; i++)
- AP[i + offset] = APtmp[i];
+ for (i = 0; i < num_rows; i++) APtmp[i] = AP[P[i] + row_offset];
+ for (i = 0; i < num_rows; i++) AP[i + row_offset] = APtmp[i];
flint_free(Atmp);
flint_free(APtmp);
@@ -85,7 +86,7 @@ TEMPLATE(T, mat_lu_recursive) (slong * P,
if (r1 != 0)
{
- _apply_permutation(P, A, P1, m, 0);
+ _apply_permutation(P, A, P1, m, 0, n - n1, n1);
}
TEMPLATE(T, mat_window_init) (A00, A, 0, 0, r1, r1, ctx);
@@ -107,14 +108,14 @@ TEMPLATE(T, mat_lu_recursive) (slong * P,
}
else
{
- _apply_permutation(P, A, P1, m - r1, r1);
+ _apply_permutation(P, A, P1, m - r1, r1, n1, 0);
/* Compress L */
if (r1 != n1)
{
for (i = 0; i < m - r1; i++)
{
- TEMPLATE(T, struct) * row = A->rows[r1 + i];
+ TEMPLATE(T, struct) * row = TEMPLATE(T, mat_entry) (A, r1 + i, 0);
for (j = 0; j < FLINT_MIN(i, r2); j++)
{
TEMPLATE(T, set) (row + r1 + j, row + n1 + j, ctx);
diff --git a/src/fq_mat_templates/mul_classical.c b/src/fq_mat_templates/mul_classical.c
index 179e491b34..bbd2f72371 100644
--- a/src/fq_mat_templates/mul_classical.c
+++ b/src/fq_mat_templates/mul_classical.c
@@ -61,7 +61,7 @@ TEMPLATE(T, mat_mul_classical) (TEMPLATE(T, mat_t) C,
for (j = 0; j < bc; j++)
{
_TEMPLATE(T, vec_dot) (TEMPLATE(T, mat_entry) (C, i, j),
- A->rows[i], trB + j * br, br, ctx);
+ TEMPLATE(T, mat_entry) (A, i, 0), trB + j * br, br, ctx);
}
}
diff --git a/src/fq_mat_templates/neg.c b/src/fq_mat_templates/neg.c
index 303ca97819..01b7a757f6 100644
--- a/src/fq_mat_templates/neg.c
+++ b/src/fq_mat_templates/neg.c
@@ -25,7 +25,8 @@ TEMPLATE(T, mat_neg) (TEMPLATE(T, mat_t) res,
return;
for (i = 0; i < res->r; i++)
- _TEMPLATE(T, vec_neg) (res->rows[i], mat->rows[i], res->c, ctx);
+ _TEMPLATE(T, vec_neg) (TEMPLATE(T, mat_entry)(res, i, 0),
+ TEMPLATE(T, mat_entry)(mat, i, 0), res->c, ctx);
}
diff --git a/src/fq_mat_templates/randops.c b/src/fq_mat_templates/randops.c
index 6fec7abb20..c31f7bcd3d 100644
--- a/src/fq_mat_templates/randops.c
+++ b/src/fq_mat_templates/randops.c
@@ -34,12 +34,12 @@ TEMPLATE(T, mat_randops) (TEMPLATE(T, mat_t) mat,
if (n_randint(state, 2))
for (k = 0; k < n; k++)
- TEMPLATE(T, add) (mat->rows[j] + k,
- mat->rows[j] + k, mat->rows[i] + k, ctx);
+ TEMPLATE(T, add) (TEMPLATE(T, mat_entry)(mat, j, k),
+ TEMPLATE(T, mat_entry)(mat, j, k), TEMPLATE(T, mat_entry)(mat, i, k), ctx);
else
for (k = 0; k < n; k++)
- TEMPLATE(T, sub) (mat->rows[j] + k,
- mat->rows[j] + k, mat->rows[i] + k, ctx);
+ TEMPLATE(T, sub) (TEMPLATE(T, mat_entry)(mat, j, k),
+ TEMPLATE(T, mat_entry)(mat, j, k), TEMPLATE(T, mat_entry)(mat, i, k), ctx);
}
else
{
@@ -47,12 +47,12 @@ TEMPLATE(T, mat_randops) (TEMPLATE(T, mat_t) mat,
continue;
if (n_randint(state, 2))
for (k = 0; k < m; k++)
- TEMPLATE(T, add) (mat->rows[k] + j,
- mat->rows[k] + j, mat->rows[k] + i, ctx);
+ TEMPLATE(T, add) (TEMPLATE(T, mat_entry)(mat, k, j),
+ TEMPLATE(T, mat_entry)(mat, k, j), TEMPLATE(T, mat_entry)(mat, k, i), ctx);
else
for (k = 0; k < m; k++)
- TEMPLATE(T, sub) (mat->rows[k] + j,
- mat->rows[k] + j, mat->rows[k] + i, ctx);
+ TEMPLATE(T, sub) (TEMPLATE(T, mat_entry)(mat, k, j),
+ TEMPLATE(T, mat_entry)(mat, k, j), TEMPLATE(T, mat_entry)(mat, k, i), ctx);
}
}
}
diff --git a/src/fq_mat_templates/randtest.c b/src/fq_mat_templates/randtest.c
index 48106145da..d8f710f15d 100644
--- a/src/fq_mat_templates/randtest.c
+++ b/src/fq_mat_templates/randtest.c
@@ -25,7 +25,7 @@ TEMPLATE(T, mat_randtest) (TEMPLATE(T, mat_t) mat, flint_rand_t state,
for (i = 0; i < r; i++)
for (j = 0; j < c; j++)
- TEMPLATE(T, randtest) (mat->rows[i] + j, state, ctx);
+ TEMPLATE(T, randtest) (TEMPLATE(T, mat_entry)(mat, i, j), state, ctx);
}
diff --git a/src/fq_mat_templates/set.c b/src/fq_mat_templates/set.c
index 17bc6a5644..8d91db4083 100644
--- a/src/fq_mat_templates/set.c
+++ b/src/fq_mat_templates/set.c
@@ -25,8 +25,8 @@ TEMPLATE(T, mat_set) (TEMPLATE(T, mat_t) mat1, const TEMPLATE(T, mat_t) mat2,
if (mat2->r && mat2->c)
for (i = 0; i < mat2->r; i++)
- _TEMPLATE(T, vec_set) (mat1->rows[i], mat2->rows[i], mat2->c,
- ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry)(mat1, i, 0),
+ TEMPLATE(T, mat_entry)(mat2, i, 0), mat2->c, ctx);
}
}
diff --git a/src/fq_mat_templates/solve.c b/src/fq_mat_templates/solve.c
index b05e81b551..c8b0b60a82 100644
--- a/src/fq_mat_templates/solve.c
+++ b/src/fq_mat_templates/solve.c
@@ -33,14 +33,15 @@ TEMPLATE(T, mat_solve)(TEMPLATE(T, mat_t) X, const TEMPLATE(T, mat_t) A,
if (rank == A->r)
{
TEMPLATE(T, mat_t) PB;
- TEMPLATE(T, mat_window_init)(PB, B, 0, 0, B->r, B->c, ctx);
+ TEMPLATE(T, mat_init)(PB, B->r, B->c, ctx);
for (i = 0; i < A->r; i++)
- PB->rows[i] = B->rows[perm[i]];
+ _TEMPLATE(T, vec_set)(TEMPLATE(T, mat_entry)(PB, i, 0),
+ TEMPLATE(T, mat_entry)(B, perm[i], 0), B->c, ctx);
TEMPLATE(T, mat_solve_tril)(X, LU, PB, 1, ctx);
TEMPLATE(T, mat_solve_triu)(X, LU, X, 0, ctx);
- TEMPLATE(T, mat_window_clear)(PB, ctx);
+ TEMPLATE(T, mat_clear)(PB, ctx);
result = 1;
}
else
diff --git a/src/fq_mat_templates/solve_tril_classical.c b/src/fq_mat_templates/solve_tril_classical.c
index 5f8d6b8b21..58258bd648 100644
--- a/src/fq_mat_templates/solve_tril_classical.c
+++ b/src/fq_mat_templates/solve_tril_classical.c
@@ -46,7 +46,7 @@ TEMPLATE(T, mat_solve_tril_classical) (TEMPLATE(T, mat_t) X,
{
TEMPLATE(T, t) s;
TEMPLATE(T, init) (s, ctx);
- _TEMPLATE(T, vec_dot) (s, L->rows[j], tmp, j, ctx);
+ _TEMPLATE(T, vec_dot) (s, TEMPLATE(T, mat_entry) (L, j, 0), tmp, j, ctx);
TEMPLATE(T, sub) (s, TEMPLATE(T, mat_entry) (B, j, i), s, ctx);
if (!unit)
TEMPLATE(T, mul) (s, s, inv + j, ctx);
diff --git a/src/fq_mat_templates/solve_triu_classical.c b/src/fq_mat_templates/solve_triu_classical.c
index a91363ace6..eb405ea3d2 100644
--- a/src/fq_mat_templates/solve_triu_classical.c
+++ b/src/fq_mat_templates/solve_triu_classical.c
@@ -46,7 +46,7 @@ TEMPLATE(T, mat_solve_triu_classical) (TEMPLATE(T, mat_t) X,
{
TEMPLATE(T, t) s;
TEMPLATE(T, init) (s, ctx);
- _TEMPLATE(T, vec_dot) (s, U->rows[j] + j + 1, tmp + j + 1,
+ _TEMPLATE(T, vec_dot) (s, TEMPLATE(T, mat_entry) (U, j, j + 1), tmp + j + 1,
n - j - 1, ctx);
TEMPLATE(T, sub) (s, TEMPLATE(T, mat_entry) (B, j, i), s, ctx);
if (!unit)
diff --git a/src/fq_mat_templates/sub.c b/src/fq_mat_templates/sub.c
index 680d25cbdf..0284a936f8 100644
--- a/src/fq_mat_templates/sub.c
+++ b/src/fq_mat_templates/sub.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2011 Fredrik Johansson
+ Copyright (C) 2010 Fredrik Johansson
Copyright (C) 2013 Mike Hansen
This file is part of FLINT.
@@ -26,8 +26,10 @@ TEMPLATE(T, mat_sub) (TEMPLATE(T, mat_t) res,
return;
for (i = 0; i < res->r; i++)
- _TEMPLATE(T, vec_sub) (res->rows[i], mat1->rows[i], mat2->rows[i],
- res->c, ctx);
+ _TEMPLATE(T, vec_sub) (TEMPLATE(T, mat_entry)(res, i, 0),
+ TEMPLATE(T, mat_entry)(mat1, i, 0),
+ TEMPLATE(T, mat_entry)(mat2, i, 0),
+ res->c, ctx);
}
diff --git a/src/fq_mat_templates/test/t-lu_classical.c b/src/fq_mat_templates/test/t-lu_classical.c
index 709dfea010..6c53a8dfc3 100644
--- a/src/fq_mat_templates/test/t-lu_classical.c
+++ b/src/fq_mat_templates/test/t-lu_classical.c
@@ -12,6 +12,7 @@
#ifdef T
+#include
#include "test_helpers.h"
#include "templates.h"
@@ -22,17 +23,15 @@ void
perm(TEMPLATE(T, mat_t) A, slong * P)
{
slong i;
- TEMPLATE(T, struct) ** tmp;
+ TEMPLATE(T, struct) * tmp;
if (A->c == 0 || A->r == 0)
return;
- tmp = flint_malloc(sizeof(TEMPLATE(T, struct) *) * A->r);
+ tmp = flint_malloc(sizeof(TEMPLATE(T, struct)) * A->r * A->c);
- for (i = 0; i < A->r; i++)
- tmp[P[i]] = A->rows[i];
- for (i = 0; i < A->r; i++)
- A->rows[i] = tmp[i];
+ for (i = 0; i < A->r; i++) memcpy(tmp + P[i] * A->c, TEMPLATE(T, mat_entry)(A, i, 0), A->c * sizeof(TEMPLATE(T, struct)));
+ for (i = 0; i < A->r; i++) memcpy(TEMPLATE(T, mat_entry)(A, i, 0), tmp + i * A->c, A->c * sizeof(TEMPLATE(T, struct)));
flint_free(tmp);
}
diff --git a/src/fq_mat_templates/test/t-lu_recursive.c b/src/fq_mat_templates/test/t-lu_recursive.c
index 9f4c7158d3..0482000636 100644
--- a/src/fq_mat_templates/test/t-lu_recursive.c
+++ b/src/fq_mat_templates/test/t-lu_recursive.c
@@ -12,6 +12,7 @@
#ifdef T
+#include
#include "test_helpers.h"
#include "templates.h"
@@ -22,17 +23,15 @@ void
perm(TEMPLATE(T, mat_t) A, slong * P)
{
slong i;
- TEMPLATE(T, struct) ** tmp;
+ TEMPLATE(T, struct) * tmp;
if (A->c == 0 || A->r == 0)
return;
- tmp = flint_malloc(sizeof(TEMPLATE(T, struct) *) * A->r);
+ tmp = flint_malloc(sizeof(TEMPLATE(T, struct)) * A->r * A->c);
- for (i = 0; i < A->r; i++)
- tmp[P[i]] = A->rows[i];
- for (i = 0; i < A->r; i++)
- A->rows[i] = tmp[i];
+ for (i = 0; i < A->r; i++) memcpy(tmp + P[i] * A->c, TEMPLATE(T, mat_entry)(A, i, 0), A->c * sizeof(TEMPLATE(T, struct)));
+ for (i = 0; i < A->r; i++) memcpy(TEMPLATE(T, mat_entry)(A, i, 0), tmp + i * A->c, A->c * sizeof(TEMPLATE(T, struct)));
flint_free(tmp);
}
diff --git a/src/fq_mat_templates/test/t-window_init_clear.c b/src/fq_mat_templates/test/t-window_init_clear.c
index 65f123e13f..bc79a7b333 100644
--- a/src/fq_mat_templates/test/t-window_init_clear.c
+++ b/src/fq_mat_templates/test/t-window_init_clear.c
@@ -46,7 +46,7 @@ TEST_TEMPLATE_FUNCTION_START(T, mat_window_init_clear, state)
TEMPLATE(T, mat_window_init) (w, a, r1, c1, r2, c2, ctx);
for (j = 0; j < r2 - r1; j++)
- _TEMPLATE(T, vec_zero) (w->rows[j], c2 - c1, ctx);
+ _TEMPLATE(T, vec_zero) (TEMPLATE(T, mat_entry) (w, j, 0), c2 - c1, ctx);
TEMPLATE(T, mat_window_clear) (w, ctx);
TEMPLATE(T, mat_clear) (a, ctx);
diff --git a/src/fq_mat_templates/window_clear.c b/src/fq_mat_templates/window_clear.c
index 5063ae783c..22ff1147ef 100644
--- a/src/fq_mat_templates/window_clear.c
+++ b/src/fq_mat_templates/window_clear.c
@@ -21,8 +21,6 @@ void
TEMPLATE(T, mat_window_clear) (TEMPLATE(T, mat_t) window,
const TEMPLATE(T, ctx_t) FLINT_UNUSED(ctx))
{
- if (window->r != 0)
- flint_free(window->rows);
}
diff --git a/src/fq_mat_templates/window_init.c b/src/fq_mat_templates/window_init.c
index 7d0e0f6042..b26e475df5 100644
--- a/src/fq_mat_templates/window_init.c
+++ b/src/fq_mat_templates/window_init.c
@@ -23,27 +23,13 @@ TEMPLATE(T, mat_window_init) (TEMPLATE(T, mat_t) window,
slong r1, slong c1, slong r2, slong c2,
const TEMPLATE(T, ctx_t) FLINT_UNUSED(ctx))
{
- slong i;
- window->entries = NULL;
-
- if (r2 > r1)
- window->rows = (TEMPLATE(T, struct) **) flint_malloc((r2 - r1)
- * sizeof(TEMPLATE(T, struct) *));
- else
- window->rows = NULL;
-
- if (mat->c > 0)
- {
- for (i = 0; i < r2 - r1; i++)
- window->rows[i] = mat->rows[r1 + i] + c1;
- } else
- {
- for (i = 0; i < r2 - r1; i++)
- window->rows[i] = NULL;
- }
+ FLINT_ASSERT(r1 >= 0 && r1 <= r2 && r2 <= mat->r);
+ FLINT_ASSERT(c2 >= 0 && c1 <= c2 && c2 <= mat->c);
+ window->entries = TEMPLATE(T, mat_entry)(mat, r1, c1);
window->r = r2 - r1;
window->c = c2 - c1;
+ window->stride = mat->stride;
}
diff --git a/src/fq_nmod_mpoly/mpolyu_gcdp_zippel.c b/src/fq_nmod_mpoly/mpolyu_gcdp_zippel.c
index ab0724960d..e054be6c76 100644
--- a/src/fq_nmod_mpoly/mpolyu_gcdp_zippel.c
+++ b/src/fq_nmod_mpoly/mpolyu_gcdp_zippel.c
@@ -588,7 +588,7 @@ nmod_gcds_ret_t fq_nmod_mpolyu_gcds_zippel(
{
for (k = 0; k < (f->coeffs + j)->length; k++)
{
- n_fq_get_fq_nmod((M + j)->rows[i] + k,
+ n_fq_get_fq_nmod(fq_nmod_mat_entry(M + j, i, k),
(fevalski->coeffs + j)->coeffs + d*k, ctx->fqctx);
}
}
@@ -658,10 +658,10 @@ nmod_gcds_ret_t fq_nmod_mpolyu_gcds_zippel(
{
for (j = 0; j < (f->coeffs + s)->length; j++)
{
- fq_nmod_set((ML + s)->rows[i] + j,
- (M + s)->rows[i] + j, ctx->fqctx);
+ fq_nmod_set(fq_nmod_mat_entry(ML + s, i, j),
+ fq_nmod_mat_entry(M + s, i, j), ctx->fqctx);
}
- fq_nmod_set((ML + s)->rows[i] + (f->coeffs + s)->length + i,
+ fq_nmod_set(fq_nmod_mat_entry(ML + s, i, (f->coeffs + s)->length + i),
W + l*s + i, ctx->fqctx);
}
} else {
@@ -669,18 +669,16 @@ nmod_gcds_ret_t fq_nmod_mpolyu_gcds_zippel(
{
for (j = 0; j < (f->coeffs + s)->length; j++)
{
- fq_nmod_set((ML + s)->rows[i] + j,
- (M + s)->rows[i] + j, ctx->fqctx);
+ fq_nmod_set(fq_nmod_mat_entry(ML + s, i, j),
+ fq_nmod_mat_entry(M + s, i, j), ctx->fqctx);
}
for (j = 0; j < l; j++) {
if (j == i)
{
- fq_nmod_set((ML + s)->rows[i]
- + (f->coeffs + s)->length + j,
+ fq_nmod_set(fq_nmod_mat_entry(ML + s, i, (f->coeffs + s)->length + j),
W + l*s + i, ctx->fqctx);
} else {
- fq_nmod_zero((ML + s)->rows[i]
- + (f->coeffs + s)->length + j,
+ fq_nmod_zero(fq_nmod_mat_entry(ML + s, i, (f->coeffs + s)->length + j),
ctx->fqctx);
}
}
@@ -691,7 +689,7 @@ nmod_gcds_ret_t fq_nmod_mpolyu_gcds_zippel(
for (i = 0; i < (f->coeffs + s)->length; i++)
{
- if (!fq_nmod_is_one((ML + s)->rows[i] + i, ctx->fqctx))
+ if (!fq_nmod_is_one(fq_nmod_mat_entry(ML + s, i, i), ctx->fqctx))
{
/* evaluation points produced a singular vandermonde matrix */
goto pick_evaluation_point;
@@ -756,7 +754,7 @@ nmod_gcds_ret_t fq_nmod_mpolyu_gcds_zippel(
{
FLINT_ASSERT((f->coeffs + i)->length <= l);
FLINT_ASSERT(j < (f->coeffs + tlen[f->length - 1])->length);
- fq_nmod_mul(b + j, W + l*i + j, Msol->rows[j] + 0, ctx->fqctx);
+ fq_nmod_mul(b + j, W + l*i + j, fq_nmod_mat_entry(Msol, j, 0), ctx->fqctx);
}
success = fq_nmod_vandsolve((G->coeffs + i)->coeffs,
(fevalsk1->coeffs + i)->coeffs, b,
@@ -782,11 +780,11 @@ nmod_gcds_ret_t fq_nmod_mpolyu_gcds_zippel(
for (j = 0; j < (f->coeffs + s)->length; j++)
{
n_fq_get_fq_nmod(u, (G->coeffs + s)->coeffs + d*j, ctx->fqctx);
- fq_nmod_mul(pp, (M + s)->rows[i] + j, u, ctx->fqctx);
+ fq_nmod_mul(pp, fq_nmod_mat_entry(M + s, i, j), u, ctx->fqctx);
fq_nmod_add(acc, acc, pp, ctx->fqctx);
}
- fq_nmod_mul(u, W + l*s + i, Msol->rows[i] + 0, ctx->fqctx);
+ fq_nmod_mul(u, W + l*s + i, fq_nmod_mat_entry(Msol, i, 0), ctx->fqctx);
if (!fq_nmod_equal(acc, u, ctx->fqctx))
{
fq_nmod_clear(acc, ctx->fqctx);
diff --git a/src/fq_nmod_types.h b/src/fq_nmod_types.h
index a58a493048..17986e1cdc 100644
--- a/src/fq_nmod_types.h
+++ b/src/fq_nmod_types.h
@@ -46,7 +46,7 @@ typedef struct
fq_nmod_struct * entries;
slong r;
slong c;
- fq_nmod_struct ** rows;
+ slong stride;
}
fq_nmod_mat_struct;
diff --git a/src/fq_poly_templates/compose_mod_brent_kung.c b/src/fq_poly_templates/compose_mod_brent_kung.c
index 8d94509b34..598c7bede8 100644
--- a/src/fq_poly_templates/compose_mod_brent_kung.c
+++ b/src/fq_poly_templates/compose_mod_brent_kung.c
@@ -56,33 +56,33 @@ _TEMPLATE(T, poly_compose_mod_brent_kung) (
/* Set rows of B to the segments of poly1 */
for (i = 0; i < len1 / m; i++)
- _TEMPLATE(T, vec_set) (B->rows[i], poly1 + i * m, m, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (B, i, 0), poly1 + i * m, m, ctx);
- _TEMPLATE(T, vec_set) (B->rows[i], poly1 + i * m, len1 % m, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (B, i, 0), poly1 + i * m, len1 % m, ctx);
/* Set rows of A to powers of poly2 */
- TEMPLATE(T, one) (A->rows[0], ctx);
- _TEMPLATE(T, vec_set) (A->rows[1], poly2, n, ctx);
+ TEMPLATE(T, one) (TEMPLATE(T, mat_entry) (A, 0, 0), ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (A, 1, 0), poly2, n, ctx);
tmp = _TEMPLATE(T, vec_init) (2 * n - 1, ctx);
for (i = 2; i < m; i++)
{
- _TEMPLATE(T, poly_mulmod) (tmp, A->rows[i - 1], n, poly2, n, poly3,
+ _TEMPLATE(T, poly_mulmod) (tmp, TEMPLATE(T, mat_entry) (A, i - 1, 0), n, poly2, n, poly3,
len3, ctx);
- _TEMPLATE(T, vec_set) (A->rows[i], tmp, n, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (A, i, 0), tmp, n, ctx);
}
_TEMPLATE(T, vec_clear) (tmp, 2 * n - 1, ctx);
TEMPLATE(T, mat_mul) (C, B, A, ctx);
/* Evaluate block composition using the Horner scheme */
- _TEMPLATE(T, vec_set) (res, C->rows[m - 1], n, ctx);
- _TEMPLATE(T, poly_mulmod) (h, A->rows[m - 1], n, poly2, n, poly3, len3,
+ _TEMPLATE(T, vec_set) (res, TEMPLATE(T, mat_entry) (C, m - 1, 0), n, ctx);
+ _TEMPLATE(T, poly_mulmod) (h, TEMPLATE(T, mat_entry) (A, m - 1, 0), n, poly2, n, poly3, len3,
ctx);
for (i = m - 2; i >= 0; i--)
{
_TEMPLATE(T, poly_mulmod) (t, res, n, h, n, poly3, len3, ctx);
- _TEMPLATE(T, poly_add) (res, t, n, C->rows[i], n, ctx);
+ _TEMPLATE(T, poly_add) (res, t, n, TEMPLATE(T, mat_entry) (C, i, 0), n, ctx);
}
_TEMPLATE(T, vec_clear) (h, 2 * n - 1, ctx);
diff --git a/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c b/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c
index 215187cabc..8add07aed8 100644
--- a/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c
+++ b/src/fq_poly_templates/compose_mod_brent_kung_precomp_preinv.c
@@ -33,7 +33,7 @@ _TEMPLATE(T, poly_reduce_matrix_mod_poly) (TEMPLATE(T, mat_t) A,
TEMPLATE(T, init) (invf, ctx);
TEMPLATE(T, inv) (invf, f->coeffs + (f->length - 1), ctx);
for (i = 1; i < m; i++)
- _TEMPLATE(T, poly_rem) (A->rows[i], B->rows[i], B->c, f->coeffs,
+ _TEMPLATE(T, poly_rem) (TEMPLATE(T, mat_entry) (A, i, 0), TEMPLATE(T, mat_entry) (B, i, 0), B->c, f->coeffs,
f->length, invf, ctx);
TEMPLATE(T, clear) (invf, ctx);
}
@@ -54,9 +54,9 @@ _TEMPLATE(T, poly_precompute_matrix) (
m = n_sqrt(n) + 1;
TEMPLATE(T, one) (TEMPLATE(T, mat_entry) (A, 0, 0), ctx);
- _TEMPLATE(T, vec_set) (A->rows[1], poly1, n, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (A, 1, 0), poly1, n, ctx);
for (i = 2; i < m; i++)
- _TEMPLATE(T, poly_mulmod_preinv) (A->rows[i], A->rows[i - 1],
+ _TEMPLATE(T, poly_mulmod_preinv) (TEMPLATE(T, mat_entry) (A, i, 0), TEMPLATE(T, mat_entry) (A, i - 1, 0),
n, poly1, n, poly2, len2,
poly2inv, len2inv, ctx);
}
@@ -159,22 +159,22 @@ _TEMPLATE(T, poly_compose_mod_brent_kung_precomp_preinv) (
/* Set rows of B to the segments of poly1 */
for (i = 0; i < len1 / m; i++)
- _TEMPLATE(T, vec_set) (B->rows[i], poly1 + i * m, m, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (B, i, 0), poly1 + i * m, m, ctx);
- _TEMPLATE(T, vec_set) (B->rows[i], poly1 + i * m, len1 % m, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (B, i, 0), poly1 + i * m, len1 % m, ctx);
TEMPLATE(T, mat_mul) (C, B, A, ctx);
/* Evaluate block composition using the Horner scheme */
- _TEMPLATE(T, vec_set) (res, C->rows[m - 1], n, ctx);
- _TEMPLATE(T, poly_mulmod_preinv) (h, A->rows[m - 1], n, A->rows[1], n,
+ _TEMPLATE(T, vec_set) (res, TEMPLATE(T, mat_entry) (C, m - 1, 0), n, ctx);
+ _TEMPLATE(T, poly_mulmod_preinv) (h, TEMPLATE(T, mat_entry) (A, m - 1, 0), n, TEMPLATE(T, mat_entry) (A, 1, 0), n,
poly3, len3, poly3inv, len3inv, ctx);
for (i = m - 2; i >= 0; i--)
{
_TEMPLATE(T, poly_mulmod_preinv) (t, res, n, h, n, poly3, len3,
poly3inv, len3inv, ctx);
- _TEMPLATE(T, poly_add) (res, t, n, C->rows[i], n, ctx);
+ _TEMPLATE(T, poly_add) (res, t, n, TEMPLATE(T, mat_entry) (C, i, 0), n, ctx);
}
_TEMPLATE(T, vec_clear) (h, n, ctx);
diff --git a/src/fq_poly_templates/compose_mod_brent_kung_preinv.c b/src/fq_poly_templates/compose_mod_brent_kung_preinv.c
index 36aa4e397f..ceab8dd8c0 100644
--- a/src/fq_poly_templates/compose_mod_brent_kung_preinv.c
+++ b/src/fq_poly_templates/compose_mod_brent_kung_preinv.c
@@ -58,34 +58,34 @@ _TEMPLATE(T, poly_compose_mod_brent_kung_preinv) (
/* Set rows of B to the segments of poly1 */
for (i = 0; i < len1 / m; i++)
- _TEMPLATE(T, vec_set) (B->rows[i], poly1 + i * m, m, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (B, i, 0), poly1 + i * m, m, ctx);
- _TEMPLATE(T, vec_set) (B->rows[i], poly1 + i * m, len1 % m, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (B, i, 0), poly1 + i * m, len1 % m, ctx);
/* Set rows of A to powers of poly2 */
- TEMPLATE(T, one) (A->rows[0], ctx);
- _TEMPLATE(T, vec_set) (A->rows[1], poly2, n, ctx);
+ TEMPLATE(T, one) (TEMPLATE(T, mat_entry) (A, 0, 0), ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (A, 1, 0), poly2, n, ctx);
tmp = _TEMPLATE(T, vec_init) (2 * n - 1, ctx);
for (i = 2; i < m; i++)
{
- _TEMPLATE(T, poly_mulmod_preinv) (tmp, A->rows[i - 1], n, poly2, n,
+ _TEMPLATE(T, poly_mulmod_preinv) (tmp, TEMPLATE(T, mat_entry) (A, i - 1, 0), n, poly2, n,
poly3, len3, poly3inv, len3inv, ctx);
- _TEMPLATE(T, vec_set) (A->rows[i], tmp, n, ctx);
+ _TEMPLATE(T, vec_set) (TEMPLATE(T, mat_entry) (A, i, 0), tmp, n, ctx);
}
_TEMPLATE(T, vec_clear) (tmp, 2 * n - 1, ctx);
TEMPLATE(T, mat_mul) (C, B, A, ctx);
/* Evaluate block composition using the Horner scheme */
- _TEMPLATE(T, vec_set) (res, C->rows[m - 1], n, ctx);
- _TEMPLATE(T, poly_mulmod_preinv) (h, A->rows[m - 1], n, poly2, n, poly3,
+ _TEMPLATE(T, vec_set) (res, TEMPLATE(T, mat_entry) (C, m - 1, 0), n, ctx);
+ _TEMPLATE(T, poly_mulmod_preinv) (h, TEMPLATE(T, mat_entry) (A, m - 1, 0), n, poly2, n, poly3,
len3, poly3inv, len3inv, ctx);
for (i = m - 2; i >= 0; i--)
{
_TEMPLATE(T, poly_mulmod_preinv) (t, res, n, h, n, poly3, len3,
poly3inv, len3inv, ctx);
- _TEMPLATE(T, poly_add) (res, t, n, C->rows[i], n, ctx);
+ _TEMPLATE(T, poly_add) (res, t, n, TEMPLATE(T, mat_entry) (C, i, 0), n, ctx);
}
_TEMPLATE(T, vec_clear) (h, 2 * n - 1, ctx);
diff --git a/src/fq_types.h b/src/fq_types.h
index fc48247857..84b8ec9b22 100644
--- a/src/fq_types.h
+++ b/src/fq_types.h
@@ -46,7 +46,7 @@ typedef struct
fq_struct * entries;
slong r;
slong c;
- fq_struct ** rows;
+ slong stride;
}
fq_mat_struct;
diff --git a/src/fq_zech_types.h b/src/fq_zech_types.h
index d63dcbea8e..1def8a84da 100644
--- a/src/fq_zech_types.h
+++ b/src/fq_zech_types.h
@@ -51,7 +51,7 @@ typedef struct
fq_zech_struct * entries;
slong r;
slong c;
- fq_zech_struct ** rows;
+ slong stride;
}
fq_zech_mat_struct;
diff --git a/src/gr/acf.c b/src/gr/acf.c
index 4b9eee80b4..d9a88815ec 100644
--- a/src/gr/acf.c
+++ b/src/gr/acf.c
@@ -1242,8 +1242,8 @@ _gr_acf_mat_diagonalization(gr_vec_t D, gr_mat_t L, gr_mat_t R, const gr_mat_t A
{
for (j = 0; j < n; j++)
{
- arf_set(acf_realref(((acf_ptr) L->rows[i]) + j), arb_midref(acb_realref(acb_mat_entry(L_acb, i, j))));
- arf_set(acf_imagref(((acf_ptr) L->rows[i]) + j), arb_midref(acb_imagref(acb_mat_entry(L_acb, i, j))));
+ arf_set(acf_realref(ACF_MAT_ENTRY(L, i, j), arb_midref(acb_realref(acb_mat_entry(L_acb, i, j))));
+ arf_set(acf_imagref(ACF_MAT_ENTRY(L, i, j), arb_midref(acb_imagref(acb_mat_entry(L_acb, i, j))));
}
}
}
diff --git a/src/mpn_mod/profile/p-mat_mul.c b/src/mpn_mod/profile/p-mat_mul.c
index 339706de00..8f37f07bce 100644
--- a/src/mpn_mod/profile/p-mat_mul.c
+++ b/src/mpn_mod/profile/p-mat_mul.c
@@ -53,7 +53,7 @@ randmat(gr_mat_t mat, flint_rand_t state, gr_ctx_t ctx)
slong i;
for (i = 0; i < mat->r; i++)
- randvec(mat->rows[i], state, mat->c, ctx);
+ randvec(gr_mat_entry_ptr(mat, i, 0, ctx), state, mat->c, ctx);
}
slong cutoff_bits[1000];
diff --git a/src/mpn_mod/profile/p-mat_vs_fmpz_mod.c b/src/mpn_mod/profile/p-mat_vs_fmpz_mod.c
index 2264d8c587..8109518862 100644
--- a/src/mpn_mod/profile/p-mat_vs_fmpz_mod.c
+++ b/src/mpn_mod/profile/p-mat_vs_fmpz_mod.c
@@ -51,7 +51,7 @@ randmat(gr_mat_t mat, flint_rand_t state, slong bits, gr_ctx_t ctx)
slong i;
for (i = 0; i < mat->r; i++)
- randvec(mat->rows[i], state, mat->c, bits, ctx);
+ randvec(gr_mat_entry_ptr(mat, i, 0, ctx), state, mat->c, bits, ctx);
}
int main()
diff --git a/src/nfloat/profile/p-complex_mat_mul.c b/src/nfloat/profile/p-complex_mat_mul.c
index 6dbd4a1d8a..d0f9ac37f5 100644
--- a/src/nfloat/profile/p-complex_mat_mul.c
+++ b/src/nfloat/profile/p-complex_mat_mul.c
@@ -136,7 +136,7 @@ void prof_classical_vs_fixed()
{
gr_ctx_t ctx;
gr_mat_t A, B, C;
- slong i, ni, n;
+ slong ni, n;
slong prec;
double FLINT_SET_BUT_UNUSED(__), t1, t2;
@@ -244,7 +244,7 @@ void prof_fixed_vs_block()
{
gr_ctx_t ctx;
gr_mat_t A, B, C;
- slong i, ni, n;
+ slong ni, n;
slong prec;
double FLINT_SET_BUT_UNUSED(__), t1, t2;
@@ -357,7 +357,7 @@ void prof_mul()
{
gr_ctx_t ctx;
gr_mat_t A, B, C;
- slong i, ni, n;
+ slong ni, n;
slong prec;
double FLINT_SET_BUT_UNUSED(__), t1, t2;
@@ -411,7 +411,7 @@ void prof_mul()
int main()
{
- int tab[TABN];
+ //int tab[TABN];
//tune_classical_vs_fixed(tab);
//tune_fixed_vs_block(tab);
diff --git a/src/nfloat/profile/p-mat_mul.c b/src/nfloat/profile/p-mat_mul.c
index 5a0163d373..d15eb7a393 100644
--- a/src/nfloat/profile/p-mat_mul.c
+++ b/src/nfloat/profile/p-mat_mul.c
@@ -132,7 +132,7 @@ void prof_classical_vs_fixed()
{
gr_ctx_t ctx;
gr_mat_t A, B, C;
- slong i, ni, n;
+ slong ni, n;
slong prec;
double FLINT_SET_BUT_UNUSED(__), t1, t2;
@@ -240,7 +240,7 @@ void prof_fixed_vs_block()
{
gr_ctx_t ctx;
gr_mat_t A, B, C;
- slong i, ni, n;
+ slong ni, n;
slong prec;
double FLINT_SET_BUT_UNUSED(__), t1, t2;
@@ -353,7 +353,7 @@ void prof_mul()
{
gr_ctx_t ctx;
gr_mat_t A, B, C;
- slong i, ni, n;
+ slong ni, n;
slong prec;
double FLINT_SET_BUT_UNUSED(__), t1, t2;
@@ -407,7 +407,7 @@ void prof_mul()
int main()
{
- int tab[TABN];
+ //int tab[TABN];
//tune_classical_vs_fixed(tab);
//tune_fixed_vs_block(tab);
diff --git a/src/nfloat/profile/p-nfixed_mat_mul.c b/src/nfloat/profile/p-nfixed_mat_mul.c
index dc6cabd5b7..5759a17298 100644
--- a/src/nfloat/profile/p-nfixed_mat_mul.c
+++ b/src/nfloat/profile/p-nfixed_mat_mul.c
@@ -213,7 +213,7 @@ void tune_strassen(int * cutoffs)
void prof_strassen_1()
{
nn_ptr A, B, C;
- slong i, n, nlimbs;
+ slong n, nlimbs;
int parity;
double FLINT_SET_BUT_UNUSED(__), t1, t2;
@@ -259,8 +259,8 @@ void prof_strassen_1()
int main()
{
- int tab_fixed_classical_vs_waksman[TABN];
- int tab_strassen[TABN];
+ //int tab_fixed_classical_vs_waksman[TABN];
+ //int tab_strassen[TABN];
//tune_fixed_vs_waksman(tab_fixed_classical_vs_waksman);
//tune_strassen(tab_strassen);