Loading...
Searching...
No Matches
SubMatrix< T > Class Template Reference

`#include <ftmpl_matrix.h>`

## Public Member Functions

| SubMatrix (const SubMatrix< T > &S)
SubMatrix< T > & | operator= (const SubMatrix< T > &S)
SubMatrix< T > & | operator= (const Matrix< T > &S)
| operator Matrix< T > () const
T | operator[] (int i) const
T & | operator[] (int i)

## Private Member Functions

| SubMatrix (int rmin, int rmax, int cmin, int cmax, const Matrix< T > &m)

## Private Attributes

int | r_min
int | r_max
int | c_min
int | c_max
Matrix< T > & | M

## Friends

class | Matrix< T >

## Detailed Description

template<class T>
class SubMatrix< T >

Definition at line 71 of file ftmpl_matrix.h.

## Constructor & Destructor Documentation

## SubMatrix() [1/2]

template<class T>

SubMatrix< T >::SubMatrix | ( | int | rmin,
|  | int | rmax,
|  | int | cmin,
|  | int | cmax,
|  | const Matrix< T > & | m )

private

Definition at line 231 of file ftmpl_matrix.cc.

: r_min(rmin), r_max(rmax), c_min(cmin), c_max(cmax), M((Matrix<T>&)m) {}
SubMatrix
Definition ftmpl_matrix.h:72
SubMatrix::r_max
int r_max
Definition ftmpl_matrix.h:74
SubMatrix::c_min
int c_min
Definition ftmpl_matrix.h:74
SubMatrix::c_max
int c_max
Definition ftmpl_matrix.h:74
SubMatrix::r_min
int r_min
Definition ftmpl_matrix.h:74
M
#define M
Definition sirandom.c:25

## SubMatrix() [2/2]

template<class T>

SubMatrix< T >::SubMatrix | ( | const SubMatrix< T > & | S | ) |

Definition at line 234 of file ftmpl_matrix.cc.

: r_min(S.r_min), r_max(S.r_max), c_min(S.c_min), c_max(S.c_max), M(S.M) {}
SubMatrix::M
Matrix< T > & M
Definition ftmpl_matrix.h:75

## Member Function Documentation

## operator Matrix< T >()

template<class T>

SubMatrix< T >::operator Matrix< T > | ( |  | ) | const

Definition at line 287 of file ftmpl_matrix.cc.

{
Matrix<T> res( r_max - r_min + 1, c_max - c_min + 1 );
int i, j;
int n = r_max - r_min + 1, m = c_max - c_min + 1;
for ( i = 0; i < n; i++ )
for ( j = 0; j < m; j++ )
res.elems[i][j] = M.elems[r_min+i-1][c_min+j-1];
return res;
}
res
CanonicalForm res
Definition facAbsFact.cc:60

## operator=() [1/2]

template<class T>

SubMatrix< T > & SubMatrix< T >::operator= | ( | const Matrix< T > & | S | ) |

Definition at line 237 of file ftmpl_matrix.cc.

{
ASSERT( r_max - r_min + 1 == S.NR && c_max - c_min + 1 == S.NC, "incompatible matrices" );
if ( M.elems != S.elems ) {
int i, j;
for ( i = 0; i < S.NR; i++ )
for ( j = 0; j < S.NC; j++ )
M.elems[r_min+i-1][c_min+j-1] = S.elems[i][j];
}
return *this;
}
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99

## operator=() [2/2]

template<class T>

SubMatrix< T > & SubMatrix< T >::operator= | ( | const SubMatrix< T > & | S | ) |

Definition at line 250 of file ftmpl_matrix.cc.

{
ASSERT( r_max - r_min == S.r_max - S.r_min && c_max - c_min == S.c_max - S.c_min, "incompatible matrices" );
int i, j, n, m;
n = r_max - r_min + 1;
m = c_max - c_min + 1;
if ( M.elems == S.M.elems ) {
if ( r_min < S.r_min ) {
for ( i = 0; i < n; i++ )
for ( j = 0; j < m; j++ )
M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
}
else if ( r_min > S.r_min ) {
for ( i = n-1; i >= 0; i-- )
for ( j = 0; j < m; j++ )
M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
}
else if ( c_min < S.c_min ) {
for ( j = 0; j < m; j++ )
for ( i = 0; i < n; i++ )
M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
}
else if ( c_min > S.c_min ) {
for ( j = m-1; j >= 0; j-- )
for ( i = 0; i < n; i++ )
M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
}
}
else {
for ( i = 0; i < n; i++ )
for ( j = 0; j < m; j++ )
M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
}
return *this;
}

## operator[]() [1/2]

template<class T>

T & SubMatrix< T >::operator[] | ( | int | i | ) |

Definition at line 306 of file ftmpl_matrix.cc.

{
ASSERT( r_min == r_max && i >= c_min && i <= c_max, "illegal index" );
return M.elems[r_min-1][i-1];
}

## operator[]() [2/2]

template<class T>

T SubMatrix< T >::operator[] | ( | int | i | ) | const

Definition at line 299 of file ftmpl_matrix.cc.

{
ASSERT( r_min == r_max && i >= c_min && i <= c_max, "illegal index" );
return M.elems[r_min-1][i-1];
}

## Friends And Related Symbol Documentation

## Matrix< T >

template<class T>

friend class Matrix< T >

friend

Definition at line 84 of file ftmpl_matrix.h.

## Field Documentation

## c_max

template<class T>

int SubMatrix< T >::c_max

private

Definition at line 74 of file ftmpl_matrix.h.

## c_min

template<class T>

int SubMatrix< T >::c_min

private

Definition at line 74 of file ftmpl_matrix.h.

## M

template<class T>

Matrix<T>& SubMatrix< T >::M

private

Definition at line 75 of file ftmpl_matrix.h.

## r_max

template<class T>

int SubMatrix< T >::r_max

private

Definition at line 74 of file ftmpl_matrix.h.

## r_min

template<class T>

int SubMatrix< T >::r_min

private

Definition at line 74 of file ftmpl_matrix.h.

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

- factory/include/factory/templates/ftmpl_matrix.h
- factory/templates/ftmpl_matrix.cc