/usr/share/doc/libntl-dev/NTL/matrix.cpp.html is in libntl-dev 9.9.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>/Volumes/unix-files/u/ntl-new/ntl-9.9.0dev/doc/matrix.cpp.html</title>
<meta name="Generator" content="Vim/7.1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i>MODULE: matrix</i></font><br>
<br>
<font color="#0000ed"><i>SUMMARY:</i></font><br>
<br>
<font color="#0000ed"><i>Matrix templates.</i></font><br>
<br>
<font color="#0000ed"><i>The declaration </i></font><br>
<br>
<font color="#0000ed"><i> Mat<T> M;</i></font><br>
<br>
<font color="#0000ed"><i>creates a 0 x 0 matrix. </i></font><br>
<br>
<font color="#0000ed"><i>We can make it have 10 rows and 20 columns like this:</i></font><br>
<br>
<font color="#0000ed"><i> M.SetDims(10, 20);</i></font><br>
<br>
<font color="#0000ed"><i>A row can be accessed as M[i], indexing from 0, or as M(i), indexing from 1.</i></font><br>
<font color="#0000ed"><i>A matrix entry can be accessed as M[i][j], indexing from 0, or as</i></font><br>
<font color="#0000ed"><i>M(i, j), indexing from 1.</i></font><br>
<br>
<font color="#0000ed"><i>A matrix is represented as a Vec< Vec<T> >: a vector of rows, where</i></font><br>
<font color="#0000ed"><i>each row is a Vec<T>. Any attempt to resize one of the rows so</i></font><br>
<font color="#0000ed"><i>as to create a non-rectangular matrix will result in a run-time </i></font><br>
<font color="#0000ed"><i>error.</i></font><br>
<br>
<font color="#0000ed"><i>The dimensions of an existing matrix may be changed. If the number of</i></font><br>
<font color="#0000ed"><i>columns does not change, then the matrix is just "resized" like a vector,</i></font><br>
<font color="#0000ed"><i>and no information is lost. Otherwise, if the number of columns changes,</i></font><br>
<font color="#0000ed"><i>the matrix is completely destroyed, and a new matrix is created</i></font><br>
<br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: all functions below do not throw any exceptions,</i></font><br>
<font color="#0000ed"><i>// except as noted</i></font><br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
<font color="#008b00"><b>class</b></font> Mat {<br>
<br>
<font color="#008b00"><b>typedef</b></font> <font color="#008b00"><b>typename</b></font> Vec<T>::value_type value_type;<br>
<font color="#008b00"><b>typedef</b></font> <font color="#008b00"><b>typename</b></font> Vec<T>::reference reference;<br>
<font color="#008b00"><b>typedef</b></font> <font color="#008b00"><b>typename</b></font> Vec<T>::const_reference const_reference;<br>
<br>
<br>
Mat(); <font color="#0000ed"><i>// initially 0 x 0</i></font><br>
<br>
Mat(<font color="#008b00"><b>const</b></font> Mat<T>& a);<br>
<font color="#0000ed"><i>// copy constructor</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw</i></font><br>
<br>
<br>
Mat& <font color="#b02f60"><b>operator</b></font>=(<font color="#008b00"><b>const</b></font> Mat<T>& a);<br>
<font color="#0000ed"><i>// assignment</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw, weak ES (but dimensions of LHS</i></font><br>
<font color="#0000ed"><i>// will be either that of old LHS or RHS)</i></font><br>
<br>
~Mat();<br>
<font color="#0000ed"><i>// destructor</i></font><br>
<br>
Mat(INIT_SIZE_TYPE, <font color="#008b00"><b>long</b></font> n, <font color="#008b00"><b>long</b></font> m); <br>
<font color="#0000ed"><i>// Mat(INIT_SIZE, n, m) initializes an n x m matrix, invoking</i></font><br>
<font color="#0000ed"><i>// the default constructor for T to initialize entries.</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> SetDims(<font color="#008b00"><b>long</b></font> n, <font color="#008b00"><b>long</b></font> m); <br>
<font color="#0000ed"><i>// M.SetDims(n, m) makes M have dimension n x m. If the number of</i></font><br>
<font color="#0000ed"><i>// columns (m) changes, previous storage is freed, and space for M</i></font><br>
<font color="#0000ed"><i>// is reallocated and initialized; otherwise, more rows are</i></font><br>
<font color="#0000ed"><i>// allocated as necessary (when number of rows increases), </i></font><br>
<font color="#0000ed"><i>// excess rows are retained (when number of rows decreases),</i></font><br>
<font color="#0000ed"><i>// and--importantly--the contents do not change.</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: strong ES (although underlying vector representation</i></font><br>
<font color="#0000ed"><i>// may be reallocated)</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> kill(); free storage <font color="#b02f60"><b>and</b></font> make <font color="#ff8b00">0</font> x <font color="#ff8b00">0</font><br>
<br>
<font color="#008b00"><b>long</b></font> NumRows() <font color="#008b00"><b>const</b></font>;<br>
<font color="#0000ed"><i>// M.NumRows() returns the number of rows of M</i></font><br>
<br>
<font color="#008b00"><b>long</b></font> NumCols() <font color="#008b00"><b>const</b></font>;<br>
<font color="#0000ed"><i>// M.NumCols() returns the number of columns of M</i></font><br>
<br>
Vec<T>& <font color="#b02f60"><b>operator</b></font>[](<font color="#008b00"><b>long</b></font> i);<br>
<font color="#008b00"><b>const</b></font> Vec<T>& <font color="#b02f60"><b>operator</b></font>[](<font color="#008b00"><b>long</b></font> i) <font color="#008b00"><b>const</b></font>;<br>
<font color="#0000ed"><i>// access row i, initial index 0. </i></font><br>
<font color="#0000ed"><i>// Even if one has read/write access to a row, any attempt</i></font><br>
<font color="#0000ed"><i>// to change its length will raise an error.</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw if range checking is turned on</i></font><br>
<br>
Vec<T>& <font color="#b02f60"><b>operator</b></font>()(<font color="#008b00"><b>long</b></font> i);<br>
<font color="#008b00"><b>const</b></font> Vec<T>& <font color="#b02f60"><b>operator</b></font>()(<font color="#008b00"><b>long</b></font> i) <font color="#008b00"><b>const</b></font>;<br>
<font color="#0000ed"><i>// access row i, initial index 1. </i></font><br>
<font color="#0000ed"><i>// Even if one has read/write access to a row, any attempt</i></font><br>
<font color="#0000ed"><i>// to change its length will raise an error.</i></font><br>
<font color="#0000ed"><i>// of this row will raise an error.</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw if range checking is turned on</i></font><br>
<br>
reference <font color="#b02f60"><b>operator</b></font>()(<font color="#008b00"><b>long</b></font> i, <font color="#008b00"><b>long</b></font> j);<br>
const_reference <font color="#b02f60"><b>operator</b></font>()(<font color="#008b00"><b>long</b></font> i, <font color="#008b00"><b>long</b></font> j) <font color="#008b00"><b>const</b></font>; <br>
<font color="#0000ed"><i>// access element (i, j), both indices starting at 1</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw if range checking is turned on</i></font><br>
<br>
const_reference get(<font color="#008b00"><b>long</b></font> i, <font color="#008b00"><b>long</b></font> j) <font color="#008b00"><b>const</b></font>;<br>
<font color="#0000ed"><i>// access element (i, j), both indices starting at 0</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw if range checking is turned on</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> put(<font color="#008b00"><b>long</b></font> i, <font color="#008b00"><b>long</b></font> j, <font color="#008b00"><b>const</b></font> T& a);<br>
<font color="#0000ed"><i>// same as M[i].put(j, a)</i></font><br>
<br>
<font color="#008b00"><b>template</b></font> <<font color="#008b00"><b>class</b></font> U><br>
<font color="#008b00"><b>void</b></font> put(<font color="#008b00"><b>long</b></font> i, <font color="#008b00"><b>long</b></font> j, <font color="#008b00"><b>const</b></font> U& a);<br>
<font color="#0000ed"><i>// same as M[i].put(j, a)</i></font><br>
<br>
<font color="#008b00"><b>long</b></font> position(<font color="#008b00"><b>const</b></font> Vec<T>& a) <font color="#008b00"><b>const</b></font>;<br>
<font color="#0000ed"><i>// returns index of a in matrix, or -1 if not present;</i></font><br>
<font color="#0000ed"><i>// equivalent to rep(*this).position(a).</i></font><br>
<br>
<font color="#008b00"><b>long</b></font> position1(<font color="#008b00"><b>const</b></font> Vec<T>& a) <font color="#008b00"><b>const</b></font>;<br>
<font color="#0000ed"><i>// returns index of a in matrix, or -1 if not present;</i></font><br>
<font color="#0000ed"><i>// equivalent to rep(*this).position1(a).</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> swap(Mat<T>& other);<br>
<font color="#0000ed"><i>// quick swap *this and other</i></font><br>
<br>
};<br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
<font color="#008b00"><b>const</b></font> Vec< Vec<T> >& rep(<font color="#008b00"><b>const</b></font> Mat<T>& a);<br>
<font color="#0000ed"><i>// read-only access to underlying representation</i></font><br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
<font color="#008b00"><b>void</b></font> swap(Mat<T>& X, Mat<T>& Y);<br>
<font color="#0000ed"><i>// quick swap of X and Y </i></font><br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
<font color="#008b00"><b>void</b></font> MakeMatrix(Mat<T>& x, <font color="#008b00"><b>const</b></font> vec_vec_T& a);<br>
<font color="#0000ed"><i>// copies a to x, checking that it is "rectangular"</i></font><br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may thow, weak ES (but dimensions of x either</i></font><br>
<font color="#0000ed"><i>// remain unchanged or are set to the new dimensions implied by a)</i></font><br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Input/Output</i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
istream& <font color="#b02f60"><b>operator</b></font>>>(istream&, Mat<T>&);<br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw, weak ES</i></font><br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
ostream& <font color="#b02f60"><b>operator</b></font><<(ostream&, <font color="#008b00"><b>const</b></font> Mat<T>&); <br>
<br>
<font color="#0000ed"><i>// EXCEPTIONS: may throw, weak ES</i></font><br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Equality Testing</i></font><br>
<br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
<font color="#008b00"><b>long</b></font> <font color="#b02f60"><b>operator</b></font>==(<font color="#008b00"><b>const</b></font> Mat<T>& a, <font color="#008b00"><b>const</b></font> Mat<T>& b);<br>
<br>
<font color="#008b00"><b>template</b></font><<font color="#008b00"><b>class</b></font> T><br>
<font color="#008b00"><b>long</b></font> <font color="#b02f60"><b>operator</b></font>!=(<font color="#008b00"><b>const</b></font> Mat<T>& a, <font color="#008b00"><b>const</b></font> Mat<T>& b);<br>
<br>
</font></body>
</html>
|