Commits

CarloWood  committed 9cf8d71

More constness fixes.

This should cause all pointers passed to functions
to be a pointer-to-const when the content is not changed.

I needed to introduce mzd_init_window_const, which creates
a window into a const mzd_t, returning mzd_t const* as well.
I decided to demand an explicit cast when freeing such
a window (we can fix that later once I added flags to mzd_t,
and add runtime checking when freeing a const window,
removing the need for explicit casts).

Also fixed a few -Wall compiler warnings that sneaked
into the testsuite.

  • Participants
  • Parent commits 2a1345b

Comments (0)

Files changed (15)

File src/brilliantrussian.c

   }
 }
 
-void mzd_make_table(mzd_t *M, rci_t r, rci_t c, int k, mzd_t *T, rci_t *L)
+void mzd_make_table(mzd_t const *M, rci_t r, rci_t c, int k, mzd_t *T, rci_t *L)
 {
   wi_t const homeblock = (c + M->offset) / m4ri_radix;
   word const mask_end = __M4RI_LEFT_BITMASK((M->ncols + M->offset) % m4ri_radix);
   }
 }
 
-void mzd_process_rows(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, mzd_t *T, rci_t *L) {
+void mzd_process_rows(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, mzd_t const *T, rci_t const *L) {
   wi_t const block = startcol / m4ri_radix;
   wi_t const wide = M->width - block;
   wi_t const count = (wide + 7) / 8;	/* Unrolled loop count */
   }
 }
 
-void mzd_process_rows2(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1) {
+void mzd_process_rows2(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1) {
   wi_t const blocknum = startcol / m4ri_radix;
   wi_t const wide = M->width - blocknum;
   wi_t const count = (wide + 7) / 8;	/* Unrolled loop count */
   }
 }
 
