8 ASSERT( (nr > 0 && nc > 0) || (nr == 0 && nc == 0),
"illegal index" );
14 for (
i = 0;
i < nr;
i++ )
27 for (
i = 0;
i <
NR;
i++ ) {
29 for (
j = 0;
j <
NC;
j++ )
40 for (
i = 0;
i < NR;
i++ )
51 if ( NR !=
M.NR || NC !=
M.NC ) {
52 for (
i = 0;
i < NR;
i++ )
56 elems =
new T_ptr[NR];
57 for (
i = 0;
i < NR;
i++ )
60 for (
i = 0;
i < NR;
i++ )
61 for (
j = 0;
j < NC;
j++ )
62 elems[
i][
j] =
M.elems[
i][
j];
70 ASSERT(
i > 0 &&
i <= NR,
"illegal index" );
77 ASSERT(
i > 0 &&
i <= NR,
"illegal index" );
84 ASSERT( row > 0 && col > 0 && row <= NR && col <= NC,
"illegal index" );
85 return elems[row-1][col-1];
91 ASSERT( row > 0 && col > 0 && row <= NR && col <= NC,
"illegal index" );
92 return elems[row-1][col-1];
98 ASSERT( rmin > 0 && rmax <= NR && rmin <= rmax && cmin > 0 && cmax <= NC && cmin <= cmax ,
"illegal index" );
105 ASSERT( rmin > 0 && rmax <= NR && rmin <= rmax && cmin > 0 && cmax <= NC && cmin <= cmax ,
"illegal index" );
112 ASSERT(
i > 0 && i <= NR && j > 0 &&
j <= NR,
"illegal index" );
124 ASSERT(
i > 0 && i <= NC && j > 0 &&
j <= NC,
"illegal index" );
128 for (
k = 0;
k < NR;
k++ ) {
130 elems[
k][
i] = elems[
k][
j];
140 s <<
"( " << elems[
i][0];
141 for (
int j = 1;
j < NC;
j++ )
142 s <<
", " << elems[
i][
j];
151 else if ( NR == 1 ) {
160 for (
i = 1;
i < NR;
i++ ) {
239 ASSERT( r_max - r_min + 1 == S.
NR && c_max - c_min + 1 == S.
NC,
"incompatible matrices" );
240 if (
M.elems != S.
elems ) {
242 for (
i = 0;
i < S.
NR;
i++ )
243 for (
j = 0;
j < S.
NC;
j++ )
244 M.elems[r_min+
i-1][c_min+
j-1] = S.
elems[
i][
j];
254 n = r_max - r_min + 1;
255 m = c_max - c_min + 1;
256 if (
M.elems == S.
M.elems ) {
257 if ( r_min < S.
r_min ) {
258 for (
i = 0;
i < n;
i++ )
259 for (
j = 0;
j <
m;
j++ )
262 else if ( r_min > S.
r_min ) {
263 for (
i = n-1;
i >= 0;
i-- )
264 for (
j = 0;
j <
m;
j++ )
267 else if ( c_min < S.
c_min ) {
268 for (
j = 0;
j <
m;
j++ )
269 for (
i = 0;
i < n;
i++ )
272 else if ( c_min > S.
c_min ) {
273 for (
j =
m-1;
j >= 0;
j-- )
274 for (
i = 0;
i < n;
i++ )
279 for (
i = 0;
i < n;
i++ )
280 for (
j = 0;
j <
m;
j++ )
291 int n = r_max - r_min + 1,
m = c_max - c_min + 1;
292 for (
i = 0;
i < n;
i++ )
293 for (
j = 0;
j <
m;
j++ )
294 res.elems[
i][
j] =
M.elems[r_min+
i-1][c_min+
j-1];
301 ASSERT( r_min == r_max &&
i >= c_min &&
i <= c_max,
"illegal index" );
302 return M.elems[r_min-1][
i-1];
308 ASSERT( r_min == r_max &&
i >= c_min &&
i <= c_max,
"illegal index" );
309 return M.elems[r_min-1][
i-1];
#define ASSERT(expression, message)
void swapRow(int i, int j)
void print(OSTREAM &s) const
void swapColumn(int i, int j)
Matrix< T > & operator=(const Matrix< T > &M)
void printrow(OSTREAM &s, int i) const
SubMatrix< T > operator[](int i)
T & operator()(int row, int col)
SubMatrix(int rmin, int rmax, int cmin, int cmax, const Matrix< T > &m)
T operator[](int i) const
SubMatrix< T > & operator=(const SubMatrix< T > &S)
const CanonicalForm int s
OSTREAM & operator<<(OSTREAM &s, const Matrix< T > &M)