My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends
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
 
Toperator[] (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.

231: r_min(rmin), r_max(rmax), c_min(cmin), c_max(cmax), M((Matrix<T>&)m) {}
int m
Definition: cfEzgcd.cc:128
Matrix< T > & M
Definition: ftmpl_matrix.h:75

◆ SubMatrix() [2/2]

template<class T >
SubMatrix< T >::SubMatrix ( const SubMatrix< T > &  S)

Definition at line 234 of file ftmpl_matrix.cc.

234: r_min(S.r_min), r_max(S.r_max), c_min(S.c_min), c_max(S.c_max), M(S.M) {}

Member Function Documentation

◆ operator Matrix< T >()

template<class T >
SubMatrix< T >::operator Matrix< T >

Definition at line 287 of file ftmpl_matrix.cc.

288{
289 Matrix<T> res( r_max - r_min + 1, c_max - c_min + 1 );
290 int i, 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];
295 return res;
296}
int i
Definition: cfEzgcd.cc:132
CanonicalForm res
Definition: facAbsFact.cc:60
int j
Definition: facHensel.cc:110

◆ operator=() [1/2]

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

Definition at line 237 of file ftmpl_matrix.cc.

238{
239 ASSERT( r_max - r_min + 1 == S.NR && c_max - c_min + 1 == S.NC, "incompatible matrices" );
240 if ( M.elems != S.elems ) {
241 int i, j;
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];
245 }
246 return *this;
247}
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int NR
Definition: ftmpl_matrix.h:31
T ** elems
Definition: ftmpl_matrix.h:32
int NC
Definition: ftmpl_matrix.h:31

◆ operator=() [2/2]

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

Definition at line 250 of file ftmpl_matrix.cc.

251{
252 ASSERT( r_max - r_min == S.r_max - S.r_min && c_max - c_min == S.c_max - S.c_min, "incompatible matrices" );
253 int i, j, n, m;
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++ )
260 M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
261 }
262 else if ( r_min > S.r_min ) {
263 for ( i = n-1; i >= 0; i-- )
264 for ( j = 0; j < m; j++ )
265 M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
266 }
267 else if ( c_min < S.c_min ) {
268 for ( j = 0; j < m; j++ )
269 for ( i = 0; i < n; i++ )
270 M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
271 }
272 else if ( c_min > S.c_min ) {
273 for ( j = m-1; j >= 0; j-- )
274 for ( i = 0; i < n; i++ )
275 M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
276 }
277 }
278 else {
279 for ( i = 0; i < n; i++ )
280 for ( j = 0; j < m; j++ )
281 M.elems[r_min+i-1][c_min+j-1] = S.M.elems[S.r_min+i-1][S.c_min+j-1];
282 }
283 return *this;
284}

◆ operator[]() [1/2]

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

Definition at line 306 of file ftmpl_matrix.cc.

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

◆ operator[]() [2/2]

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

Definition at line 299 of file ftmpl_matrix.cc.

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

Friends And Related Function 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: