M4RIE  0.20120415
 All Data Structures Files Functions Variables Defines
permutation.h
Go to the documentation of this file.
00001 
00008 #ifndef M4RIE_PERMUTATION_H
00009 #define M4RIE_PERMUTATION_H
00010 
00011 /******************************************************************************
00012 *
00013 *            M4RIE: Linear Algebra over GF(2^e)
00014 *
00015 *    Copyright (C) 2011 Martin Albrecht <martinralbrecht@googlemail.com>
00016 *
00017 *  Distributed under the terms of the GNU General Public License (GEL)
00018 *  version 2 or higher.
00019 *
00020 *    This code is distributed in the hope that it will be useful,
00021 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023 *    General Public License for more details.
00024 *
00025 *  The full text of the GPL is available at:
00026 *
00027 *                  http://www.gnu.org/licenses/
00028 ******************************************************************************/
00029 
00030 #include <m4ri/mzp.h>
00031 #include "mzed.h"
00032 #include "mzd_slice.h"
00033 
00043 static inline void mzed_apply_p_left(mzed_t *A, mzp_t const *P) {
00044   mzd_apply_p_left(A->x, P);
00045 }
00046 
00056 static inline void mzed_apply_p_left_trans(mzed_t *A, mzp_t const *P) {
00057   mzd_apply_p_left_trans(A->x, P);
00058 }
00059 
00069 static inline void mzed_apply_p_right(mzed_t *A, mzp_t const *P) {
00070   if(A->nrows == 0)
00071     return;
00072   rci_t const length = MIN(P->length, A->ncols);
00073   for (rci_t i = length-1; i >= 0; --i) {
00074     mzed_col_swap(A, i, P->values[i]);
00075   }
00076 }
00077 
00087 static inline void mzed_apply_p_right_trans(mzed_t *A, mzp_t const *P) {
00088   if(A->nrows == 0)
00089     return;
00090   rci_t const length = MIN(P->length, A->ncols);
00091   for (rci_t i = 0; i < length; ++i) {
00092     mzed_col_swap(A, i, P->values[i]);
00093   }
00094 }
00095 
00105 static inline void mzd_slice_apply_p_left(mzd_slice_t *A, mzp_t const *P) {
00106   for(unsigned int i=0; i<A->depth; i++) {
00107     mzd_apply_p_left(A->x[i], P);
00108   }
00109 }
00110 
00120 static inline void mzd_slice_apply_p_left_trans(mzd_slice_t *A, mzp_t const *P) {
00121   for(unsigned int i=0; i<A->depth; i++) {
00122     mzd_apply_p_left_trans(A->x[i], P);
00123   }
00124 }
00125 
00135 static inline void mzd_slice_apply_p_right(mzd_slice_t *A, mzp_t const *P) {
00136   for(unsigned int i=0; i<A->depth; i++) {
00137     mzd_apply_p_right(A->x[i], P);
00138   }
00139 }
00140 
00150 static inline void mzd_slice_apply_p_right_trans(mzd_slice_t *A, mzp_t const *P) {
00151   for(unsigned int i=0; i<A->depth; i++) {
00152     mzd_apply_p_right_trans(A->x[i], P);
00153   }
00154 }
00155 
00167 static inline void mzd_slice_apply_p_right_trans_tri(mzd_slice_t *A, mzp_t const *P) {
00168   for(unsigned int i=0; i<A->depth; i++) {
00169     mzd_apply_p_right_trans_tri(A->x[i], P);
00170   }
00171 }
00172 
00173 
00174 #endif // M4RIE_PERMUTATION_H