Botan  1.11.15
Public Member Functions | Public Attributes
Botan::binary_matrix Struct Reference

#include <binary_matrix.h>

List of all members.

Public Member Functions

 binary_matrix (u32bit m_rown, u32bit m_coln)
u32bit coef (u32bit i, u32bit j)
secure_vector< int > row_reduced_echelon_form ()
void row_xor (u32bit a, u32bit b)
void set_coef_to_one (u32bit i, u32bit j)
void set_to_zero ()
void toggle_coeff (u32bit i, u32bit j)

Public Attributes

u32bit m_coln
std::vector< u32bitm_elem
u32bit m_rown
u32bit m_rwdcnt

Detailed Description

Definition at line 21 of file binary_matrix.h.


Constructor & Destructor Documentation

Definition at line 17 of file binary_matrix.cpp.

References BITS_PER_U32, m_coln, m_elem, m_rown, and m_rwdcnt.

   {
   m_coln = coln;
   m_rown = rown;
   m_rwdcnt = (1 + (m_coln - 1) / BITS_PER_U32);
   m_elem = std::vector<u32bit>(m_rown * m_rwdcnt);
   }

Member Function Documentation

return the coefficient out of F_2

Definition at line 32 of file binary_matrix.h.

References BITS_PER_U32, m_elem, and m_rwdcnt.

Referenced by row_reduced_echelon_form().

         {
         return (m_elem[(i) * m_rwdcnt + (j) / BITS_PER_U32] >> (j % BITS_PER_U32)) & 1;
         };

Definition at line 35 of file binary_matrix.cpp.

References coef(), m_coln, m_rown, and row_xor().

   {
   u32bit i, failcnt, findrow, max=m_coln - 1;

   secure_vector<int> perm(m_coln);
   for(i=0;i<m_coln;i++)
      {
      perm[i]=i;//initialize permutation.
      }
   failcnt = 0;

   for(i=0;i<m_rown;i++,max--)
      {
      findrow=0;
      for(u32bit j=i;j<m_rown;j++)
         {
         if(coef(j,max))
            {
            if (i!=j)//not needed as ith row is 0 and jth row is 1.
               row_xor(i,j);//xor to the row.(swap)?
            findrow=1;
            break;
            }//largest value found (end if)
         }

      if(!findrow)//if no row with a 1 found then swap last column and the column with no 1 down.
         {
         perm[m_coln - m_rown - 1 - failcnt] = max;
         failcnt++;
         if (!max)
            {
            //CSEC_FREE_MEM_CHK_SET_NULL(*p_perm);
            //CSEC_THR_RETURN();
            perm.resize(0);
            }
         i--;
         }
      else
         {
         perm[i+m_coln - m_rown] = max;
         for(u32bit j=i+1;j<m_rown;j++)//fill the column downwards with 0's
            {
            if(coef(j,(max)))
               {
               row_xor(j,i);//check the arg. order.
               }
            }

         for(int j=i-1;j>=0;j--)//fill the column with 0's upwards too.
            {
            if(coef(j,(max)))
               {
               row_xor(j,i);
               }
            }
         }
      }//end for(i)
   return perm;
   }

Definition at line 25 of file binary_matrix.cpp.

References m_elem, and m_rwdcnt.

Referenced by row_reduced_echelon_form().

   {
   u32bit i;
   for(i=0;i<m_rwdcnt;i++)
      {
      m_elem[a*m_rwdcnt+i]^=m_elem[b*m_rwdcnt+i];
      }
   }
void Botan::binary_matrix::set_coef_to_one ( u32bit  i,
u32bit  j 
) [inline]

Definition at line 37 of file binary_matrix.h.

References BITS_PER_U32, m_elem, and m_rwdcnt.

         {
         m_elem[(i) * m_rwdcnt + (j) / BITS_PER_U32] |= (1UL << ((j) % BITS_PER_U32)) ;
         };

Definition at line 47 of file binary_matrix.h.

References m_elem, and Botan::zeroise().

         {
         zeroise(m_elem);
         }
void Botan::binary_matrix::toggle_coeff ( u32bit  i,
u32bit  j 
) [inline]

Definition at line 42 of file binary_matrix.h.

References BITS_PER_U32, m_elem, and m_rwdcnt.

         {
         m_elem[(i) * m_rwdcnt + (j) / BITS_PER_U32] ^= (1UL << ((j) % BITS_PER_U32)) ;
         }

Member Data Documentation

Definition at line 53 of file binary_matrix.h.

Referenced by binary_matrix(), and row_reduced_echelon_form().

Definition at line 55 of file binary_matrix.h.

Referenced by binary_matrix(), coef(), row_xor(), set_coef_to_one(), set_to_zero(), and toggle_coeff().

Definition at line 52 of file binary_matrix.h.

Referenced by binary_matrix(), and row_reduced_echelon_form().

Definition at line 54 of file binary_matrix.h.

Referenced by binary_matrix(), coef(), row_xor(), set_coef_to_one(), and toggle_coeff().


The documentation for this struct was generated from the following files: