<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>M4RI: packedmatrix.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">M4RI <span id="projectnumber">1.0.1</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">packedmatrix.h</div> </div> </div> <div class="contents"> <a href="packedmatrix_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00009"></a>00009 <span class="preprocessor">#ifndef PACKEDMATRIX_H</span> <a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#define PACKEDMATRIX_H</span> <a name="l00011"></a>00011 <span class="preprocessor"></span><span class="comment">/*******************************************************************</span> <a name="l00012"></a>00012 <span class="comment">*</span> <a name="l00013"></a>00013 <span class="comment">* M4RI: Linear Algebra over GF(2)</span> <a name="l00014"></a>00014 <span class="comment">*</span> <a name="l00015"></a>00015 <span class="comment">* Copyright (C) 2007, 2008 Gregory Bard <bard@fordham.edu></span> <a name="l00016"></a>00016 <span class="comment">* Copyright (C) 2008-2010 Martin Albrecht <M.R.Albrecht@rhul.ac.uk></span> <a name="l00017"></a>00017 <span class="comment">*</span> <a name="l00018"></a>00018 <span class="comment">* Distributed under the terms of the GNU General Public License (GPL)</span> <a name="l00019"></a>00019 <span class="comment">* version 2 or higher.</span> <a name="l00020"></a>00020 <span class="comment">*</span> <a name="l00021"></a>00021 <span class="comment">* This code is distributed in the hope that it will be useful,</span> <a name="l00022"></a>00022 <span class="comment">* but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00023"></a>00023 <span class="comment">* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00024"></a>00024 <span class="comment">* General Public License for more details.</span> <a name="l00025"></a>00025 <span class="comment">*</span> <a name="l00026"></a>00026 <span class="comment">* The full text of the GPL is available at:</span> <a name="l00027"></a>00027 <span class="comment">*</span> <a name="l00028"></a>00028 <span class="comment">* http://www.gnu.org/licenses/</span> <a name="l00029"></a>00029 <span class="comment">*</span> <a name="l00030"></a>00030 <span class="comment">********************************************************************/</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="preprocessor">#include <math.h></span> <a name="l00033"></a>00033 <span class="preprocessor">#include <assert.h></span> <a name="l00034"></a>00034 <span class="preprocessor">#include <stdio.h></span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="preprocessor">#ifdef HAVE_SSE2</span> <a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#include <emmintrin.h></span> <a name="l00038"></a>00038 <span class="preprocessor">#endif</span> <a name="l00039"></a>00039 <span class="preprocessor"></span> <a name="l00040"></a>00040 <a name="l00041"></a>00041 <span class="preprocessor">#ifdef HAVE_SSE2</span> <a name="l00042"></a>00042 <span class="preprocessor"></span> <a name="l00049"></a>00049 <span class="preprocessor">#define SSE2_CUTOFF 20</span> <a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00051"></a>00051 <span class="preprocessor"></span> <a name="l00060"></a><a class="code" href="packedmatrix_8h.html#ac16bd56bca01886245a5f82f4b39f1ef">00060</a> <span class="preprocessor">#define MZD_MUL_BLOCKSIZE MIN(((int)sqrt((double)(4*CPU_L2_CACHE)))/2,2048)</span> <a name="l00061"></a>00061 <span class="preprocessor"></span> <a name="l00062"></a>00062 <a name="l00069"></a><a class="code" href="structmzd__t.html">00069</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00075"></a><a class="code" href="structmzd__t.html#adf2667e5b164eca4e243be0c3590ca53">00075</a> <a class="code" href="struct__mm__block.html">mmb_t</a> *<a class="code" href="structmzd__t.html#adf2667e5b164eca4e243be0c3590ca53">blocks</a>; <a name="l00076"></a>00076 <a name="l00081"></a><a class="code" href="structmzd__t.html#a431207854b150a792cd98b9ae801129b">00081</a> <span class="keywordtype">size_t</span> <a class="code" href="structmzd__t.html#a431207854b150a792cd98b9ae801129b">nrows</a>; <a name="l00082"></a>00082 <a name="l00087"></a><a class="code" href="structmzd__t.html#afc8515ec2757e92d80dd198b33bc3cab">00087</a> <span class="keywordtype">size_t</span> <a class="code" href="structmzd__t.html#afc8515ec2757e92d80dd198b33bc3cab">ncols</a>; <a name="l00088"></a>00088 <a name="l00092"></a><a class="code" href="structmzd__t.html#ae1b2b55b81f04088c8184bfa9471d767">00092</a> <span class="keywordtype">size_t</span> <a class="code" href="structmzd__t.html#ae1b2b55b81f04088c8184bfa9471d767">width</a>; <a name="l00093"></a>00093 <a name="l00098"></a><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">00098</a> <span class="keywordtype">size_t</span> <a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>; <a name="l00099"></a>00099 <a name="l00105"></a><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">00105</a> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> **<a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>; <a name="l00106"></a>00106 <a name="l00107"></a>00107 } <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a>; <a name="l00108"></a>00108 <a name="l00119"></a>00119 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_init(<span class="keyword">const</span> <span class="keywordtype">size_t</span> r, <span class="keyword">const</span> <span class="keywordtype">size_t</span> c); <a name="l00120"></a>00120 <a name="l00127"></a>00127 <span class="keywordtype">void</span> mzd_free(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A); <a name="l00128"></a>00128 <a name="l00129"></a>00129 <a name="l00151"></a>00151 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_init_window(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> lowr, <span class="keyword">const</span> <span class="keywordtype">size_t</span> lowc, <span class="keyword">const</span> <span class="keywordtype">size_t</span> highr, <span class="keyword">const</span> <span class="keywordtype">size_t</span> highc); <a name="l00152"></a>00152 <a name="l00159"></a><a class="code" href="packedmatrix_8h.html#adc489a58a3989dad9aecdef73ff12544">00159</a> <span class="preprocessor">#define mzd_free_window mzd_free</span> <a name="l00160"></a>00160 <span class="preprocessor"></span> <a name="l00169"></a><a class="code" href="packedmatrix_8h.html#af890631f07570822c0dab42eeb7fe2cf">00169</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#af890631f07570822c0dab42eeb7fe2cf" title="Swap the two rows rowa and rowb.">mzd_row_swap</a>(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> rowa, <span class="keyword">const</span> <span class="keywordtype">size_t</span> rowb) { <a name="l00170"></a>00170 <span class="keywordflow">if</span>(rowa == rowb) <a name="l00171"></a>00171 <span class="keywordflow">return</span>; <a name="l00172"></a>00172 <span class="keywordtype">size_t</span> i; <a name="l00173"></a>00173 <span class="keywordtype">size_t</span> width = M-><a class="code" href="structmzd__t.html#ae1b2b55b81f04088c8184bfa9471d767">width</a> - 1; <a name="l00174"></a>00174 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> *a = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[rowa]; <a name="l00175"></a>00175 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> *b = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[rowb]; <a name="l00176"></a>00176 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> tmp; <a name="l00177"></a>00177 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> mask_begin = <a class="code" href="misc_8h.html#a58c8eaa587f74c1f6ee3bb8b6bf9394c" title="creat a bit mask to zero out all but the nRADIX rightmost bits.">RIGHT_BITMASK</a>(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> - M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>); <a name="l00178"></a>00178 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> mask_end = <a class="code" href="misc_8h.html#a2354ea8ba9a104d0c624038195f0aada" title="creat a bit mask to zero out all but the nRADIX leftmost bits.">LEFT_BITMASK</a>( (M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a> + M-><a class="code" href="structmzd__t.html#afc8515ec2757e92d80dd198b33bc3cab">ncols</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> ); <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keywordflow">if</span> (width != 0) { <a name="l00181"></a>00181 tmp = a[0]; <a name="l00182"></a>00182 a[0] = (a[0] & ~mask_begin) | (b[0] & mask_begin); <a name="l00183"></a>00183 b[0] = (b[0] & ~mask_begin) | (tmp & mask_begin); <a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="keywordflow">for</span>(i = 1; i<width; i++) { <a name="l00186"></a>00186 tmp = a[i]; <a name="l00187"></a>00187 a[i] = b[i]; <a name="l00188"></a>00188 b[i] = tmp; <a name="l00189"></a>00189 } <a name="l00190"></a>00190 tmp = a[width]; <a name="l00191"></a>00191 a[width] = (a[width] & ~mask_end) | (b[width] & mask_end); <a name="l00192"></a>00192 b[width] = (b[width] & ~mask_end) | (tmp & mask_end); <a name="l00193"></a>00193 <a name="l00194"></a>00194 } <span class="keywordflow">else</span> { <a name="l00195"></a>00195 tmp = a[0]; <a name="l00196"></a>00196 a[0] = (a[0] & ~mask_begin) | (b[0] & mask_begin & mask_end) | (a[0] & ~mask_end); <a name="l00197"></a>00197 b[0] = (b[0] & ~mask_begin) | (tmp & mask_begin & mask_end) | (b[0] & ~mask_end); <a name="l00198"></a>00198 } <a name="l00199"></a>00199 } <a name="l00200"></a>00200 <a name="l00213"></a>00213 <span class="keywordtype">void</span> mzd_copy_row(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a>* B, <span class="keywordtype">size_t</span> i, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a>* A, <span class="keywordtype">size_t</span> j); <a name="l00214"></a>00214 <a name="l00223"></a>00223 <span class="keywordtype">void</span> mzd_col_swap(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> cola, <span class="keyword">const</span> <span class="keywordtype">size_t</span> colb); <a name="l00224"></a>00224 <a name="l00235"></a><a class="code" href="packedmatrix_8h.html#a72fb0336dbbc9b817f4a274c38f35e28">00235</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#a72fb0336dbbc9b817f4a274c38f35e28" title="Swap the two columns cola and colb but only between start_row and stop_row.">mzd_col_swap_in_rows</a>(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> cola, <span class="keyword">const</span> <span class="keywordtype">size_t</span> colb, <span class="keyword">const</span> <span class="keywordtype">size_t</span> start_row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> stop_row) { <a name="l00236"></a>00236 <span class="keywordflow">if</span> (cola == colb) <a name="l00237"></a>00237 <span class="keywordflow">return</span>; <a name="l00238"></a>00238 <a name="l00239"></a>00239 <span class="keyword">const</span> <span class="keywordtype">size_t</span> _cola = cola + M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>; <a name="l00240"></a>00240 <span class="keyword">const</span> <span class="keywordtype">size_t</span> _colb = colb + M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>; <a name="l00241"></a>00241 <a name="l00242"></a>00242 <span class="keyword">const</span> <span class="keywordtype">size_t</span> a_word = _cola/<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00243"></a>00243 <span class="keyword">const</span> <span class="keywordtype">size_t</span> b_word = _colb/<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00244"></a>00244 <span class="keyword">const</span> <span class="keywordtype">size_t</span> a_bit = _cola%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00245"></a>00245 <span class="keyword">const</span> <span class="keywordtype">size_t</span> b_bit = _colb%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00246"></a>00246 <a name="l00247"></a>00247 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> a, b, *base; <a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="keywordtype">size_t</span> i; <a name="l00250"></a>00250 <a name="l00251"></a>00251 <span class="keywordflow">if</span>(a_word == b_word) { <a name="l00252"></a>00252 <span class="keyword">const</span> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> ai = <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> - a_bit - 1; <a name="l00253"></a>00253 <span class="keyword">const</span> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> bi = <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> - b_bit - 1; <a name="l00254"></a>00254 <span class="keywordflow">for</span> (i=start_row; i<stop_row; i++) { <a name="l00255"></a>00255 base = (M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[i] + a_word); <a name="l00256"></a>00256 <span class="keyword">register</span> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> b = *base; <a name="l00257"></a>00257 <span class="keyword">register</span> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> x = ((b >> ai) ^ (b >> bi)) & 1; <span class="comment">// XOR temporary</span> <a name="l00258"></a>00258 *base = b ^ ((x << ai) | (x << bi)); <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <span class="keywordflow">return</span>; <a name="l00261"></a>00261 } <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="keyword">const</span> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> a_bm = (<a class="code" href="misc_8h.html#a206b6f5362e56b51ca957635350b70b6" title="The number one as a word.">ONE</a><<(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> - (a_bit) - 1)); <a name="l00264"></a>00264 <span class="keyword">const</span> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> b_bm = (<a class="code" href="misc_8h.html#a206b6f5362e56b51ca957635350b70b6" title="The number one as a word.">ONE</a><<(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> - (b_bit) - 1)); <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="keywordflow">if</span>(a_bit > b_bit) { <a name="l00267"></a>00267 <span class="keyword">const</span> <span class="keywordtype">size_t</span> offset = a_bit - b_bit; <a name="l00268"></a>00268 <span class="keywordflow">for</span> (i=start_row; i<stop_row; i++) { <a name="l00269"></a>00269 base = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[i]; <a name="l00270"></a>00270 a = *(base + a_word); <a name="l00271"></a>00271 b = *(base + b_word); <a name="l00272"></a>00272 <a name="l00273"></a>00273 a ^= (b & b_bm) >> offset; <a name="l00274"></a>00274 b ^= (a & a_bm) << offset; <a name="l00275"></a>00275 a ^= (b & b_bm) >> offset; <a name="l00276"></a>00276 <a name="l00277"></a>00277 *(base + a_word) = a; <a name="l00278"></a>00278 *(base + b_word) = b; <a name="l00279"></a>00279 } <a name="l00280"></a>00280 } <span class="keywordflow">else</span> { <a name="l00281"></a>00281 <span class="keyword">const</span> <span class="keywordtype">size_t</span> offset = b_bit - a_bit; <a name="l00282"></a>00282 <span class="keywordflow">for</span> (i=start_row; i<stop_row; i++) { <a name="l00283"></a>00283 base = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[i]; <a name="l00284"></a>00284 a = *(base + a_word); <a name="l00285"></a>00285 b = *(base + b_word); <a name="l00286"></a>00286 <a name="l00287"></a>00287 a ^= (b & b_bm) << offset; <a name="l00288"></a>00288 b ^= (a & a_bm) >> offset; <a name="l00289"></a>00289 a ^= (b & b_bm) << offset; <a name="l00290"></a>00290 *(base + a_word) = a; <a name="l00291"></a>00291 *(base + b_word) = b; <a name="l00292"></a>00292 } <a name="l00293"></a>00293 } <a name="l00294"></a>00294 <a name="l00295"></a>00295 } <a name="l00296"></a>00296 <a name="l00308"></a><a class="code" href="packedmatrix_8h.html#a8b092ba6fad1336b5baa5c018fd35d62">00308</a> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="misc_8h.html#a0fd3ebb26b5e387df9c3677528d9e39c" title="Pretty for unsigned char.">BIT</a> <a class="code" href="packedmatrix_8h.html#a8b092ba6fad1336b5baa5c018fd35d62" title="Read the bit at position M[row,col].">mzd_read_bit</a>(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> col ) { <a name="l00309"></a>00309 <span class="keywordflow">return</span> <a class="code" href="misc_8h.html#a5a5bf7a849b5cc252a18003abd06cb9f" title="Get the bit spot (counting from the left) in the word w.">GET_BIT</a>(M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[row][(col+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)/<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>], (col+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) % <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>); <a name="l00310"></a>00310 } <a name="l00311"></a>00311 <a name="l00324"></a><a class="code" href="packedmatrix_8h.html#a279d49adacd0f08fbcf9d3936c1774a4">00324</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#a279d49adacd0f08fbcf9d3936c1774a4" title="Write the bit value to position M[row,col].">mzd_write_bit</a>(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> col, <span class="keyword">const</span> <a class="code" href="misc_8h.html#a0fd3ebb26b5e387df9c3677528d9e39c" title="Pretty for unsigned char.">BIT</a> value) { <a name="l00325"></a>00325 <span class="keywordflow">if</span> (value==1) <a name="l00326"></a>00326 <a class="code" href="misc_8h.html#ad25524880cc697d9949a927918527c5f" title="Set the bit spot (counting from the left) in the word w.">SET_BIT</a>(M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[row][(col+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)/<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>], (col+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) % <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>); <a name="l00327"></a>00327 <span class="keywordflow">else</span> <a name="l00328"></a>00328 <a class="code" href="misc_8h.html#a6a0302c19b801b3a02f51c3da22a3cc4" title="Clear the bit spot (counting from the left) in the word w.">CLR_BIT</a>(M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[row][(col+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)/<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>], (col+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) % <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>); <a name="l00329"></a>00329 } <a name="l00330"></a>00330 <a name="l00339"></a>00339 <span class="keywordtype">void</span> mzd_print(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M); <a name="l00340"></a>00340 <a name="l00347"></a>00347 <span class="keywordtype">void</span> mzd_print_tight(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M); <a name="l00348"></a>00348 <a name="l00359"></a>00359 <span class="comment">/*void mzd_row_add_offset(mzd_t *M, size_t dstrow, size_t srcrow, size_t coloffset); */</span> <a name="l00360"></a><a class="code" href="packedmatrix_8h.html#a920cc86cc3795ee1dff8c56e5cc113dc">00360</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#a920cc86cc3795ee1dff8c56e5cc113dc" title="Add the rows sourcerow and destrow and stores the total in the row destrow, but only begins at the co...">mzd_row_add_offset</a>(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keywordtype">size_t</span> dstrow, <span class="keywordtype">size_t</span> srcrow, <span class="keywordtype">size_t</span> coloffset) { <a name="l00361"></a>00361 coloffset += M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>; <a name="l00362"></a>00362 <span class="keyword">const</span> <span class="keywordtype">size_t</span> startblock= coloffset/<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00363"></a>00363 <span class="keywordtype">size_t</span> wide = M-><a class="code" href="structmzd__t.html#ae1b2b55b81f04088c8184bfa9471d767">width</a> - startblock; <a name="l00364"></a>00364 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> *src = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[srcrow] + startblock; <a name="l00365"></a>00365 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> *dst = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[dstrow] + startblock; <a name="l00366"></a>00366 <a name="l00367"></a>00367 <span class="keywordflow">if</span>(!wide) <a name="l00368"></a>00368 <span class="keywordflow">return</span>; <a name="l00369"></a>00369 <a name="l00370"></a>00370 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> temp = *src++; <a name="l00371"></a>00371 <span class="keywordflow">if</span> (coloffset%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>) <a name="l00372"></a>00372 temp = <a class="code" href="misc_8h.html#ab88914d08b653abdc6c0ed58e19047de" title="Return the n rightmost bits of the word w.">RIGHTMOST_BITS</a>(temp, (RADIX-(coloffset%RADIX)-1)); <a name="l00373"></a>00373 *dst++ ^= temp; <a name="l00374"></a>00374 wide--; <a name="l00375"></a>00375 <a name="l00376"></a>00376 <span class="preprocessor">#ifdef HAVE_SSE2 </span> <a name="l00377"></a>00377 <span class="preprocessor"></span> <span class="keywordflow">if</span> (<a class="code" href="misc_8h.html#ab393859ad772802fd0cb0277463730e4" title="Return alignment of addr w.r.t. n. For example the address 17 would be 1 aligned w.r.t. 16.">ALIGNMENT</a>(src,16)==8 && wide) { <a name="l00378"></a>00378 *dst++ ^= *src++; <a name="l00379"></a>00379 wide--; <a name="l00380"></a>00380 } <a name="l00381"></a>00381 __m128i *__src = (__m128i*)src; <a name="l00382"></a>00382 __m128i *__dst = (__m128i*)dst; <a name="l00383"></a>00383 <span class="keyword">const</span> __m128i *eof = (__m128i*)((<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)(src + wide) & ~0xF); <a name="l00384"></a>00384 __m128i xmm1; <a name="l00385"></a>00385 <a name="l00386"></a>00386 <span class="keywordflow">while</span>(__src < eof) { <a name="l00387"></a>00387 xmm1 = _mm_xor_si128(*__dst, *__src++); <a name="l00388"></a>00388 *__dst++ = xmm1; <a name="l00389"></a>00389 } <a name="l00390"></a>00390 src = (<a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a>*)__src; <a name="l00391"></a>00391 dst = (<a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a>*)__dst; <a name="l00392"></a>00392 wide = ((<span class="keyword">sizeof</span>(<a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a>)*wide)%16)/<span class="keyword">sizeof</span>(<a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a>); <a name="l00393"></a>00393 <span class="preprocessor">#endif</span> <a name="l00394"></a>00394 <span class="preprocessor"></span> <span class="keywordtype">size_t</span> i; <a name="l00395"></a>00395 <span class="keywordflow">for</span>(i=0; i<wide; i++) { <a name="l00396"></a>00396 dst[i] ^= src[i]; <a name="l00397"></a>00397 } <a name="l00398"></a>00398 } <a name="l00399"></a>00399 <a name="l00411"></a>00411 <span class="keywordtype">void</span> mzd_row_add(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> sourcerow, <span class="keyword">const</span> <span class="keywordtype">size_t</span> destrow); <a name="l00412"></a>00412 <a name="l00427"></a>00427 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_transpose(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *DST, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A ); <a name="l00428"></a>00428 <a name="l00443"></a>00443 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_mul_naive(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B); <a name="l00444"></a>00444 <a name="l00459"></a>00459 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_addmul_naive(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B); <a name="l00460"></a>00460 <a name="l00472"></a>00472 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *_mzd_mul_naive(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B, <span class="keyword">const</span> <span class="keywordtype">int</span> clear); <a name="l00473"></a>00473 <a name="l00483"></a>00483 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *_mzd_mul_va(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *v, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <span class="keywordtype">int</span> clear); <a name="l00484"></a>00484 <a name="l00495"></a>00495 <span class="keywordtype">void</span> mzd_randomize(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M); <a name="l00496"></a>00496 <a name="l00511"></a>00511 <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#aaf5ab2357cc0df3fac6bb7ba10f734e9" title="Set the matrix M to the value equivalent to the integer value provided.">mzd_set_ui</a>(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> value); <a name="l00512"></a>00512 <a name="l00528"></a>00528 <span class="keywordtype">int</span> mzd_gauss_delayed(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> startcol, <span class="keyword">const</span> <span class="keywordtype">int</span> full); <a name="l00529"></a>00529 <a name="l00545"></a>00545 <span class="keywordtype">int</span> mzd_echelonize_naive(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">int</span> full); <a name="l00546"></a>00546 <a name="l00556"></a>00556 <a class="code" href="misc_8h.html#a0fd3ebb26b5e387df9c3677528d9e39c" title="Pretty for unsigned char.">BIT</a> mzd_equal(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B ); <a name="l00557"></a>00557 <a name="l00571"></a>00571 <span class="keywordtype">int</span> mzd_cmp(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B); <a name="l00572"></a>00572 <a name="l00582"></a>00582 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_copy(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *DST, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A); <a name="l00583"></a>00583 <a name="l00604"></a>00604 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_concat(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B); <a name="l00605"></a>00605 <a name="l00625"></a>00625 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_stack(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B); <a name="l00626"></a>00626 <a name="l00639"></a>00639 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_submatrix(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *S, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> lowr, <span class="keyword">const</span> <span class="keywordtype">size_t</span> lowc, <span class="keyword">const</span> <span class="keywordtype">size_t</span> highr, <span class="keyword">const</span> <span class="keywordtype">size_t</span> highc); <a name="l00640"></a>00640 <a name="l00654"></a>00654 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_invert_naive(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *INV, <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *I); <a name="l00655"></a>00655 <a name="l00667"></a>00667 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *mzd_add(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B); <a name="l00668"></a>00668 <a name="l00679"></a>00679 <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *_mzd_add(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *C, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *B); <a name="l00680"></a>00680 <a name="l00691"></a><a class="code" href="packedmatrix_8h.html#a8ef10f72725525b63bdc96f7c0bf9934">00691</a> <span class="preprocessor">#define mzd_sub mzd_add</span> <a name="l00692"></a>00692 <span class="preprocessor"></span> <a name="l00703"></a><a class="code" href="packedmatrix_8h.html#a4855f23f629469e453e97cbce794b55d">00703</a> <span class="preprocessor">#define _mzd_sub _mzd_add</span> <a name="l00704"></a>00704 <span class="preprocessor"></span> <a name="l00725"></a>00725 <span class="keywordtype">void</span> mzd_combine(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> * DST, <span class="keyword">const</span> <span class="keywordtype">size_t</span> row3, <span class="keyword">const</span> <span class="keywordtype">size_t</span> startblock3, <a name="l00726"></a>00726 <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> * SC1, <span class="keyword">const</span> <span class="keywordtype">size_t</span> row1, <span class="keyword">const</span> <span class="keywordtype">size_t</span> startblock1, <a name="l00727"></a>00727 <span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> * SC2, <span class="keyword">const</span> <span class="keywordtype">size_t</span> row2, <span class="keyword">const</span> <span class="keywordtype">size_t</span> startblock2); <a name="l00728"></a>00728 <a name="l00738"></a><a class="code" href="packedmatrix_8h.html#ac5d7f3b1224bf1b336f85dc39ac88106">00738</a> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> <a class="code" href="packedmatrix_8h.html#ac5d7f3b1224bf1b336f85dc39ac88106">mzd_read_bits</a>(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> x, <span class="keyword">const</span> <span class="keywordtype">size_t</span> y, <span class="keyword">const</span> <span class="keywordtype">int</span> n) { <a name="l00739"></a>00739 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> temp; <a name="l00740"></a>00740 <a name="l00741"></a>00741 <span class="comment">/* there are two possible situations. Either all bits are in one</span> <a name="l00742"></a>00742 <span class="comment"> * word or they are spread across two words. */</span> <a name="l00743"></a>00743 <a name="l00744"></a>00744 <span class="keywordflow">if</span> ( ((y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> + n - 1) < <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> ) { <a name="l00745"></a>00745 <span class="comment">/* everything happens in one word here */</span> <a name="l00746"></a>00746 temp = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][(y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>]; <span class="comment">/* get the value */</span> <a name="l00747"></a>00747 temp <<= (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* clear upper bits */</span> <a name="l00748"></a>00748 temp >>= <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> - n; <span class="comment">/* clear lower bits and move to correct position.*/</span> <a name="l00749"></a>00749 <span class="keywordflow">return</span> temp; <a name="l00750"></a>00750 <a name="l00751"></a>00751 } <span class="keywordflow">else</span> { <a name="l00752"></a>00752 <span class="comment">/* two words are affected */</span> <a name="l00753"></a>00753 <span class="keyword">const</span> <span class="keywordtype">size_t</span> block = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct block */</span> <a name="l00754"></a>00754 <span class="keyword">const</span> <span class="keywordtype">size_t</span> spot = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>+n) % <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct offset */</span> <a name="l00755"></a>00755 <span class="comment">/* make room by shifting spot times to the right, and add stuff from the second word */</span> <a name="l00756"></a>00756 temp = (M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block] << spot) | ( M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block + 1] >> (<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> - spot) ); <a name="l00757"></a>00757 <span class="keywordflow">return</span> (temp << (<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-n)) >> (<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-n); <span class="comment">/* clear upper bits and return */</span> <a name="l00758"></a>00758 } <a name="l00759"></a>00759 } <a name="l00760"></a>00760 <a name="l00761"></a>00761 <a name="l00772"></a><a class="code" href="packedmatrix_8h.html#a07a4f4b11033e8343190c03b54e0269f">00772</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#a07a4f4b11033e8343190c03b54e0269f" title="XOR n bits from values to M starting a position (x,y).">mzd_xor_bits</a>(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> x, <span class="keyword">const</span> <span class="keywordtype">size_t</span> y, <span class="keyword">const</span> <span class="keywordtype">int</span> n, <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> values) { <a name="l00773"></a>00773 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> *temp; <a name="l00774"></a>00774 <a name="l00775"></a>00775 <span class="comment">/* there are two possible situations. Either all bits are in one</span> <a name="l00776"></a>00776 <span class="comment"> * word or they are spread across two words. */</span> <a name="l00777"></a>00777 <a name="l00778"></a>00778 <span class="keywordflow">if</span> ( ((y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> + n - 1) < <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> ) { <a name="l00779"></a>00779 <span class="comment">/* everything happens in one word here */</span> <a name="l00780"></a>00780 temp = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x] + (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00781"></a>00781 *temp ^= values<<(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-((y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>)-n); <a name="l00782"></a>00782 <a name="l00783"></a>00783 } <span class="keywordflow">else</span> { <a name="l00784"></a>00784 <span class="comment">/* two words are affected */</span> <a name="l00785"></a>00785 <span class="keyword">const</span> <span class="keywordtype">size_t</span> block = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct block */</span> <a name="l00786"></a>00786 <span class="keyword">const</span> <span class="keywordtype">size_t</span> spot = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>+n) % <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct offset */</span> <a name="l00787"></a>00787 M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block] ^= values >> (spot); <a name="l00788"></a>00788 M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block + 1] ^= values<<(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-spot); <a name="l00789"></a>00789 } <a name="l00790"></a>00790 } <a name="l00791"></a>00791 <a name="l00802"></a><a class="code" href="packedmatrix_8h.html#aacb4812eace6f0db3d1c6984020b7e8c">00802</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#aacb4812eace6f0db3d1c6984020b7e8c" title="AND n bits from values to M starting a position (x,y).">mzd_and_bits</a>(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> x, <span class="keyword">const</span> <span class="keywordtype">size_t</span> y, <span class="keyword">const</span> <span class="keywordtype">int</span> n, <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> values) { <a name="l00803"></a>00803 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> *temp; <a name="l00804"></a>00804 <a name="l00805"></a>00805 <span class="comment">/* there are two possible situations. Either all bits are in one</span> <a name="l00806"></a>00806 <span class="comment"> * word or they are spread across two words. */</span> <a name="l00807"></a>00807 <a name="l00808"></a>00808 <span class="keywordflow">if</span> ( ((y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> + n - 1) < <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> ) { <a name="l00809"></a>00809 <span class="comment">/* everything happens in one word here */</span> <a name="l00810"></a>00810 temp = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x] + (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00811"></a>00811 *temp &= values<<(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-((y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>)-n); <a name="l00812"></a>00812 <a name="l00813"></a>00813 } <span class="keywordflow">else</span> { <a name="l00814"></a>00814 <span class="comment">/* two words are affected */</span> <a name="l00815"></a>00815 <span class="keyword">const</span> <span class="keywordtype">size_t</span> block = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct block */</span> <a name="l00816"></a>00816 <span class="keyword">const</span> <span class="keywordtype">size_t</span> spot = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>+n) % <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct offset */</span> <a name="l00817"></a>00817 M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block] &= values >> (spot); <a name="l00818"></a>00818 M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block + 1] &= values<<(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-spot); <a name="l00819"></a>00819 } <a name="l00820"></a>00820 } <a name="l00821"></a>00821 <a name="l00831"></a><a class="code" href="packedmatrix_8h.html#a3c42404eadf254e714cd9af7f3dd25e9">00831</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="packedmatrix_8h.html#a3c42404eadf254e714cd9af7f3dd25e9" title="Clear n bits in M starting a position (x,y).">mzd_clear_bits</a>(<span class="keyword">const</span> <a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> x, <span class="keyword">const</span> <span class="keywordtype">size_t</span> y, <span class="keyword">const</span> <span class="keywordtype">int</span> n) { <a name="l00832"></a>00832 <a class="code" href="misc_8h.html#aa975e5cf9a68e2ddca2085ee1fb57edb">word</a> temp; <a name="l00833"></a>00833 <a name="l00834"></a>00834 <span class="comment">/* there are two possible situations. Either all bits are in one</span> <a name="l00835"></a>00835 <span class="comment"> * word or they are spread across two words. */</span> <a name="l00836"></a>00836 <a name="l00837"></a>00837 <span class="keywordflow">if</span> ( ((y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> + n - 1) < <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a> ) { <a name="l00838"></a>00838 <span class="comment">/* everything happens in one word here */</span> <a name="l00839"></a>00839 temp = M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][(y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>]; <a name="l00840"></a>00840 temp <<= (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* clear upper bits */</span> <a name="l00841"></a>00841 temp >>= <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-n; <span class="comment">/* clear lower bits and move to correct position.*/</span> <a name="l00842"></a>00842 temp <<= <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-n - (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>)%<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <a name="l00843"></a>00843 M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][(y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>] ^= temp; <a name="l00844"></a>00844 } <span class="keywordflow">else</span> { <a name="l00845"></a>00845 <span class="comment">/* two words are affected */</span> <a name="l00846"></a>00846 <span class="keyword">const</span> <span class="keywordtype">size_t</span> block = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>) / <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct block */</span> <a name="l00847"></a>00847 <span class="keyword">const</span> <span class="keywordtype">size_t</span> spot = (y+M-><a class="code" href="structmzd__t.html#a2b45c396b8c3bc5c586a9327931a0431">offset</a>+n) % <a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>; <span class="comment">/* correct offset */</span> <a name="l00848"></a>00848 M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block] ^= M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block] & ((<a class="code" href="misc_8h.html#a206b6f5362e56b51ca957635350b70b6" title="The number one as a word.">ONE</a><<(n-spot))-1); <a name="l00849"></a>00849 M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block+1] ^= (M-><a class="code" href="structmzd__t.html#ae809b9c25df0752caabe8233209dd447">rows</a>[x][block+1]>>(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-spot))<<(<a class="code" href="misc_8h.html#a534ad31d9e306202c071ae3c21eaf50a" title="The number of bits in a word.">RADIX</a>-spot); <a name="l00850"></a>00850 } <a name="l00851"></a>00851 } <a name="l00852"></a>00852 <a name="l00859"></a>00859 <span class="keywordtype">int</span> mzd_is_zero(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A); <a name="l00860"></a>00860 <a name="l00869"></a>00869 <span class="keywordtype">void</span> mzd_row_clear_offset(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keyword">const</span> <span class="keywordtype">size_t</span> row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> coloffset); <a name="l00870"></a>00870 <a name="l00887"></a>00887 <span class="keywordtype">int</span> mzd_find_pivot(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *M, <span class="keywordtype">size_t</span> start_row, <span class="keywordtype">size_t</span> start_col, <span class="keywordtype">size_t</span> *r, <span class="keywordtype">size_t</span> *c); <a name="l00888"></a>00888 <a name="l00889"></a>00889 <a name="l00902"></a>00902 <span class="keywordtype">double</span> mzd_density(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keywordtype">int</span> res); <a name="l00903"></a>00903 <a name="l00918"></a>00918 <span class="keywordtype">double</span> _mzd_density(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A, <span class="keywordtype">int</span> res, <span class="keywordtype">size_t</span> r, <span class="keywordtype">size_t</span> c); <a name="l00919"></a>00919 <a name="l00920"></a>00920 <a name="l00929"></a>00929 <span class="keywordtype">size_t</span> mzd_first_zero_row(<a class="code" href="structmzd__t.html" title="Dense matrices over GF(2).">mzd_t</a> *A); <a name="l00930"></a>00930 <a name="l00931"></a>00931 <span class="preprocessor">#endif //PACKEDMATRIX_H</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Sat Apr 23 2011 for M4RI by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>