-void mzd_process_rows3(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1, mzd_t *T2, rci_t *L2) {
+void mzd_process_rows3(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k,
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1, mzd_t const *T2, rci_t const *L2) {
   wi_t const blocknum = startcol / m4ri_radix;
   wi_t const wide = M->width - blocknum;
   wi_t const count = (wide + 7) / 8;	/* Unrolled loop count */
 }
 
 void mzd_process_rows4(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, 
-                       mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1, mzd_t *T2, rci_t *L2, mzd_t *T3, rci_t *L3) {
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1, mzd_t const *T2, rci_t const *L2, mzd_t const *T3, rci_t const *L3) {
   wi_t const blocknum = startcol / m4ri_radix;
   wi_t const wide = M->width - blocknum;
   wi_t const count = (wide + 7) / 8;	/* Unrolled loop count */
 }
 
 void mzd_process_rows5(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, 
-                       mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1, mzd_t *T2, rci_t *L2, mzd_t *T3, rci_t *L3,
-                       mzd_t *T4, rci_t *L4) {
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1, mzd_t const *T2, rci_t const *L2,
+		       mzd_t const *T3, rci_t const *L3, mzd_t const *T4, rci_t const *L4) {
   wi_t const blocknum = startcol / m4ri_radix;
   wi_t const wide = M->width - blocknum;
   wi_t const count = (wide + 7) / 8;	/* Unrolled loop count */
 }
 
 void mzd_process_rows6(mzd_t *M, rci_t startrow, rci_t stoprow, rci_t startcol, int k, 
-                       mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1, mzd_t *T2, rci_t *L2, mzd_t *T3, rci_t *L3,
-                       mzd_t *T4, rci_t *L4, mzd_t *T5, rci_t *L5) {
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1, mzd_t const *T2,
+		       rci_t const *L2, mzd_t const *T3, rci_t const *L3, mzd_t const *T4, rci_t const *L4,
+		       mzd_t const *T5, rci_t const *L5) {
   wi_t const blocknum = startcol / m4ri_radix;
   wi_t const wide = M->width - blocknum;
   wi_t const count = (wide + 7) / 8;	/* Unrolled loop count */
   _mzd_top_echelonize_m4ri(M,k,0,0,M->nrows);
 }
 
-
-mzd_t *mzd_invert_m4ri(mzd_t *m, mzd_t *I, int k) {
+mzd_t *mzd_invert_m4ri(mzd_t const *m, mzd_t const *I, int k) {
   mzd_t *big = mzd_concat(NULL, m, I);
   rci_t size = m->ncols;
   if (k == 0)
   return answer;
 }
 
-mzd_t *mzd_mul_m4rm(mzd_t *C, mzd_t *A, mzd_t *B, int k) {
+mzd_t *mzd_mul_m4rm(mzd_t *C, mzd_t const *A, mzd_t const *B, int k) {
   rci_t a = A->nrows;
   rci_t c = B->ncols;
 
   return _mzd_mul_m4rm(C, A, B, k, TRUE);
 }
 
-mzd_t *mzd_addmul_m4rm(mzd_t *C, mzd_t *A, mzd_t *B, int k) {
+mzd_t *mzd_addmul_m4rm(mzd_t *C, mzd_t const *A, mzd_t const *B, int k) {
   rci_t a = A->nrows;
   rci_t c = B->ncols;
 
   return _mzd_mul_m4rm(C, A, B, k, FALSE);
 }
 
-mzd_t *_mzd_mul_m4rm(mzd_t *C, mzd_t *A, mzd_t *B, int k, int clear) {
+mzd_t *_mzd_mul_m4rm(mzd_t *C, mzd_t const *A, mzd_t const *B, int k, int clear) {
   /**
    * The algorithm proceeds as follows:
    * 

File src/brilliantrussian.h

  * \brief Constructs all possible \f$2^k\f$ row combinations using the gray
  * code table.
  * 
- * \param M matrix to operate on
+ * \param M matrix to generate the tables from
  * \param r the starting row
  * \param c the starting column (only exact up to block)
  * \param k
  * \wordoffset
  */
 
-void mzd_make_table(mzd_t *M, rci_t r, rci_t c, int k, mzd_t *T, rci_t *L);
+void mzd_make_table(mzd_t const *M, rci_t r, rci_t c, int k, mzd_t *T, rci_t *L);
 
 /**
  * \brief The function looks up k bits from position i,startcol in
  * \wordoffset
  */
 
-void mzd_process_rows(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k, mzd_t *T, rci_t *L);
+void mzd_process_rows(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k, mzd_t const *T, rci_t const *L);
 
 /**
  * \brief Same as mzd_process_rows but works with two Gray code tables
  * \wordoffset
  */
 
-void mzd_process_rows2(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k, mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1);
+void mzd_process_rows2(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k, mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1);
 
 /**
  * \brief Same as mzd_process_rows but works with three Gray code tables
  */
 
 void mzd_process_rows3(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k, 
-                       mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1,
-                       mzd_t *T2, rci_t *L2);
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1,
+                       mzd_t const *T2, rci_t const *L2);
 
 /**
  * \brief Same as mzd_process_rows but works with four Gray code tables
  */
 
 void mzd_process_rows4(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k,
-                       mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1,
-                       mzd_t *T2, rci_t *L2, mzd_t *T3, rci_t *L3);
-
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1,
+                       mzd_t const *T2, rci_t const *L2, mzd_t const *T3, rci_t const *L3);
 
 /**
  * \brief Same as mzd_process_rows but works with five Gray code tables
  */
 
 void mzd_process_rows5(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k,
-                       mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1,
-                       mzd_t *T2, rci_t *L2, mzd_t *T3, rci_t *L3,
-                       mzd_t *T4, rci_t *L4);
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1,
+                       mzd_t const *T2, rci_t const *L2, mzd_t const *T3, rci_t const *L3,
+                       mzd_t const *T4, rci_t const *L4);
 
 /**
  * \brief Same as mzd_process_rows but works with six Gray code tables
  */
 
 void mzd_process_rows6(mzd_t *M, rci_t startrow, rci_t endrow, rci_t startcol, int k,
-                       mzd_t *T0, rci_t *L0, mzd_t *T1, rci_t *L1,
-                       mzd_t *T2, rci_t *L2, mzd_t *T3, rci_t *L3,
-                       mzd_t *T4, rci_t *L4, mzd_t *T5, rci_t *L5);
+                       mzd_t const *T0, rci_t const *L0, mzd_t const *T1, rci_t const *L1,
+                       mzd_t const *T2, rci_t const *L2, mzd_t const *T3, rci_t const *L3,
+                       mzd_t const *T4, rci_t const *L4, mzd_t const *T5, rci_t const *L5);
 
 /**
  * \brief Matrix elimination using the 'Method of the Four Russians'
  * must be free'd using mzd_free() once it is not needed anymore.
  */
 
-mzd_t *mzd_invert_m4ri(mzd_t *M, mzd_t *I, int k);
+mzd_t *mzd_invert_m4ri(mzd_t const *M, mzd_t const *I, int k);
 
 /**
  * \brief Matrix multiplication using Konrod's method, i.e. compute C
  * \return Pointer to C.
  */
 
-mzd_t *mzd_mul_m4rm(mzd_t *C, mzd_t *A, mzd_t *B, int k);
+mzd_t *mzd_mul_m4rm(mzd_t *C, mzd_t const *A, mzd_t const *B, int k);
 
 
 /**
  * \return Pointer to C.
  */
 
-mzd_t *mzd_addmul_m4rm(mzd_t *C, mzd_t *A, mzd_t *B, int k);
+mzd_t *mzd_addmul_m4rm(mzd_t *C, mzd_t const *A, mzd_t const *B, int k);
 
 /**
  * \brief Matrix multiplication using Konrod's method, i.e. compute C such
  * \return Pointer to C.
  */
 
-mzd_t *_mzd_mul_m4rm(mzd_t *C, mzd_t *A, mzd_t *B, int k, int clear);
+mzd_t *_mzd_mul_m4rm(mzd_t *C, mzd_t const *A, mzd_t const *B, int k, int clear);
 
 /**
  * \brief If defined 8 Gray code tables are used in parallel.

File src/packedmatrix.c

   return A;
 }
 
-mzd_t *mzd_init_window (mzd_t const *m, rci_t lowr, rci_t lowc, rci_t highr, rci_t highc) {
+mzd_t *mzd_init_window (mzd_t *m, rci_t lowr, rci_t lowc, rci_t highr, rci_t highc) {
   rci_t nrows, ncols;
   mzd_t *window;
   window = (mzd_t*)m4ri_mmc_malloc(sizeof(mzd_t));
   rci_t nr2 = (X->nrows > 256) ? 2 * m4ri_radix * (X->nrows / (4 * m4ri_radix)) : m4ri_radix * (X->nrows / (2 * m4ri_radix));
   rci_t nc2 = (X->ncols > 256) ? 2 * m4ri_radix * (X->ncols / (4 * m4ri_radix)) : m4ri_radix * (X->ncols / (2 * m4ri_radix));
 
-  mzd_t *A = mzd_init_window(X,    0,   0, nr2, nc2);
-  mzd_t *B = mzd_init_window(X,    0, nc2, nr2,  nc);
-  mzd_t *C = mzd_init_window(X,  nr2,   0,  nr, nc2);
-  mzd_t *D = mzd_init_window(X,  nr2, nc2,  nr,  nc);
+  mzd_t const *A = mzd_init_window_const(X,    0,   0, nr2, nc2);
+  mzd_t const *B = mzd_init_window_const(X,    0, nc2, nr2,  nc);
+  mzd_t const *C = mzd_init_window_const(X,  nr2,   0,  nr, nc2);
+  mzd_t const *D = mzd_init_window_const(X,  nr2, nc2,  nr,  nc);
 
   mzd_t *AT = mzd_init_window(DST,   0,   0, nc2, nr2);
   mzd_t *CT = mzd_init_window(DST,   0, nr2, nc2,  nr);
   _mzd_transpose(CT, C);
   _mzd_transpose(DT, D);
 
-  mzd_free_window(A); mzd_free_window(B);
-  mzd_free_window(C); mzd_free_window(D);
+  mzd_free_window((mzd_t*)A); mzd_free_window((mzd_t*)B);
+  mzd_free_window((mzd_t*)C); mzd_free_window((mzd_t*)D);
 
   mzd_free_window(AT); mzd_free_window(CT);
   mzd_free_window(BT); mzd_free_window(DT);

File src/packedmatrix.h

  *
  */
 
-mzd_t *mzd_init_window(mzd_t const *M, rci_t const lowr, rci_t const lowc, rci_t const highr, rci_t const highc);
+mzd_t *mzd_init_window(mzd_t *M, rci_t const lowr, rci_t const lowc, rci_t const highr, rci_t const highc);
+
+/**
+ * \brief Create a const window/view into a const matrix M.
+ *
+ * See mzd_init_window, but for constant M.
+ */
+
+static inline mzd_t const *mzd_init_window_const(mzd_t const *M, rci_t const lowr, rci_t const lowc, rci_t const highr, rci_t const highc)
+{
+  return mzd_init_window((mzd_t*)M, lowr, lowc, highr, highc);
+}
 
 /**
  * \brief Free a matrix window created with mzd_init_window.

File src/permutation.c

   }
 }
 
-void mzd_apply_p_left(mzd_t *A, mzp_t *P) {
+void mzd_apply_p_left(mzd_t *A, mzp_t const *P) {
   if(A->ncols == 0)
     return;
   rci_t const length = MIN(P->length, A->nrows);
   }
 }
 
-void mzd_apply_p_left_trans(mzd_t *A, mzp_t *P) {
+void mzd_apply_p_left_trans(mzd_t *A, mzp_t const *P) {
   if(A->ncols == 0)
     return;
   rci_t const length = MIN(P->length, A->nrows);
 /**
  * Implements both apply_p_right and apply_p_right_trans.
  */
-void _mzd_apply_p_right_even(mzd_t *A, mzp_t *P, rci_t start_row, rci_t start_col, int notrans) {
+void _mzd_apply_p_right_even(mzd_t *A, mzp_t const *P, rci_t start_row, rci_t start_col, int notrans) {
   assert(A->offset == 0);
   if(A->nrows - start_row == 0)
     return;
   mzd_free(B);
 }
 
-void _mzd_apply_p_right_trans(mzd_t *A, mzp_t *P) {
+void _mzd_apply_p_right_trans(mzd_t *A, mzp_t const *P) {
   if(A->nrows == 0)
     return;
   rci_t const length = MIN(P->length, A->ncols);
 /*   } */
 }
 
-void _mzd_apply_p_right(mzd_t *A, mzp_t *P) {
+void _mzd_apply_p_right(mzd_t *A, mzp_t const *P) {
   if(A->nrows == 0)
     return;
   int const step_size = MAX((__M4RI_CPU_L1_CACHE >> 3) / A->width, 1);
 }
 
 
-void mzd_apply_p_right_trans(mzd_t *A, mzp_t *P) {
+void mzd_apply_p_right_trans(mzd_t *A, mzp_t const *P) {
   if(!A->nrows)
     return;
   if(A->offset) {
   _mzd_apply_p_right_even(A, P, 0, 0, 0); 
 }
 
-void mzd_apply_p_right(mzd_t *A, mzp_t *P) {
+void mzd_apply_p_right(mzd_t *A, mzp_t const *P) {
   if(!A->nrows)
     return;
   if(A->offset) {
   _mzd_apply_p_right_even(A, P, 0, 0, 1); 
 }
 
-void mzd_apply_p_right_trans_even_capped(mzd_t *A, mzp_t *P, rci_t start_row, rci_t start_col) {
+void mzd_apply_p_right_trans_even_capped(mzd_t *A, mzp_t const *P, rci_t start_row, rci_t start_col) {
   assert(A->offset == 0);
   if(!A->nrows)
     return;
   _mzd_apply_p_right_even(A, P, start_row, start_col, 0); 
 }
 
-void mzd_apply_p_right_even_capped(mzd_t *A, mzp_t *P, rci_t start_row, rci_t start_col) {
+void mzd_apply_p_right_even_capped(mzd_t *A, mzp_t const *P, rci_t start_row, rci_t start_col) {
   assert(A->offset == 0);
   if(!A->nrows)
     return;
   _mzd_apply_p_right_even(A, P, start_row, start_col, 1); 
 }
 
-void mzp_print(mzp_t *P) {
+void mzp_print(mzp_t const *P) {
   printf("[ ");
   for(rci_t i = 0; i < P->length; ++i) {
     printf("%zd ", (size_t)P->values[i]);
   printf("]");
 }
 
-void mzd_apply_p_right_trans_tri(mzd_t *A, mzp_t *P) {
+void mzd_apply_p_right_trans_tri(mzd_t *A, mzp_t const *P) {
   assert(P->length == A->ncols);
   int const step_size = MAX((__M4RI_CPU_L1_CACHE >> 2) / A->width, 1);
 

File src/permutation.h

  * \param P Permutation.
  */
 
-void mzd_apply_p_left(mzd_t *A, mzp_t *P);
+void mzd_apply_p_left(mzd_t *A, mzp_t const *P);
 
 /**
  * Apply the permutation P to A from the left but transpose P before.
  * \param P Permutation.
  */
 
-void mzd_apply_p_left_trans(mzd_t *A, mzp_t *P);
+void mzd_apply_p_left_trans(mzd_t *A, mzp_t const *P);
 
 /**
  * Apply the permutation P to A from the right.
  * \param P Permutation.
  */
 
-void mzd_apply_p_right(mzd_t *A, mzp_t *P);
+void mzd_apply_p_right(mzd_t *A, mzp_t const *P);
 
 /**
  * Apply the permutation P to A from the right but transpose P before.
  * \param P Permutation.
  */
 
-void mzd_apply_p_right_trans(mzd_t *A, mzp_t *P);
+void mzd_apply_p_right_trans(mzd_t *A, mzp_t const *P);
 
 
 /**
  * \wordoffset
  */
 
-void mzd_apply_p_right_even_capped(mzd_t *A, mzp_t *P, rci_t start_row, rci_t start_col);
+void mzd_apply_p_right_even_capped(mzd_t *A, mzp_t const *P, rci_t start_row, rci_t start_col);
 
 /**
  * Apply the permutation P^T to A from the right starting at start_row.
  * \wordoffset
  */
 
-void mzd_apply_p_right_trans_even_capped(mzd_t *A, mzp_t *P, rci_t start_row, rci_t start_col);
+void mzd_apply_p_right_trans_even_capped(mzd_t *A, mzp_t const *P, rci_t start_row, rci_t start_col);
 
 /**
  * Apply the mzp_t P to A from the right but transpose P before.
  * \param P Permutation.
  */
 
-void mzd_apply_p_right_trans(mzd_t *A, mzp_t *P);
+void mzd_apply_p_right_trans(mzd_t *A, mzp_t const *P);
 
 
 /**
  * \param A Matrix.
  * \param Q Permutation.
  */
-void  mzd_apply_p_right_trans_tri(mzd_t *A, mzp_t *Q);
+void  mzd_apply_p_right_trans_tri(mzd_t *A, mzp_t const *Q);
 
 /**
  * Print the mzp_t P
  * \param P Permutation.
  */
 
-void mzp_print(mzp_t *P);
+void mzp_print(mzp_t const *P);
 
 /**
  * Compresses the matrix L in a step in blockwise-recursive PLS
   if (ncols <= m4ri_radix || A->width * A->nrows <= __M4RI_PLS_CUTOFF) {
 /*   if(ncols <= __M4RI_PLUQ_CUTOFF) { */
     /* this improves data locality and runtime considerably */
-    mzd_t *Abar = mzd_copy(NULL, A);
-    rci_t r = _mzd_pls_mmpf(Abar, P, Q, 0);
+    mzd_t *Abar = mzd_copy(NULL, A);				// FIXME: Why is A copied to Abar
+    rci_t r = _mzd_pls_mmpf(Abar, P, Q, 0);			// changed
     //rci_t r = _mzd_pls_naive(Abar, P, Q);
-    mzd_copy(A, Abar);
+    mzd_copy(A, Abar);						// and copied back to A? Can't we work on A directly?
     mzd_free(Abar);
     return r;
   }
   return _mzd_solve_left(A, B, cutoff, inconsistency_check);
 }
  
-int mzd_pluq_solve_left (mzd_t *A, rci_t rank, 
-                         mzp_t *P, mzp_t *Q, 
+int mzd_pluq_solve_left (mzd_t const *A, rci_t rank, 
+                         mzp_t const *P, mzp_t const *Q, 
                          mzd_t *B, int const cutoff, int const inconsistency_check) {
   if(A->ncols > B->nrows)
     m4ri_die("mzd_pluq_solve_left: A ncols (%d) need to be lower than B nrows (%d).\n", A->ncols, B->nrows);
   return _mzd_pluq_solve_left (A, rank, P, Q, B, cutoff, inconsistency_check);
 }
 
-int _mzd_pluq_solve_left(mzd_t *A, rci_t rank, 
-                         mzp_t *P, mzp_t *Q, 
+int _mzd_pluq_solve_left(mzd_t const *A, rci_t rank, 
+                         mzp_t const *P, mzp_t const *Q, 
                          mzd_t *B, int const cutoff, int const inconsistency_check) {
   /** A is supposed to store L lower triangular and U upper triangular
    *  B is modified in place 
   /* L B3 = B2 */
   
   /* view on the upper part of L */
-  mzd_t *LU = mzd_init_window(A, 0, 0, rank, rank);
+  mzd_t const *LU = mzd_init_window_const(A, 0, 0, rank, rank);
   mzd_t *Y1 = mzd_init_window(B, 0, 0, rank, B->ncols);
   mzd_trsm_lower_left(LU, Y1, cutoff);
 
   if (inconsistency_check) { /* Check for inconsistency */    
     /** FASTER without this check; update with the lower part of L
      */
-    mzd_t *H  = mzd_init_window(A, rank, 0, A->nrows, rank);
+    mzd_t const *H  = mzd_init_window_const(A, rank, 0, A->nrows, rank);
     mzd_t *Y2 = mzd_init_window(B, rank, 0, A->nrows, B->ncols);
     if(A->nrows < B->nrows) {
       mzd_t *Y3 = mzd_init_window(B, A->nrows, 0, B->nrows, B->ncols);
     if(!mzd_is_zero(Y2)) {
       retval = -1;
     }
-    mzd_free_window(H);
+    mzd_free_window((mzd_t*)H);
     mzd_free_window(Y2);
   }
   /* U B4 = B3 */
   mzd_trsm_upper_left(LU, Y1, cutoff);
-  mzd_free_window(LU);
+  mzd_free_window((mzd_t*)LU);
   mzd_free_window(Y1);
   
   if (!inconsistency_check) {
  *        system is not consistent).
  * \return 0 if a solution was found, -1 otherwise
  */
-int mzd_solve_left(mzd_t *A, mzd_t *B, const int cutoff, const int inconsistency_check);
+int mzd_solve_left(mzd_t *A, mzd_t *B, int const cutoff, int const inconsistency_check);
 
 /**
  * \brief Solves (P L U Q) X = B
  *        found, -1 otherwise
  * \return 0 if a solution was found, -1 otherwise
  */
-int mzd_pluq_solve_left (mzd_t *A, rci_t rank, 
-                         mzp_t *P, mzp_t *Q, 
-                         mzd_t *B, const int cutoff, const int inconsistency_check);
+int mzd_pluq_solve_left (mzd_t const *A, rci_t rank, 
+                         mzp_t const *P, mzp_t const *Q, 
+                         mzd_t *B, int const cutoff, int const inconsistency_check);
 
 /**
  * \brief  Solves (P L U Q) X = B
  *        found, -1 otherwise
  * \return 0 if a solution was found, -1 otherwise
  */
-int _mzd_pluq_solve_left(mzd_t *A, rci_t rank, 
-                         mzp_t *P, mzp_t *Q, 
-                         mzd_t *B, const int cutoff, const int inconsistency_check);
+int _mzd_pluq_solve_left(mzd_t const *A, rci_t rank, 
+                         mzp_t const *P, mzp_t const *Q, 
+                         mzd_t *B, int const cutoff, int const inconsistency_check);
 
 /**
  * \brief Solves A X = B with A and B matrices.
  * This version assumes that the matrices are at an even position on
  * the m4ri_radix grid and that their dimension is a multiple of m4ri_radix.
  *
- * \param A Input matrix.
+ * \param A Input matrix (overwritten).
  * \param B Input matrix, being overwritten by the solution matrix X.
  * \param cutoff Minimal dimension for Strassen recursion (default: 0).
  * \param inconsistency_check decide whether or not to perform a check
  *        found, -1 otherwise
  * \return 0 if a solution was found, -1 otherwise
  */
-int _mzd_solve_left(mzd_t *A, mzd_t *B, const int cutoff, const int inconsistency_check);
-
+int _mzd_solve_left(mzd_t *A, mzd_t *B, int const cutoff, int const inconsistency_check);
 
 /**
  * \brief Solve X for A X = 0.
  * matrix X such that A*X == 0 and that the columns of X are linearly
  * independent.
  *
- * \param A Matrix.
+ * \param A Input matrix (overwritten).
  * \param cutoff Minimal dimension for Strassen recursion (default: 0).
  *
  * \wordoffset
  * \return X, NULL if kernel is empty
  */
 
-mzd_t *mzd_kernel_left_pluq(mzd_t *A, const int cutoff);
+mzd_t *mzd_kernel_left_pluq(mzd_t *A, int const cutoff);
 
 #endif // M4RI_SOLVE_H

File src/strassen.c

 /**
  * Simple blockwise product
  */
-mzd_t *_mzd_addmul_mp_even(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *_mzd_addmul_mp_even(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 
-mzd_t *_mzd_mul_even_orig(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *_mzd_mul_even_orig(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   rci_t a = A->nrows;
   rci_t b = A->ncols;
   rci_t c = B->ncols;
   rci_t bnr = anc;
   rci_t bnc = ((c / m4ri_radix) >> 1) * m4ri_radix;
 
-  mzd_t *A00 = mzd_init_window(A,   0,   0,   anr,   anc);
-  mzd_t *A01 = mzd_init_window(A,   0, anc,   anr, 2*anc);
-  mzd_t *A10 = mzd_init_window(A, anr,   0, 2*anr,   anc);
-  mzd_t *A11 = mzd_init_window(A, anr, anc, 2*anr, 2*anc);
+  mzd_t const *A00 = mzd_init_window_const(A,   0,   0,   anr,   anc);
+  mzd_t const *A01 = mzd_init_window_const(A,   0, anc,   anr, 2*anc);
+  mzd_t const *A10 = mzd_init_window_const(A, anr,   0, 2*anr,   anc);
+  mzd_t const *A11 = mzd_init_window_const(A, anr, anc, 2*anr, 2*anc);
 
-  mzd_t *B00 = mzd_init_window(B,   0,   0,   bnr,   bnc);
-  mzd_t *B01 = mzd_init_window(B,   0, bnc,   bnr, 2*bnc);
-  mzd_t *B10 = mzd_init_window(B, bnr,   0, 2*bnr,   bnc);
-  mzd_t *B11 = mzd_init_window(B, bnr, bnc, 2*bnr, 2*bnc);
+  mzd_t const *B00 = mzd_init_window_const(B,   0,   0,   bnr,   bnc);
+  mzd_t const *B01 = mzd_init_window_const(B,   0, bnc,   bnr, 2*bnc);
+  mzd_t const *B10 = mzd_init_window_const(B, bnr,   0, 2*bnr,   bnc);
+  mzd_t const *B11 = mzd_init_window_const(B, bnr, bnc, 2*bnr, 2*bnc);
 
   mzd_t *C00 = mzd_init_window(C,   0,   0,   anr,   bnc);
   mzd_t *C01 = mzd_init_window(C,   0, bnc,   anr, 2*bnc);
 
   /* deal with rest */
   if (B->ncols > 2 * bnc) {
-    mzd_t *B_last_col = mzd_init_window(B, 0, 2*bnc, A->ncols, B->ncols); 
+    mzd_t const *B_last_col = mzd_init_window_const(B, 0, 2*bnc, A->ncols, B->ncols); 
     mzd_t *C_last_col = mzd_init_window(C, 0, 2*bnc, A->nrows, C->ncols);
     _mzd_mul_m4rm(C_last_col, A, B_last_col, 0, TRUE);
-    mzd_free_window(B_last_col);
+    mzd_free_window((mzd_t*)B_last_col);
     mzd_free_window(C_last_col);
   }
   if (A->nrows > 2 * anr) {
-    mzd_t *A_last_row = mzd_init_window(A, 2*anr, 0, A->nrows, A->ncols);
+    mzd_t const *A_last_row = mzd_init_window_const(A, 2*anr, 0, A->nrows, A->ncols);
     mzd_t *C_last_row = mzd_init_window(C, 2*anr, 0, C->nrows, C->ncols);
     _mzd_mul_m4rm(C_last_row, A_last_row, B, 0, TRUE);
-    mzd_free_window(A_last_row);
+    mzd_free_window((mzd_t*)A_last_row);
     mzd_free_window(C_last_row);
   }
   if (A->ncols > 2 * anc) {
-    mzd_t *A_last_col = mzd_init_window(A,     0, 2*anc, 2*anr, A->ncols);
-    mzd_t *B_last_row = mzd_init_window(B, 2*bnr,     0, B->nrows, 2*bnc);
+    mzd_t const *A_last_col = mzd_init_window_const(A,     0, 2*anc, 2*anr, A->ncols);
+    mzd_t const *B_last_row = mzd_init_window_const(B, 2*bnr,     0, B->nrows, 2*bnc);
     mzd_t *C_bulk = mzd_init_window(C, 0, 0, 2*anr, 2*bnc);
     mzd_addmul_m4rm(C_bulk, A_last_col, B_last_row, 0);
-    mzd_free_window(A_last_col);
-    mzd_free_window(B_last_row);
+    mzd_free_window((mzd_t*)A_last_col);
+    mzd_free_window((mzd_t*)B_last_row);
     mzd_free_window(C_bulk);
   }
 
   /* clean up */
-  mzd_free_window(A00); mzd_free_window(A01);
-  mzd_free_window(A10); mzd_free_window(A11);
+  mzd_free_window((mzd_t*)A00); mzd_free_window((mzd_t*)A01);
+  mzd_free_window((mzd_t*)A10); mzd_free_window((mzd_t*)A11);
 
-  mzd_free_window(B00); mzd_free_window(B01);
-  mzd_free_window(B10); mzd_free_window(B11);
+  mzd_free_window((mzd_t*)B00); mzd_free_window((mzd_t*)B01);
+  mzd_free_window((mzd_t*)B10); mzd_free_window((mzd_t*)B11);
 
   mzd_free_window(C00); mzd_free_window(C01);
   mzd_free_window(C10); mzd_free_window(C11);
 }
 
 
-mzd_t *_mzd_mul_even(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *_mzd_mul_even(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   rci_t mmm, kkk, nnn;
   
   if(C->nrows == 0 || C->ncols == 0)
   /*         |A |   |B |   |C |
    * Compute |  | x |  | = |  | */
   {
-    mzd_t *A11 = mzd_init_window(A,   0,   0,   mmm,   kkk);
-    mzd_t *A12 = mzd_init_window(A,   0, kkk,   mmm, 2*kkk);
-    mzd_t *A21 = mzd_init_window(A, mmm,   0, 2*mmm,   kkk);
-    mzd_t *A22 = mzd_init_window(A, mmm, kkk, 2*mmm, 2*kkk);
+    mzd_t const *A11 = mzd_init_window_const(A,   0,   0,   mmm,   kkk);
+    mzd_t const *A12 = mzd_init_window_const(A,   0, kkk,   mmm, 2*kkk);
+    mzd_t const *A21 = mzd_init_window_const(A, mmm,   0, 2*mmm,   kkk);
+    mzd_t const *A22 = mzd_init_window_const(A, mmm, kkk, 2*mmm, 2*kkk);
 
-    mzd_t *B11 = mzd_init_window(B,   0,   0,   kkk,   nnn);
-    mzd_t *B12 = mzd_init_window(B,   0, nnn,   kkk, 2*nnn);
-    mzd_t *B21 = mzd_init_window(B, kkk,   0, 2*kkk,   nnn);
-    mzd_t *B22 = mzd_init_window(B, kkk, nnn, 2*kkk, 2*nnn);
+    mzd_t const *B11 = mzd_init_window_const(B,   0,   0,   kkk,   nnn);
+    mzd_t const *B12 = mzd_init_window_const(B,   0, nnn,   kkk, 2*nnn);
+    mzd_t const *B21 = mzd_init_window_const(B, kkk,   0, 2*kkk,   nnn);
+    mzd_t const *B22 = mzd_init_window_const(B, kkk, nnn, 2*kkk, 2*nnn);
 
     mzd_t *C11 = mzd_init_window(C,   0,   0,   mmm,   nnn);
     mzd_t *C12 = mzd_init_window(C,   0, nnn,   mmm, 2*nnn);
     _mzd_add(C11, C11, Wmk);		  /* C11 = C11 + Wmk */
 
     /* clean up */
-    mzd_free_window(A11); mzd_free_window(A12);
-    mzd_free_window(A21); mzd_free_window(A22);
+    mzd_free_window((mzd_t*)A11); mzd_free_window((mzd_t*)A12);
+    mzd_free_window((mzd_t*)A21); mzd_free_window((mzd_t*)A22);
 
-    mzd_free_window(B11); mzd_free_window(B12);
-    mzd_free_window(B21); mzd_free_window(B22);
+    mzd_free_window((mzd_t*)B11); mzd_free_window((mzd_t*)B12);
+    mzd_free_window((mzd_t*)B21); mzd_free_window((mzd_t*)B22);
 
     mzd_free_window(C11); mzd_free_window(C12);
     mzd_free_window(C21); mzd_free_window(C22);
   if (n > nnn) {
     /*         |AA|   | B|   | C|
      * Compute |AA| x | B| = | C| */
-    mzd_t *B_last_col = mzd_init_window(B, 0, nnn, k, n); 
+    mzd_t const *B_last_col = mzd_init_window_const(B, 0, nnn, k, n); 
     mzd_t *C_last_col = mzd_init_window(C, 0, nnn, m, n);
     _mzd_mul_m4rm(C_last_col, A, B_last_col, 0, TRUE);
-    mzd_free_window(B_last_col);
+    mzd_free_window((mzd_t*)B_last_col);
     mzd_free_window(C_last_col);
   }
   mmm *= 2;
   if (m > mmm) {
     /*         |  |   |B |   |  |
      * Compute |AA| x |B | = |C | */
-    mzd_t *A_last_row = mzd_init_window(A, mmm, 0, m, k);
-    mzd_t *B_first_col= mzd_init_window(B,   0, 0, k, nnn);
+    mzd_t const *A_last_row = mzd_init_window_const(A, mmm, 0, m, k);
+    mzd_t const *B_first_col= mzd_init_window_const(B,   0, 0, k, nnn);
     mzd_t *C_last_row = mzd_init_window(C, mmm, 0, m, nnn);
     _mzd_mul_m4rm(C_last_row, A_last_row, B_first_col, 0, TRUE);
-    mzd_free_window(A_last_row);
-    mzd_free_window(B_first_col);
+    mzd_free_window((mzd_t*)A_last_row);
+    mzd_free_window((mzd_t*)B_first_col);
     mzd_free_window(C_last_row);
   }
   kkk *= 2;
   if (k > kkk) {
     /* Add to  |  |   | B|   |C |
      * result  |A | x |  | = |  | */
-    mzd_t *A_last_col = mzd_init_window(A,   0, kkk, mmm, k);
-    mzd_t *B_last_row = mzd_init_window(B, kkk,   0,   k, nnn);
+    mzd_t const *A_last_col = mzd_init_window_const(A,   0, kkk, mmm, k);
+    mzd_t const *B_last_row = mzd_init_window_const(B, kkk,   0,   k, nnn);
     mzd_t *C_bulk = mzd_init_window(C, 0, 0, mmm, nnn);
     mzd_addmul_m4rm(C_bulk, A_last_col, B_last_row, 0);
-    mzd_free_window(A_last_col);
-    mzd_free_window(B_last_row);
+    mzd_free_window((mzd_t*)A_last_col);
+    mzd_free_window((mzd_t*)B_last_row);
     mzd_free_window(C_bulk);
   }
 
   return C;
 }
 
-mzd_t *_mzd_sqr_even(mzd_t *C, mzd_t *A, int cutoff) {
+mzd_t *_mzd_sqr_even(mzd_t *C, mzd_t const *A, int cutoff) {
   rci_t m;
   
   m = A->nrows;
   /*         |A |   |A |   |C |
    * Compute |  | x |  | = |  | */
   {
-    mzd_t *A11 = mzd_init_window(A,   0,   0,   mmm,   mmm);
-    mzd_t *A12 = mzd_init_window(A,   0, mmm,   mmm, 2*mmm);
-    mzd_t *A21 = mzd_init_window(A, mmm,   0, 2*mmm,   mmm);
-    mzd_t *A22 = mzd_init_window(A, mmm, mmm, 2*mmm, 2*mmm);
+    mzd_t const *A11 = mzd_init_window_const(A,   0,   0,   mmm,   mmm);
+    mzd_t const *A12 = mzd_init_window_const(A,   0, mmm,   mmm, 2*mmm);
+    mzd_t const *A21 = mzd_init_window_const(A, mmm,   0, 2*mmm,   mmm);
+    mzd_t const *A22 = mzd_init_window_const(A, mmm, mmm, 2*mmm, 2*mmm);
 
     mzd_t *C11 = mzd_init_window(C,   0,   0,   mmm,   mmm);
     mzd_t *C12 = mzd_init_window(C,   0, mmm,   mmm, 2*mmm);
     _mzd_add(C11, C11, Wmk);		  /* C11 = C11 + Wmk */
 
     /* clean up */
-    mzd_free_window(A11); mzd_free_window(A12);
-    mzd_free_window(A21); mzd_free_window(A22);
+    mzd_free_window((mzd_t*)A11); mzd_free_window((mzd_t*)A12);
+    mzd_free_window((mzd_t*)A21); mzd_free_window((mzd_t*)A22);
 
     mzd_free_window(C11); mzd_free_window(C12);
     mzd_free_window(C21); mzd_free_window(C22);
     /*         |AA|   | A|   | C|
      * Compute |AA| x | A| = | C| */
     {
-      mzd_t *A_last_col = mzd_init_window(A, 0, mmm, m, m);
+      mzd_t const *A_last_col = mzd_init_window_const(A, 0, mmm, m, m);
       mzd_t *C_last_col = mzd_init_window(C, 0, mmm, m, m);
       _mzd_mul_m4rm(C_last_col, A, A_last_col, 0, TRUE);
-      mzd_free_window(A_last_col);
+      mzd_free_window((mzd_t*)A_last_col);
       mzd_free_window(C_last_col);
     }
     /*         |  |   |A |   |  |
      * Compute |AA| x |A | = |C | */
     {
-      mzd_t *A_last_row = mzd_init_window(A, mmm, 0, m, m);
-      mzd_t *A_first_col= mzd_init_window(A,   0, 0, m, mmm);
+      mzd_t const *A_last_row = mzd_init_window_const(A, mmm, 0, m, m);
+      mzd_t const *A_first_col= mzd_init_window_const(A,   0, 0, m, mmm);
       mzd_t *C_last_row = mzd_init_window(C, mmm, 0, m, mmm);
       _mzd_mul_m4rm(C_last_row, A_last_row, A_first_col, 0, TRUE);
-      mzd_free_window(A_last_row);
-      mzd_free_window(A_first_col);
+      mzd_free_window((mzd_t*)A_last_row);
+      mzd_free_window((mzd_t*)A_first_col);
       mzd_free_window(C_last_row);
     }
     /* Add to  |  |   | A|   |C |
      * result  |A | x |  | = |  | */
     {
-      mzd_t *A_last_col = mzd_init_window(A,   0, mmm, mmm, m);
-      mzd_t *A_last_row = mzd_init_window(A, mmm,   0,   m, mmm);
+      mzd_t const *A_last_col = mzd_init_window_const(A,   0, mmm, mmm, m);
+      mzd_t const *A_last_row = mzd_init_window_const(A, mmm,   0,   m, mmm);
       mzd_t *C_bulk = mzd_init_window(C, 0, 0, mmm, mmm);
       mzd_addmul_m4rm(C_bulk, A_last_col, A_last_row, 0);
-      mzd_free_window(A_last_col);
-      mzd_free_window(A_last_row);
+      mzd_free_window((mzd_t*)A_last_col);
+      mzd_free_window((mzd_t*)A_last_row);
       mzd_free_window(C_bulk);
     }
   }
 
 
 #ifdef HAVE_OPENMP
-mzd_t *_mzd_addmul_mp_even(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *_mzd_addmul_mp_even(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   /**
    * \todo make sure not to overwrite crap after ncols and before width * m4ri_radix
    */
 }
 #endif
 
-mzd_t *mzd_mul(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *mzd_mul(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   if(A->ncols != B->nrows)
     m4ri_die("mzd_mul: A ncols (%d) need to match B nrows (%d).\n", A->ncols, B->nrows);
   
   return C;
 }
 
-mzd_t *_mzd_addmul_even_orig(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *_mzd_addmul_even_orig(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   /**
    * \todo make sure not to overwrite crap after ncols and before width * m4ri_radix
    */
   rci_t bnr = anc;
   rci_t bnc = ((c/m4ri_radix) >> 1) * m4ri_radix;
 
-  mzd_t *A00 = mzd_init_window(A,   0,   0,   anr,   anc);
-  mzd_t *A01 = mzd_init_window(A,   0, anc,   anr, 2*anc);
-  mzd_t *A10 = mzd_init_window(A, anr,   0, 2*anr,   anc);
-  mzd_t *A11 = mzd_init_window(A, anr, anc, 2*anr, 2*anc);
+  mzd_t const *A00 = mzd_init_window_const(A,   0,   0,   anr,   anc);
+  mzd_t const *A01 = mzd_init_window_const(A,   0, anc,   anr, 2*anc);
+  mzd_t const *A10 = mzd_init_window_const(A, anr,   0, 2*anr,   anc);
+  mzd_t const *A11 = mzd_init_window_const(A, anr, anc, 2*anr, 2*anc);
 
-  mzd_t *B00 = mzd_init_window(B,   0,   0,   bnr,   bnc);
-  mzd_t *B01 = mzd_init_window(B,   0, bnc,   bnr, 2*bnc);
-  mzd_t *B10 = mzd_init_window(B, bnr,   0, 2*bnr,   bnc);
-  mzd_t *B11 = mzd_init_window(B, bnr, bnc, 2*bnr, 2*bnc);
+  mzd_t const *B00 = mzd_init_window_const(B,   0,   0,   bnr,   bnc);
+  mzd_t const *B01 = mzd_init_window_const(B,   0, bnc,   bnr, 2*bnc);
+  mzd_t const *B10 = mzd_init_window_const(B, bnr,   0, 2*bnr,   bnc);
+  mzd_t const *B11 = mzd_init_window_const(B, bnr, bnc, 2*bnr, 2*bnc);
 
   mzd_t *C00 = mzd_init_window(C,   0,   0,   anr,   bnc);
   mzd_t *C01 = mzd_init_window(C,   0, bnc,   anr, 2*bnc);
 
   /* deal with rest */
   if (B->ncols > 2 * bnc) {
-    mzd_t *B_last_col = mzd_init_window(B, 0, 2*bnc, A->ncols, B->ncols); 
+    mzd_t const *B_last_col = mzd_init_window_const(B, 0, 2*bnc, A->ncols, B->ncols); 
     mzd_t *C_last_col = mzd_init_window(C, 0, 2*bnc, A->nrows, C->ncols);
     mzd_addmul_m4rm(C_last_col, A, B_last_col, 0);
-    mzd_free_window(B_last_col);
+    mzd_free_window((mzd_t*)B_last_col);
     mzd_free_window(C_last_col);
   }
   if (A->nrows > 2 * anr) {
-    mzd_t *A_last_row = mzd_init_window(A, 2*anr, 0, A->nrows, A->ncols);
-    mzd_t *B_bulk = mzd_init_window(B, 0, 0, B->nrows, 2*bnc);
+    mzd_t const *A_last_row = mzd_init_window_const(A, 2*anr, 0, A->nrows, A->ncols);
+    mzd_t const *B_bulk = mzd_init_window_const(B, 0, 0, B->nrows, 2*bnc);
     mzd_t *C_last_row = mzd_init_window(C, 2*anr, 0, C->nrows, 2*bnc);
     mzd_addmul_m4rm(C_last_row, A_last_row, B_bulk, 0);
-    mzd_free_window(A_last_row);
-    mzd_free_window(B_bulk);
+    mzd_free_window((mzd_t*)A_last_row);
+    mzd_free_window((mzd_t*)B_bulk);
     mzd_free_window(C_last_row);
   }
   if (A->ncols > 2 * anc) {
-    mzd_t *A_last_col = mzd_init_window(A,     0, 2*anc, 2*anr, A->ncols);
-    mzd_t *B_last_row = mzd_init_window(B, 2*bnr,     0, B->nrows, 2*bnc);
+    mzd_t const *A_last_col = mzd_init_window_const(A,     0, 2*anc, 2*anr, A->ncols);
+    mzd_t const *B_last_row = mzd_init_window_const(B, 2*bnr,     0, B->nrows, 2*bnc);
     mzd_t *C_bulk = mzd_init_window(C, 0, 0, 2*anr, 2*bnc);
     mzd_addmul_m4rm(C_bulk, A_last_col, B_last_row, 0);
-    mzd_free_window(A_last_col);
-    mzd_free_window(B_last_row);
+    mzd_free_window((mzd_t*)A_last_col);
+    mzd_free_window((mzd_t*)B_last_row);
     mzd_free_window(C_bulk);
   }
 
   /* clean up */
-  mzd_free_window(A00); mzd_free_window(A01);
-  mzd_free_window(A10); mzd_free_window(A11);
+  mzd_free_window((mzd_t*)A00); mzd_free_window((mzd_t*)A01);
+  mzd_free_window((mzd_t*)A10); mzd_free_window((mzd_t*)A11);
 
-  mzd_free_window(B00); mzd_free_window(B01);
-  mzd_free_window(B10); mzd_free_window(B11);
+  mzd_free_window((mzd_t*)B00); mzd_free_window((mzd_t*)B01);
+  mzd_free_window((mzd_t*)B10); mzd_free_window((mzd_t*)B11);
 
   mzd_free_window(C00); mzd_free_window(C01);
   mzd_free_window(C10); mzd_free_window(C11);
   return C;
 }
 
-mzd_t *_mzd_addmul_even(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *_mzd_addmul_even(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   /**
    * \todo make sure not to overwrite crap after ncols and before width * m4ri_radix
    */
   /*         |C |    |A |   |B | 
    * Compute |  | += |  | x |  |  */
   {
-    mzd_t *A11 = mzd_init_window(A,   0,   0,   mmm,   kkk);
-    mzd_t *A12 = mzd_init_window(A,   0, kkk,   mmm, 2*kkk);
-    mzd_t *A21 = mzd_init_window(A, mmm,   0, 2*mmm,   kkk);
-    mzd_t *A22 = mzd_init_window(A, mmm, kkk, 2*mmm, 2*kkk);
+    mzd_t const *A11 = mzd_init_window_const(A,   0,   0,   mmm,   kkk);
+    mzd_t const *A12 = mzd_init_window_const(A,   0, kkk,   mmm, 2*kkk);
+    mzd_t const *A21 = mzd_init_window_const(A, mmm,   0, 2*mmm,   kkk);
+    mzd_t const *A22 = mzd_init_window_const(A, mmm, kkk, 2*mmm, 2*kkk);
 
-    mzd_t *B11 = mzd_init_window(B,   0,   0,   kkk,   nnn);
-    mzd_t *B12 = mzd_init_window(B,   0, nnn,   kkk, 2*nnn);
-    mzd_t *B21 = mzd_init_window(B, kkk,   0, 2*kkk,   nnn);
-    mzd_t *B22 = mzd_init_window(B, kkk, nnn, 2*kkk, 2*nnn);
+    mzd_t const *B11 = mzd_init_window_const(B,   0,   0,   kkk,   nnn);
+    mzd_t const *B12 = mzd_init_window_const(B,   0, nnn,   kkk, 2*nnn);
+    mzd_t const *B21 = mzd_init_window_const(B, kkk,   0, 2*kkk,   nnn);
+    mzd_t const *B22 = mzd_init_window_const(B, kkk, nnn, 2*kkk, 2*nnn);
 
     mzd_t *C11 = mzd_init_window(C,   0,   0,   mmm,   nnn);
     mzd_t *C12 = mzd_init_window(C,   0, nnn,   mmm, 2*nnn);
     _mzd_add(C22, C22, U);                   /* 21 C22 = C22 - U3      */
 
     /* clean up */
-    mzd_free_window(A11); mzd_free_window(A12);
-    mzd_free_window(A21); mzd_free_window(A22);
+    mzd_free_window((mzd_t*)A11); mzd_free_window((mzd_t*)A12);
+    mzd_free_window((mzd_t*)A21); mzd_free_window((mzd_t*)A22);
 
-    mzd_free_window(B11); mzd_free_window(B12);
-    mzd_free_window(B21); mzd_free_window(B22);
+    mzd_free_window((mzd_t*)B11); mzd_free_window((mzd_t*)B12);
+    mzd_free_window((mzd_t*)B21); mzd_free_window((mzd_t*)B22);
 
     mzd_free_window(C11); mzd_free_window(C12);
     mzd_free_window(C21); mzd_free_window(C22);
   if (n > nnn) {
     /*         | C|    |AA|   | B|
      * Compute | C| += |AA| x | B| */
-    mzd_t *B_last_col = mzd_init_window(B, 0, nnn, k, n); 
+    mzd_t const *B_last_col = mzd_init_window_const(B, 0, nnn, k, n); 
     mzd_t *C_last_col = mzd_init_window(C, 0, nnn, m, n);
     mzd_addmul_m4rm(C_last_col, A, B_last_col, 0);
-    mzd_free_window(B_last_col);
+    mzd_free_window((mzd_t*)B_last_col);
     mzd_free_window(C_last_col);
   }
   mmm *= 2;
   if (m > mmm) {
     /*         |  |    |  |   |B |
      * Compute |C | += |AA| x |B | */
-    mzd_t *A_last_row = mzd_init_window(A, mmm, 0, m, k);
-    mzd_t *B_first_col= mzd_init_window(B,   0, 0, k, nnn);
+    mzd_t const *A_last_row = mzd_init_window_const(A, mmm, 0, m, k);
+    mzd_t const *B_first_col= mzd_init_window_const(B,   0, 0, k, nnn);
     mzd_t *C_last_row = mzd_init_window(C, mmm, 0, m, nnn);
     mzd_addmul_m4rm(C_last_row, A_last_row, B_first_col, 0);
-    mzd_free_window(A_last_row);
-    mzd_free_window(B_first_col);
+    mzd_free_window((mzd_t*)A_last_row);
+    mzd_free_window((mzd_t*)B_first_col);
     mzd_free_window(C_last_row);
   }
   kkk *= 2;
   if (k > kkk) {
     /* Add to  |  |   | B|   |C |
      * result  |A | x |  | = |  | */
-    mzd_t *A_last_col = mzd_init_window(A,   0, kkk, mmm, k);
-    mzd_t *B_last_row = mzd_init_window(B, kkk,   0,   k, nnn);
+    mzd_t const *A_last_col = mzd_init_window_const(A,   0, kkk, mmm, k);
+    mzd_t const *B_last_row = mzd_init_window_const(B, kkk,   0,   k, nnn);
     mzd_t *C_bulk = mzd_init_window(C, 0, 0, mmm, nnn);
     mzd_addmul_m4rm(C_bulk, A_last_col, B_last_row, 0);
-    mzd_free_window(A_last_col);
-    mzd_free_window(B_last_row);
+    mzd_free_window((mzd_t*)A_last_col);
+    mzd_free_window((mzd_t*)B_last_row);
     mzd_free_window(C_bulk);
   }
 
   return C;
 }
 
-mzd_t *_mzd_addsqr_even(mzd_t *C, mzd_t *A, int cutoff) {
+mzd_t *_mzd_addsqr_even(mzd_t *C, mzd_t const *A, int cutoff) {
   /**
    * \todo make sure not to overwrite crap after ncols and before width * m4ri_radix
    */
   /*         |C |    |A |   |B | 
    * Compute |  | += |  | x |  |  */
   {
-    mzd_t *A11 = mzd_init_window(A,   0,   0,   mmm,   mmm);
-    mzd_t *A12 = mzd_init_window(A,   0, mmm,   mmm, 2*mmm);
-    mzd_t *A21 = mzd_init_window(A, mmm,   0, 2*mmm,   mmm);
-    mzd_t *A22 = mzd_init_window(A, mmm, mmm, 2*mmm, 2*mmm);
+    mzd_t const *A11 = mzd_init_window_const(A,   0,   0,   mmm,   mmm);
+    mzd_t const *A12 = mzd_init_window_const(A,   0, mmm,   mmm, 2*mmm);
+    mzd_t const *A21 = mzd_init_window_const(A, mmm,   0, 2*mmm,   mmm);
+    mzd_t const *A22 = mzd_init_window_const(A, mmm, mmm, 2*mmm, 2*mmm);
 
     mzd_t *C11 = mzd_init_window(C,   0,   0,   mmm,   mmm);
     mzd_t *C12 = mzd_init_window(C,   0, mmm,   mmm, 2*mmm);
     _mzd_add(C22, C22, U);                   /* 21 C22 = C22 - U3      */
 
     /* clean up */
-    mzd_free_window(A11); mzd_free_window(A12);
-    mzd_free_window(A21); mzd_free_window(A22);
+    mzd_free_window((mzd_t*)A11); mzd_free_window((mzd_t*)A12);
+    mzd_free_window((mzd_t*)A21); mzd_free_window((mzd_t*)A22);
 
     mzd_free_window(C11); mzd_free_window(C12);
     mzd_free_window(C21); mzd_free_window(C22);
     /*         | C|    |AA|   | B|
      * Compute | C| += |AA| x | B| */
     {
-      mzd_t *A_last_col = mzd_init_window(A, 0, mmm, m, m); 
+      mzd_t const *A_last_col = mzd_init_window_const(A, 0, mmm, m, m); 
       mzd_t *C_last_col = mzd_init_window(C, 0, mmm, m, m);
       mzd_addmul_m4rm(C_last_col, A, A_last_col, 0);
-      mzd_free_window(A_last_col);
+      mzd_free_window((mzd_t*)A_last_col);
       mzd_free_window(C_last_col);
     }
     /*         |  |    |  |   |B |
      * Compute |C | += |AA| x |B | */
     {
-      mzd_t *A_last_row = mzd_init_window(A, mmm, 0, m, m);
-      mzd_t *A_first_col= mzd_init_window(A,   0, 0, m, mmm);
+      mzd_t const *A_last_row = mzd_init_window_const(A, mmm, 0, m, m);
+      mzd_t const *A_first_col= mzd_init_window_const(A,   0, 0, m, mmm);
       mzd_t *C_last_row = mzd_init_window(C, mmm, 0, m, mmm);
       mzd_addmul_m4rm(C_last_row, A_last_row, A_first_col, 0);
-      mzd_free_window(A_last_row);
-      mzd_free_window(A_first_col);
+      mzd_free_window((mzd_t*)A_last_row);
+      mzd_free_window((mzd_t*)A_first_col);
       mzd_free_window(C_last_row);
     }
     /* Add to  |  |   | B|   |C |
      * result  |A | x |  | = |  | */
     {
-      mzd_t *A_last_col = mzd_init_window(A,   0, mmm, mmm, m);
-      mzd_t *A_last_row = mzd_init_window(A, mmm,   0,   m, mmm);
+      mzd_t const *A_last_col = mzd_init_window_const(A,   0, mmm, mmm, m);
+      mzd_t const *A_last_row = mzd_init_window_const(A, mmm,   0,   m, mmm);
       mzd_t *C_bulk = mzd_init_window(C, 0, 0, mmm, mmm);
       mzd_addmul_m4rm(C_bulk, A_last_col, A_last_row, 0);
-      mzd_free_window(A_last_col);
-      mzd_free_window(A_last_row);
+      mzd_free_window((mzd_t*)A_last_col);
+      mzd_free_window((mzd_t*)A_last_row);
       mzd_free_window(C_bulk);
     }
   }
   return C;
 }
 
-mzd_t *_mzd_addmul(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *_mzd_addmul(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   /**
    * Assumes that B and C are aligned in the same manner (as in a Schur complement)
    */
       if (B->ncols <= bnc){
 	_mzd_addmul_even_weird  (C,  A, B, cutoff);
       } else {
-	mzd_t *B0 = mzd_init_window (B, 0, 0, B->nrows, bnc);
+	mzd_t const *B0 = mzd_init_window_const (B, 0, 0, B->nrows, bnc);
 	mzd_t *C0 = mzd_init_window (C, 0, 0, C->nrows, bnc);
-	mzd_t *B1 = mzd_init_window (B, 0, bnc, B->nrows, B->ncols);
+	mzd_t const *B1 = mzd_init_window_const (B, 0, bnc, B->nrows, B->ncols);
 	mzd_t *C1 = mzd_init_window (C, 0, bnc, C->nrows, C->ncols);
 	_mzd_addmul_even_weird  (C0,  A, B0, cutoff);
 	_mzd_addmul_even(C1, A, B1, cutoff);
-	mzd_free_window (B0); mzd_free_window (B1);
+	mzd_free_window ((mzd_t*)B0); mzd_free_window ((mzd_t*)B1);
 	mzd_free_window (C0); mzd_free_window (C1);
       }
     }
       if (A->ncols <= anc)
 	_mzd_addmul_weird_weird (C, A, B);
       else {
-	mzd_t *A0  = mzd_init_window (A, 0, 0, A->nrows, anc);
-	mzd_t *A1  = mzd_init_window (A, 0, anc, A->nrows, A->ncols);
-	mzd_t *B0  = mzd_init_window (B, 0, 0, anc, B->ncols);
-	mzd_t *B1  = mzd_init_window (B, anc, 0, B->nrows, B->ncols);
+	mzd_t const *A0  = mzd_init_window_const (A, 0, 0, A->nrows, anc);
+	mzd_t const *A1  = mzd_init_window_const (A, 0, anc, A->nrows, A->ncols);
+	mzd_t const *B0  = mzd_init_window_const (B, 0, 0, anc, B->ncols);
+	mzd_t const *B1  = mzd_init_window_const (B, anc, 0, B->nrows, B->ncols);
 	_mzd_addmul_weird_weird (C, A0, B0);
 	_mzd_addmul_even_weird  (C, A1, B1, cutoff);
-	mzd_free_window (A0);  mzd_free_window (A1);
-	mzd_free_window (B0);  mzd_free_window (B1);
+	mzd_free_window ((mzd_t*)A0);  mzd_free_window ((mzd_t*)A1);
+	mzd_free_window ((mzd_t*)B0);  mzd_free_window ((mzd_t*)B1);
       }
     } else if (A->ncols <= anc) {
-      mzd_t *B0 = mzd_init_window (B, 0, 0, B->nrows, bnc);
-      mzd_t *B1 = mzd_init_window (B, 0, bnc, B->nrows, B->ncols);
+      mzd_t const *B0 = mzd_init_window_const (B, 0, 0, B->nrows, bnc);
+      mzd_t const *B1 = mzd_init_window_const (B, 0, bnc, B->nrows, B->ncols);
       mzd_t *C0 = mzd_init_window (C, 0, 0, C->nrows, bnc);
       mzd_t *C1 = mzd_init_window (C, 0, bnc, C->nrows, C->ncols);
       _mzd_addmul_weird_weird (C0, A, B0);
       _mzd_addmul_weird_even  (C1, A, B1, cutoff);
-      mzd_free_window (B0); mzd_free_window (B1);
+      mzd_free_window ((mzd_t*)B0); mzd_free_window ((mzd_t*)B1);
       mzd_free_window (C0); mzd_free_window (C1);
     } else {
-      mzd_t *A0  = mzd_init_window (A, 0, 0, A->nrows, anc);
-      mzd_t *A1  = mzd_init_window (A, 0, anc, A->nrows, A->ncols);
-      mzd_t *B00 = mzd_init_window (B, 0, 0, anc, bnc);
-      mzd_t *B01 = mzd_init_window (B, 0, bnc, anc, B->ncols);
-      mzd_t *B10 = mzd_init_window (B, anc, 0, B->nrows, bnc);
-      mzd_t *B11 = mzd_init_window (B, anc, bnc, B->nrows, B->ncols);
+      mzd_t const *A0  = mzd_init_window_const (A, 0, 0, A->nrows, anc);
+      mzd_t const *A1  = mzd_init_window_const (A, 0, anc, A->nrows, A->ncols);
+      mzd_t const *B00 = mzd_init_window_const (B, 0, 0, anc, bnc);
+      mzd_t const *B01 = mzd_init_window_const (B, 0, bnc, anc, B->ncols);
+      mzd_t const *B10 = mzd_init_window_const (B, anc, 0, B->nrows, bnc);
+      mzd_t const *B11 = mzd_init_window_const (B, anc, bnc, B->nrows, B->ncols);
       mzd_t *C0 = mzd_init_window (C, 0, 0, C->nrows, bnc);
       mzd_t *C1 = mzd_init_window (C, 0, bnc, C->nrows, C->ncols);
       
       _mzd_addmul_weird_even  (C1,  A0, B01, cutoff);
       _mzd_addmul_even  (C1,  A1, B11, cutoff);
 
-      mzd_free_window (A0);  mzd_free_window (A1);
+      mzd_free_window ((mzd_t*)A0);  mzd_free_window ((mzd_t*)A1);
       mzd_free_window (C0);  mzd_free_window (C1);
-      mzd_free_window (B00); mzd_free_window (B01);
-      mzd_free_window (B10); mzd_free_window (B11);
+      mzd_free_window ((mzd_t*)B00); mzd_free_window ((mzd_t*)B01);
+      mzd_free_window ((mzd_t*)B10); mzd_free_window ((mzd_t*)B11);
     }
   } else { /* A weird, B even */
     int const anc = m4ri_radix - A->offset;
     if (A->ncols <= anc){
       _mzd_addmul_weird_even  (C,  A, B, cutoff);
     } else {
-      mzd_t *A0  = mzd_init_window (A, 0, 0, A->nrows, anc);
-      mzd_t *A1  = mzd_init_window (A, 0, anc, A->nrows, A->ncols);
-      mzd_t *B0  = mzd_init_window (B, 0, 0, anc, B->ncols);
-      mzd_t *B1  = mzd_init_window (B, anc, 0, B->nrows, B->ncols);
+      mzd_t const *A0  = mzd_init_window_const (A, 0, 0, A->nrows, anc);
+      mzd_t const *A1  = mzd_init_window_const (A, 0, anc, A->nrows, A->ncols);
+      mzd_t const *B0  = mzd_init_window_const (B, 0, 0, anc, B->ncols);
+      mzd_t const *B1  = mzd_init_window_const (B, anc, 0, B->nrows, B->ncols);
       _mzd_addmul_weird_even (C, A0, B0, cutoff);
       _mzd_addmul_even  (C, A1, B1, cutoff);
-      mzd_free_window (A0); mzd_free_window (A1);
-      mzd_free_window (B0); mzd_free_window (B1);
+      mzd_free_window ((mzd_t*)A0); mzd_free_window ((mzd_t*)A1);
+      mzd_free_window ((mzd_t*)B0); mzd_free_window ((mzd_t*)B1);
     }
   }
   return C;
 }
 
-mzd_t *_mzd_addmul_weird_even (mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *_mzd_addmul_weird_even (mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   mzd_t *tmp = mzd_init(A->nrows, MIN((rci_t)m4ri_radix - A->offset, A->ncols));
   for (rci_t i = 0; i < A->nrows; ++i){
     tmp->rows[i][0] = (A->rows[i][0] >> A->offset);
   return C;
 }
 
- mzd_t *_mzd_addmul_even_weird (mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
-   mzd_t *tmp = mzd_init (B->nrows, (rci_t)m4ri_radix);
-   int const offset = C->offset;
-   rci_t const cncols = C->ncols;
-   C->offset = 0;
-   C->ncols = m4ri_radix;
-   word const mask = __M4RI_MIDDLE_BITMASK(B->ncols, B->offset);
-   for (rci_t i = 0; i < B->nrows; ++i)
-     tmp->rows[i][0] = B->rows[i][0] & mask;
-   _mzd_addmul_even (C, A, tmp, cutoff);
-   C->offset = offset;
-   C->ncols = cncols;
-   mzd_free (tmp);
-   return C;
+mzd_t *_mzd_addmul_even_weird (mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
+  mzd_t *tmp = mzd_init (B->nrows, (rci_t)m4ri_radix);
+  int const offset = C->offset;
+  rci_t const cncols = C->ncols;
+  C->offset = 0;
+  C->ncols = m4ri_radix;
+  word const mask = __M4RI_MIDDLE_BITMASK(B->ncols, B->offset);
+  for (rci_t i = 0; i < B->nrows; ++i)
+    tmp->rows[i][0] = B->rows[i][0] & mask;
+  _mzd_addmul_even (C, A, tmp, cutoff);
+  C->offset = offset;
+  C->ncols = cncols;
+  mzd_free (tmp);
+  return C;
 }
 
-mzd_t *_mzd_addmul_weird_weird (mzd_t *C, mzd_t *A, mzd_t *B) {
+mzd_t *_mzd_addmul_weird_weird (mzd_t *C, mzd_t const *A, mzd_t const *B) {
   mzd_t *BT = mzd_init( B->ncols, B->nrows );
    
   for (rci_t i = 0; i < B->ncols; ++i) {
   return C;
 }
 
-mzd_t *mzd_addmul(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff) {
+mzd_t *mzd_addmul(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff) {
   if(A->ncols != B->nrows)
     m4ri_die("mzd_addmul: A ncols (%d) need to match B nrows (%d).\n", A->ncols, B->nrows);
   

File src/strassen.h

  * \param cutoff Minimal dimension for Strassen recursion.
  */
 
-mzd_t *mzd_mul(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *mzd_mul(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 /**
  * \brief Matrix multiplication and in-place addition via the
  * \param cutoff Minimal dimension for Strassen recursion.
  */
 
-mzd_t *mzd_addmul(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *mzd_addmul(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 /**
  * \brief Matrix multiplication via the Strassen-Winograd matrix
  * http://www.sagemath.org
  */
 
-mzd_t *_mzd_mul_even(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *_mzd_mul_even(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 /**
  * \brief Matrix multiplication and in-place addition via the
  * http://www.sagemath.org
  */
 
-mzd_t *_mzd_addmul_even(mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *_mzd_addmul_even(mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 /**
  * \brief Matrix multiplication and in-place addition via the
  *
  */
 
-mzd_t *_mzd_addmul (mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *_mzd_addmul (mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 /**
  * C = A*B + C for matrices with offsets != 0
  * \internal
  */
 
-mzd_t *_mzd_addmul_weird_weird (mzd_t *C, mzd_t *A, mzd_t *B);
+mzd_t *_mzd_addmul_weird_weird (mzd_t *C, mzd_t const *A, mzd_t const *B);
 
 /**
  * C = A*B + C for A with offset == 0 and B with offset != 0.
  * \internal
  */
 
-mzd_t *_mzd_addmul_weird_even (mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *_mzd_addmul_weird_even (mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 /**
  * C = A*B + C for A with offset != 0 and B with offset == 0.
  * \internal
  */
 
-mzd_t *_mzd_addmul_even_weird (mzd_t *C, mzd_t *A, mzd_t *B, int cutoff);
+mzd_t *_mzd_addmul_even_weird (mzd_t *C, mzd_t const *A, mzd_t const *B, int cutoff);
 
 /**
  * The default cutoff for Strassen-Winograd multiplication. It should
    */
   mzd_t *B0  = mzd_init_window (B,  0,  0, mb, n1);
   mzd_t *B1  = mzd_init_window (B,  0, n1, mb, nb);
-  mzd_t *U00 = mzd_init_window (U,  0,  0, n1, n1);
-  mzd_t *U01 = mzd_init_window (U,  0, n1, n1, nb);
-  mzd_t *U11 = mzd_init_window (U, n1, n1, nb, nb);
+  mzd_t const *U00 = mzd_init_window_const (U,  0,  0, n1, n1);
+  mzd_t const *U01 = mzd_init_window_const (U,  0, n1, n1, nb);
+  mzd_t const *U11 = mzd_init_window_const (U, n1, n1, nb, nb);
   
   _mzd_trsm_upper_right_weird (U00, B0);
   mzd_addmul (B1, B0, U01, cutoff);
   mzd_free_window(B0);
   mzd_free_window(B1);
   
-  mzd_free_window(U00);
-  mzd_free_window(U01);
-  mzd_free_window(U11);
+  mzd_free_window((mzd_t*)U00);
+  mzd_free_window((mzd_t*)U01);
+  mzd_free_window((mzd_t*)U11);
 }
 
 void _mzd_trsm_upper_right_weird(mzd_t const *U, mzd_t *B) {
   
   mzd_t *B0 = mzd_init_window(B,  0,     0,   mb, nb1);
   mzd_t *B1 = mzd_init_window(B,  0,   nb1,   mb, nb);
-  mzd_t *U00 = mzd_init_window(U, 0,     0, nb1, nb1);
-  mzd_t *U01 = mzd_init_window(U, 0,   nb1, nb1, nb);
-  mzd_t *U11 = mzd_init_window(U, nb1, nb1,  nb, nb);
+  mzd_t const *U00 = mzd_init_window_const(U, 0,     0, nb1, nb1);
+  mzd_t const *U01 = mzd_init_window_const(U, 0,   nb1, nb1, nb);
+  mzd_t const *U11 = mzd_init_window_const(U, nb1, nb1,  nb, nb);
   
   _mzd_trsm_upper_right_even (U00, B0, cutoff);
   mzd_addmul (B1, B0, U01, cutoff);
   mzd_free_window(B0);
   mzd_free_window(B1);
   
-  mzd_free_window(U00);
-  mzd_free_window(U01);
-  mzd_free_window(U11);
+  mzd_free_window((mzd_t*)U00);
+  mzd_free_window((mzd_t*)U01);
+  mzd_free_window((mzd_t*)U11);
 }
 
 void _mzd_trsm_upper_right_base(mzd_t const *U, mzd_t *B) {
    */
     mzd_t *B0  = mzd_init_window (B,  0,  0, mb, n1);
     mzd_t *B1  = mzd_init_window (B,  0, n1, mb, nb);
-    mzd_t *L00 = mzd_init_window (L,  0,  0, n1, n1);
-    mzd_t *L10 = mzd_init_window (L,  n1, 0, nb, n1);
-    mzd_t *L11 = mzd_init_window (L, n1, n1, nb, nb);
+    mzd_t const *L00 = mzd_init_window_const (L,  0,  0, n1, n1);
+    mzd_t const *L10 = mzd_init_window_const (L,  n1, 0, nb, n1);
+    mzd_t const *L11 = mzd_init_window_const (L, n1, n1, nb, nb);
     
     _mzd_trsm_lower_right_even (L11, B1, cutoff);
     mzd_addmul (B0, B1, L10, cutoff);
     mzd_free_window(B0);
     mzd_free_window(B1);
     
-    mzd_free_window(L00);
-    mzd_free_window(L10);
-    mzd_free_window(L11);
+    mzd_free_window((mzd_t*)L00);
+    mzd_free_window((mzd_t*)L10);
+    mzd_free_window((mzd_t*)L11);
   }
 }
 
 
     mzd_t *B0 = mzd_init_window(B,  0,     0,   mb, nb1);
     mzd_t *B1 = mzd_init_window(B,  0,   nb1,   mb, nb);
-    mzd_t *L00 = mzd_init_window(L, 0,     0, nb1, nb1);
-    mzd_t *L10 = mzd_init_window(L, nb1, 0, nb, nb1);
-    mzd_t *L11 = mzd_init_window(L, nb1, nb1,  nb, nb);
+    mzd_t const *L00 = mzd_init_window_const(L, 0,     0, nb1, nb1);
+    mzd_t const *L10 = mzd_init_window_const(L, nb1, 0, nb, nb1);
+    mzd_t const *L11 = mzd_init_window_const(L, nb1, nb1,  nb, nb);
 
     _mzd_trsm_lower_right_even (L11, B1, cutoff);
     mzd_addmul (B0, B1, L10, cutoff);
     mzd_free_window(B0);
     mzd_free_window(B1);
 
-    mzd_free_window(L00);
-    mzd_free_window(L10);
-    mzd_free_window(L11);
+    mzd_free_window((mzd_t*)L00);
+    mzd_free_window((mzd_t*)L10);
+    mzd_free_window((mzd_t*)L11);
   }
 }
 
       
     mzd_t *B0  = mzd_init_window (B,  0,  0, m1, nb);
     mzd_t *B1  = mzd_init_window (B,  m1, 0, mb, nb);
-    mzd_t *L00 = mzd_init_window (L,  0,  0, m1, m1);
-    mzd_t *L10 = mzd_init_window (L,  m1, 0, mb, m1);
-    mzd_t *L11 = mzd_init_window (L, m1, m1, mb, mb);
+    mzd_t const *L00 = mzd_init_window_const (L,  0,  0, m1, m1);
+    mzd_t const *L10 = mzd_init_window_const (L,  m1, 0, mb, m1);
+    mzd_t const *L11 = mzd_init_window_const (L, m1, m1, mb, mb);
     
     _mzd_trsm_lower_left_weird (L00, B0);
     mzd_addmul (B1, L10, B0, cutoff);
     mzd_free_window(B0);
     mzd_free_window(B1);
     
-    mzd_free_window(L00);
-    mzd_free_window(L10);
-    mzd_free_window(L11);
+    mzd_free_window((mzd_t*)L00);
+    mzd_free_window((mzd_t*)L10);
+    mzd_free_window((mzd_t*)L11);
   }
 }
 
 
     mzd_t *B0 = mzd_init_window(B,  0,     0,   mb1, nb);
     mzd_t *B1 = mzd_init_window(B, mb1,    0,   mb,  nb);
-    mzd_t *L00 = mzd_init_window(L, 0,     0, mb1, mb1);
-    mzd_t *L10 = mzd_init_window(L, mb1,   0, mb, mb1);
-    mzd_t *L11 = mzd_init_window(L, mb1, mb1, mb, mb);
+    mzd_t const *L00 = mzd_init_window_const(L, 0,     0, mb1, mb1);
+    mzd_t const *L10 = mzd_init_window_const(L, mb1,   0, mb, mb1);
+    mzd_t const *L11 = mzd_init_window_const(L, mb1, mb1, mb, mb);
 
     _mzd_trsm_lower_left_even (L00, B0, cutoff);
 
     mzd_free_window(B0);
     mzd_free_window(B1);
 
-    mzd_free_window(L00);
-    mzd_free_window(L10);
-    mzd_free_window(L11);
+    mzd_free_window((mzd_t*)L00);
+    mzd_free_window((mzd_t*)L10);
+    mzd_free_window((mzd_t*)L11);
   }
 }
 
     
     mzd_t *B0  = mzd_init_window (B,  0,  0, m1, nb);
     mzd_t *B1  = mzd_init_window (B,  m1, 0, mb, nb);
-    mzd_t *U00 = mzd_init_window (U,  0,  0, m1, m1);
-    mzd_t *U01 = mzd_init_window (U,  0, m1, m1, mb);
-    mzd_t *U11 = mzd_init_window (U, m1, m1, mb, mb);
+    mzd_t const *U00 = mzd_init_window_const (U,  0,  0, m1, m1);
+    mzd_t const *U01 = mzd_init_window_const (U,  0, m1, m1, mb);
+    mzd_t const *U11 = mzd_init_window_const (U, m1, m1, mb, mb);
     
     _mzd_trsm_upper_left_even (U11, B1, cutoff);
     mzd_addmul (B0, U01, B1, cutoff);
     mzd_free_window(B0);
     mzd_free_window(B1);
     
-    mzd_free_window(U00);
-    mzd_free_window(U01);
-    mzd_free_window(U11);
+    mzd_free_window((mzd_t*)U00);
+    mzd_free_window((mzd_t*)U01);
+    mzd_free_window((mzd_t*)U11);
   }
 }
 
 
     mzd_t *B0 = mzd_init_window(B,  0,     0,   mb1, nb);
     mzd_t *B1 = mzd_init_window(B, mb1,    0,   mb,  nb);
-    mzd_t *U00 = mzd_init_window(U, 0,     0, mb1, mb1);
-    mzd_t *U01 = mzd_init_window(U, 0,   mb1, mb1, mb);
-    mzd_t *U11 = mzd_init_window(U, mb1, mb1, mb, mb);
+    mzd_t const *U00 = mzd_init_window_const(U, 0,     0, mb1, mb1);
+    mzd_t const *U01 = mzd_init_window_const(U, 0,   mb1, mb1, mb);
+    mzd_t const *U11 = mzd_init_window_const(U, mb1, mb1, mb, mb);
 
     _mzd_trsm_upper_left_even (U11, B1, cutoff);
 
     mzd_free_window(B0);
     mzd_free_window(B1);
 
-    mzd_free_window(U00);
-    mzd_free_window(U01);
-    mzd_free_window(U11);
+    mzd_free_window((mzd_t*)U00);
+    mzd_free_window((mzd_t*)U01);
+    mzd_free_window((mzd_t*)U11);
   }
 }

File testsuite/test_smallops.c

 #include "config.h"
 #include <stdlib.h>
+#include <inttypes.h>
 #include "testing.h"
 #include "m4ri.h"
 
 int smallops_test_add(rci_t M, rci_t N, rci_t m, rci_t n, rci_t offset, word pattern) {
   int ret = 0; 
 
-  printf("      mzd_add: M: %4d, N: %4d, m: %4d, n: %4d, offset: %4d, pattern: 0x%llx ", M, N, m, n, offset, pattern);
+  printf("      mzd_add: M: %4d, N: %4d, m: %4d, n: %4d, offset: %4d, pattern: 0x%" PRIx64 " ", M, N, m, n, offset, pattern);
 
   mzd_t *AA;
   mzd_t *A = mzd_init_test_matrix_random(M, N, m, n, offset, pattern, &AA);

File testsuite/testing.c

   return a;
 }
 
-mzd_t *mzd_free_test_matrix_random(mzd_t *A, mzd_t *a) {
+void mzd_free_test_matrix_random(mzd_t *A, mzd_t *a) {
   mzd_free(a);
   mzd_free(A);
 };

File testsuite/testing.h

 #include "packedmatrix.h"
 
 mzd_t *mzd_init_test_matrix_random(rci_t M, rci_t N, rci_t m, rci_t n, rci_t offset, word pattern, mzd_t **A);
-mzd_t *mzd_free_test_matrix_random(mzd_t *A, mzd_t *a);
+void mzd_free_test_matrix_random(mzd_t *A, mzd_t *a);
 int mzd_check_pattern(mzd_t *A, rci_t m, rci_t n, rci_t offset, word pattern);
 
 #endif //TESTING_H