M4RIE  0.20120415
 All Data Structures Files Functions Variables Defines
newton_john.h
Go to the documentation of this file.
00001 
00011 #ifndef M4RIE_NEWTON_JOHN_H
00012 #define M4RIE_NEWTON_JOHN_H
00013 
00014 /******************************************************************************
00015 *
00016 *            M4RIE: Linear Algebra over GF(2^e)
00017 *
00018 *    Copyright (C) 2010,2011 Martin Albrecht <martinralbrecht@googlemail.com>
00019 *
00020 *  Distributed under the terms of the GNU General Public License (GEL)
00021 *  version 2 or higher.
00022 *
00023 *    This code is distributed in the hope that it will be useful,
00024 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00025 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 *    General Public License for more details.
00027 *
00028 *  The full text of the GPL is available at:
00029 *
00030 *                  http://www.gnu.org/licenses/
00031 ******************************************************************************/
00032 
00033 #include "gf2e.h"
00034 #include "mzed.h"
00035 #include "mzd_slice.h"
00036 
00041 typedef struct {
00042   rci_t *L;  
00043   mzed_t *M; 
00044   mzed_t *T; 
00045 } njt_mzed_t;
00046 
00054 njt_mzed_t *njt_mzed_init(const gf2e *ff, const rci_t ncols);
00055 
00062 void njt_mzed_free(njt_mzed_t *t);
00063 
00073 njt_mzed_t * mzed_make_table(njt_mzed_t *T, const mzed_t *A, const rci_t r, const rci_t c);
00074 
00087 mzed_t *mzed_mul_newton_john(mzed_t *C, const mzed_t *A, const mzed_t *B);
00088 
00101 mzed_t *mzed_addmul_newton_john(mzed_t *C, const mzed_t *A, const mzed_t *B);
00102 
00118 mzed_t *_mzed_mul_newton_john0(mzed_t *C, const mzed_t *A, const mzed_t *B);
00119 
00134 mzed_t *_mzed_mul_newton_john(mzed_t *C, const mzed_t *A, const mzed_t *B);
00135 
00147 rci_t mzed_echelonize_newton_john(mzed_t *A, int full);
00148 
00157 mzed_t *mzed_invert_newton_john(mzed_t *B, const mzed_t *A);
00158 
00168 void mzed_trsm_lower_left_newton_john(const mzed_t *L, mzed_t *B);
00169 
00179 void mzd_slice_trsm_lower_left_newton_john(const mzd_slice_t *L, mzd_slice_t *B);
00180 
00190 void mzed_trsm_upper_left_newton_john(const mzed_t *U, mzed_t *B);
00191 
00201 void mzd_slice_trsm_upper_left_newton_john(const mzd_slice_t *U, mzd_slice_t *B);
00202 
00209 rci_t mzed_ple_newton_john(mzed_t *A, mzp_t *P, mzp_t *Q);
00210 
00227 static inline void mzed_process_rows(mzed_t *M, const rci_t startrow, const rci_t endrow, rci_t startcol, const njt_mzed_t *T) {
00228   mzd_process_rows(M->x, startrow, endrow, startcol*M->w, M->w, T->T->x, T->L);
00229 }
00230 
00245 static inline void mzed_process_rows2(mzed_t *M, const rci_t startrow, const rci_t endrow, const rci_t startcol, 
00246                                       const njt_mzed_t *T0, const njt_mzed_t *T1) {
00247   mzd_process_rows2(M->x, startrow, endrow, startcol*M->w, 2*M->w, T0->T->x, T0->L, T1->T->x, T1->L);
00248 }
00249 
00265 static inline void mzed_process_rows3(mzed_t *M, const rci_t startrow, const rci_t endrow, const rci_t startcol,
00266                                       const njt_mzed_t *T0, const njt_mzed_t *T1, const njt_mzed_t *T2) {
00267   mzd_process_rows3(M->x, startrow, endrow, startcol*M->w, 3*M->w, T0->T->x, T0->L, T1->T->x, T1->L, T2->T->x, T2->L);
00268 }
00269 
00286 static inline void mzed_process_rows4(mzed_t *M, const rci_t startrow, const rci_t endrow, const rci_t startcol,
00287                                       const njt_mzed_t *T0, const njt_mzed_t *T1, const njt_mzed_t *T2, const njt_mzed_t *T3) {
00288   mzd_process_rows4(M->x, startrow, endrow, startcol*M->w, 4*M->w, T0->T->x, T0->L, T1->T->x, T1->L, T2->T->x, T2->L, T3->T->x, T3->L);
00289 }
00290 
00308 static inline void mzed_process_rows5(mzed_t *M, const rci_t startrow, const rci_t endrow, const rci_t startcol,
00309                                       const njt_mzed_t *T0, const njt_mzed_t *T1, const njt_mzed_t *T2, const njt_mzed_t *T3, const njt_mzed_t *T4) {
00310   mzd_process_rows5(M->x, startrow, endrow, startcol*M->w, 5*M->w, T0->T->x, T0->L, T1->T->x, T1->L, T2->T->x, T2->L, T3->T->x, T3->L, T4->T->x, T4->L);
00311 }
00312 
00313 
00332 static inline void mzed_process_rows6(mzed_t *M, const rci_t startrow, const rci_t endrow, const rci_t startcol,
00333                                       const njt_mzed_t *T0, const njt_mzed_t *T1, const njt_mzed_t *T2,
00334                                       const njt_mzed_t *T3, const njt_mzed_t *T4, const njt_mzed_t *T5) {
00335   mzd_process_rows6(M->x, startrow, endrow, startcol*M->w, 6*M->w, T0->T->x, T0->L, T1->T->x, T1->L, T2->T->x, T2->L, T3->T->x, T3->L, T4->T->x, T4->L, T5->T->x, T5->L);
00336 }
00337 
00338 
00339 #endif //M4RIE_NEWTON_JOHN_H