C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
intmatrix.inl
1 /*
2 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3 **
4 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5 ** Universitaet Karlsruhe, Germany
6 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7 ** Universitaet Wuppertal, Germany
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Library General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Library General Public License for more details.
18 **
19 ** You should have received a copy of the GNU Library General Public
20 ** License along with this library; if not, write to the Free
21 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23 
24 /* CVS $Id: intmatrix.inl,v 1.19 2014/01/30 17:23:45 cxsc Exp $ */
25 
26 #ifndef _CXSC_INTMATRIX_INL_INCLUDED
27 #define _CXSC_INTMATRIX_INL_INCLUDED
28 
29 namespace cxsc {
30 
31 INLINE intmatrix::intmatrix() throw():dat(NULL),lb1(1),ub1(0),lb2(1),ub2(0),xsize(0),ysize(0)
32 {
33 }
34 
35 INLINE intmatrix::intmatrix(const int &r) throw():lb1(1),ub1(1),lb2(1),ub2(1),xsize(1),ysize(1)
36 {
37  dat=new int[1];
38  *dat=r;
39 }
40 
41 INLINE intmatrix::intmatrix(const intmatrix &rm) throw():lb1(rm.lb1),ub1(rm.ub1),lb2(rm.lb2),ub2(rm.ub2),xsize(rm.xsize),ysize(rm.ysize)
42 {
43  dat=new int[xsize*ysize];
44  for(int i=0;i<xsize*ysize;i++)
45  dat[i]=rm.dat[i];
46 }
47 
48 INLINE intmatrix::intmatrix(const int &m, const int &n)
49 #if(CXSC_INDEX_CHECK)
50  throw(ERROR_INTMATRIX_WRONG_BOUNDARIES):lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
51 #else
52  throw():lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
53 #endif
54 {
55 #if(CXSC_INDEX_CHECK)
56  if((n<0)||(m<0)) cxscthrow(ERROR_INTMATRIX_WRONG_BOUNDARIES("intmatrix::intmatrix(const int &m, const int &n)"));
57 #endif
58  dat=new int[m*n];
59 }
60 
61 INLINE intmatrix::intmatrix(const int &m1, const int &m2, const int &n1, const int &n2)
62 #if(CXSC_INDEX_CHECK)
63  throw(ERROR_INTMATRIX_WRONG_BOUNDARIES):lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
64 #else
65  throw():lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
66 #endif
67 {
68 #if(CXSC_INDEX_CHECK)
69  if((m2<m1)||(n2<n1)) cxscthrow(ERROR_INTMATRIX_WRONG_BOUNDARIES("intmatrix::intmatrix(const int &m1, const int &n1, const int &m2, const int &n2)"));
70 #endif
71  dat=new int[xsize*ysize];
72 }
73 
74 INLINE intvector::intvector(const intmatrix_subv &v) throw():l(v.lb),u(v.ub),size(v.size)
75 {
76  dat=new int[size];
77  for (int i=0, j=v.start;i<v.size;i++,j+=v.offset)
78  dat[i]=v.dat[j];
79 }
80 
81 INLINE intmatrix::intmatrix(const intvector &v) throw():lb1(v.l),ub1(v.u),lb2(1),ub2(1),xsize(1),ysize(v.size)
82 {
83  dat=new int[v.size];
84  for(int i=0;i<v.size;i++)
85  dat[i]=v.dat[i];
86 }
87 
88 INLINE intmatrix::intmatrix(const intvector_slice &v) throw():lb1(v.start),ub1(v.end),lb2(1),ub2(1),xsize(1),ysize(v.size)
89 {
90  dat=new int[v.size];
91  for(int i=0,j=v.start-v.l;i<v.size;i++,j++)
92  dat[i]=v.dat[j];
93 }
94 
95  INLINE int &intmatrix_subv::operator [](const int &i) const
96 #if(CXSC_INDEX_CHECK)
97  throw(ERROR_INTVECTOR_ELEMENT_NOT_IN_VEC)
98 #else
99  throw()
100 #endif
101  {
102 #if(CXSC_INDEX_CHECK)
103  if((i<lb)||(i>ub)) cxscthrow(ERROR_INTVECTOR_ELEMENT_NOT_IN_VEC("int &intmatrix_subv::operator [](const int &i)"));
104 #endif
105  return dat[start+((i-lb)*offset)];
106  }
107 
108  INLINE intmatrix::intmatrix(const intmatrix_slice &sl) throw():lb1(sl.start1),ub1(sl.end1),lb2(sl.start2),ub2(sl.end2),xsize(sl.sxsize),ysize(sl.sysize)
109  {
110  int i,j;
111 
112  dat=new int[xsize*ysize];
113  for (i=0;i<ysize;i++)
114  {
115  for(j=0;j<xsize;j++)
116  {
117  dat[i*xsize+j]=sl.dat[(sl.offset1+i)*sl.mxsize+sl.offset2+j];
118  }
119  }
120  }
121 
122  INLINE intmatrix_subv Row(intmatrix &m,const int &i)
123 #if(CXSC_INDEX_CHECK)
124  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
125 #else
126  throw()
127 #endif
128 
129  {
130  return m[i];
131  }
132 
133  INLINE intmatrix_subv Col(intmatrix &m,const int &i)
134 #if(CXSC_INDEX_CHECK)
135  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
136 #else
137  throw()
138 #endif
139 
140  {
141  return m[Col(i)];
142  }
143 
144  INLINE intmatrix_subv Row(const intmatrix &m,const int &i)
145 #if(CXSC_INDEX_CHECK)
146  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
147 #else
148  throw()
149 #endif
150 
151  {
152  return m[i];
153  }
154 
155  INLINE intmatrix_subv Col(const intmatrix &m,const int &i)
156 #if(CXSC_INDEX_CHECK)
157  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
158 #else
159  throw()
160 #endif
161 
162  {
163  return m[Col(i)];
164  }
165 
166  INLINE intmatrix_subv intmatrix::operator [](const int &i) const
167 #if(CXSC_INDEX_CHECK)
168  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
169 #else
170  throw()
171 #endif
172  {
173 #if(CXSC_INDEX_CHECK)
174  if((i<lb1)||(i>ub1)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix::operator [](const int &i)"));
175 #endif
176  return intmatrix_subv(dat, lb2, ub2, xsize, xsize*(i-lb1),1);
177  }
178 
179  INLINE intmatrix_subv intmatrix::operator [](const cxscmatrix_column &i) const
180 #if(CXSC_INDEX_CHECK)
181  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
182 #else
183  throw()
184 #endif
185  {
186 #if(CXSC_INDEX_CHECK)
187  if((i.col()<lb2)||(i.col()>ub2)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix::operator [](const cxscmatrix_column &i)"));
188 #endif
189  return intmatrix_subv(dat, lb1, ub1, ysize, i.col()-lb2, xsize);
190  }
191 
192  INLINE intmatrix_slice intmatrix::operator ()(const int &m, const int &n)
193 #if(CXSC_INDEX_CHECK)
194  throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
195 #else
196  throw()
197 #endif
198  {
199 #if(CXSC_INDEX_CHECK)
200  if((m<1)||(n<1)||(m<lb1)||(n<lb2)||(m>ub1)||(n>ub2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix::operator ()(const int &m, const int &n)"));
201 #endif
202  return intmatrix_slice(*this,1,m,1,n);
203  }
204 
205  INLINE intmatrix_slice intmatrix::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)
206 #if(CXSC_INDEX_CHECK)
207  throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
208 #else
209  throw()
210 #endif
211  {
212 #if(CXSC_INDEX_CHECK)
213  if((m1<lb1)||(n1<lb2)||(m2>ub1)||(n2>ub2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix::operator ()(const int &m1, const int &n1, const int &m2, const int &n2)"));
214 #endif
215  return intmatrix_slice(*this,m1,m2,n1,n2);
216  }
217 
219 #if(CXSC_INDEX_CHECK)
220  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
221 #else
222  throw()
223 #endif
224  {
225 #if(CXSC_INDEX_CHECK)
226  if((i<start1)||(i>end1)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix_slice::operator [](const int &i)"));
227 #endif
228  return intmatrix_subv(dat, start2, end2, sxsize, mxsize*(i-start1+offset1)+offset2,1);
229  }
230 
231  INLINE intmatrix_subv intmatrix_slice::operator [](const cxscmatrix_column &i)
232 #if(CXSC_INDEX_CHECK)
233  throw(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT)
234 #else
235  throw()
236 #endif
237  {
238 #if(CXSC_INDEX_CHECK)
239  if((i.col()<start2)||(i.col()>end2)) cxscthrow(ERROR_INTMATRIX_ROW_OR_COL_NOT_IN_MAT("intmatrix_subv intmatrix_slice::operator [](const cxscmatrix_column &i)"));
240 #endif
241  return intmatrix_subv(dat, start1, end1, sysize, offset1*mxsize+i.col()-start2+offset2, mxsize);
242  }
243 
244  INLINE intmatrix_slice intmatrix_slice::operator ()(const int &m, const int &n)
245 #if(CXSC_INDEX_CHECK)
246  throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
247 #else
248  throw()
249 #endif
250  {
251 #if(CXSC_INDEX_CHECK)
252  if((m<1)||(n<1)||(m<start1)||(n<start2)||(m>end1)||(n>end2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix_slice::operator ()(const int &m, const int &n)"));
253 #endif
254  return intmatrix_slice(*this,1,m,1,n);
255  }
256 
257  INLINE intmatrix_slice intmatrix_slice::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)
258 #if(CXSC_INDEX_CHECK)
259  throw(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG)
260 #else
261  throw()
262 #endif
263  {
264 #if(CXSC_INDEX_CHECK)
265  if((m1<start1)||(n1<start2)||(m2>end1)||(n2>end2)) cxscthrow(ERROR_INTMATRIX_SUB_ARRAY_TOO_BIG("intmatrix_slice intmatrix_slice::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)"));
266 #endif
267  return intmatrix_slice(*this,m1,m2,n1,n2);
268  }
269 
271 #if(CXSC_INDEX_CHECK)
272  throw(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG)
273 #else
274  throw()
275 #endif
276 {
277 #if(CXSC_INDEX_CHECK)
278  if(1<lb||i>ub) cxscthrow(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG("intmatrix_subv intmatrix_subv::operator ()(const int &i)"));
279 #endif
280  return intmatrix_subv(dat,1,i,i,start+(1-lb)*offset,offset);
281 }
282 
283 INLINE intmatrix_subv intmatrix_subv::operator ()(const int &i1,const int &i2)
284 #if(CXSC_INDEX_CHECK)
285  throw(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG)
286 #else
287  throw()
288 #endif
289 {
290 #if(CXSC_INDEX_CHECK)
291  if(i1<lb||i2>ub) cxscthrow(ERROR_INTVECTOR_SUB_ARRAY_TOO_BIG("intmatrix_subv intmatrix_subv::operator ()(const int &i1,const int &i2)"));
292 #endif
293  return intmatrix_subv(dat,i1,i2,i2-i1+1,start+(i1-lb)*offset,offset);
294 }
295 
296  INLINE intmatrix_subv &intmatrix_subv::operator =(const intmatrix_subv &rv) throw() { return _mvmvassign(*this,rv); }
297  INLINE intmatrix_subv &intmatrix_subv::operator =(const int &r) throw() { return _mvsassign(*this,r); }
299 #if(CXSC_INDEX_CHECK)
300  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
301 #else
302  throw()
303 #endif
304  { return _mvvassign(*this,v); }
306 #if(CXSC_INDEX_CHECK)
307  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
308 #else
309  throw()
310 #endif
311  { return _mvvassign(*this,intvector(v)); }
312  INLINE intmatrix &intmatrix::operator =(const int &r) throw() { return _msassign(*this,r); }
313  INLINE intmatrix &intmatrix::operator =(const intmatrix &m) throw() { return _mmassign<intmatrix,intmatrix,int>(*this,m,0); }
314  INLINE intmatrix &intmatrix::operator =(const intvector &v) throw() { return _mvassign<intmatrix,intvector,int>(*this,v); }
315  INLINE intmatrix &intmatrix::operator =(const intvector_slice &v) throw() { return _mvassign<intmatrix,intvector,int>(*this,intvector(v)); }
316  INLINE intmatrix::operator void*() throw() { return _mvoid(*this); }
318 #if(CXSC_INDEX_CHECK)
319  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
320 #else
321  throw()
322 #endif
323  { return _msmassign(*this,m); }
325 #if(CXSC_INDEX_CHECK)
326  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
327 #else
328  throw()
329 #endif
330  { return _msmsassign(*this,ms); }
331  INLINE intmatrix_slice &intmatrix_slice::operator =(const int &r) throw() { return _mssassign(*this,r); }
333 #if(CXSC_INDEX_CHECK)
334  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
335 #else
336  throw()
337 #endif
338  { return _msmassign(*this,intmatrix(v)); }
340 #if(CXSC_INDEX_CHECK)
341  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
342 #else
343  throw()
344 #endif
345  { return _msmassign(*this,intmatrix(intvector(v))); }
347 #if(CXSC_INDEX_CHECK)
348  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
349 #else
350  throw()
351 #endif
352  { return _msmassign(*this,intmatrix(intvector(v))); }
354 #if(CXSC_INDEX_CHECK)
355  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
356 #else
357  throw()
358 #endif
359  { return _msmplusassign(*this,m1); }
361 #if(CXSC_INDEX_CHECK)
362  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
363 #else
364  throw()
365 #endif
366  { return _msmsplusassign(*this,ms2); }
368 #if(CXSC_INDEX_CHECK)
369  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
370 #else
371  throw()
372 #endif
373  { return _msmminusassign(*this,m1); }
375 #if(CXSC_INDEX_CHECK)
376  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
377 #else
378  throw()
379 #endif
380  { return _msmsminusassign(*this,ms2); }
381  INLINE intmatrix_slice &intmatrix_slice::operator *=(const int &c) throw() { return _mssmultassign(*this,c); }
382  INLINE intmatrix_slice &intmatrix_slice::operator /=(const int &c) throw() { return _mssdivassign(*this,c); }
383  INLINE intmatrix_slice::operator void*() throw() { return _msvoid(*this); }
384  INLINE intvector operator /(const intmatrix_subv &rv, const int &s) throw() { return _mvsdiv<intmatrix_subv,int,intvector>(rv,s); }
385  INLINE intvector operator *(const intmatrix_subv &rv, const int &s) throw() { return _mvsmult<intmatrix_subv,int,intvector>(rv,s); }
386  INLINE intvector operator *(const int &s, const intmatrix_subv &rv) throw() { return _mvsmult<intmatrix_subv,int,intvector>(rv,s); }
387  INLINE intmatrix_subv &intmatrix_subv::operator *=(const int &c) throw() { return _mvsmultassign(*this,c); }
388  INLINE intmatrix_subv &intmatrix_subv::operator +=(const int &c) throw() { return _mvsplusassign(*this,c); }
389  INLINE intmatrix_subv &intmatrix_subv::operator -=(const int &c) throw() { return _mvsminusassign(*this,c); }
390  INLINE intmatrix_subv &intmatrix_subv::operator /=(const int &c) throw() { return _mvsdivassign(*this,c); }
391  INLINE intvector abs(const intmatrix_subv &mv) throw() { return _mvabs<intmatrix_subv,intvector>(mv); }
392  INLINE intvector &intvector::operator =(const intmatrix_subv &mv) throw() { return _vmvassign<intvector,intmatrix_subv,int>(*this,mv); }
393  INLINE intvector_slice &intvector_slice::operator =(const intmatrix_subv &mv) throw() { return _vsvassign(*this,intvector(mv)); }
394 
395  INLINE void accumulate(dotprecision &dp, const intmatrix_subv & rv1, const intmatrix_subv &rv2)
396 #if(CXSC_INDEX_CHECK)
397  throw(OP_WITH_WRONG_DIM)
398 #else
399  throw()
400 #endif
401  { _mvmvaccu(dp,rv1,rv2); }
402  INLINE void accumulate(dotprecision &dp, const intvector & rv1, const intmatrix_subv &rv2)
403 #if(CXSC_INDEX_CHECK)
404  throw(OP_WITH_WRONG_DIM)
405 #else
406  throw()
407 #endif
408  { _vmvaccu(dp,rv1,rv2); }
409  INLINE void accumulate(dotprecision &dp, const intmatrix_subv & rv1, const intvector &rv2)
410 #if(CXSC_INDEX_CHECK)
411  throw(OP_WITH_WRONG_DIM)
412 #else
413  throw()
414 #endif
415  { _vmvaccu(dp,rv2,rv1); }
416  INLINE void accumulate(dotprecision &dp,const intvector_slice &sl,const intmatrix_subv &sv)
417 #if(CXSC_INDEX_CHECK)
418  throw(OP_WITH_WRONG_DIM)
419 #else
420  throw()
421 #endif
422  { _vmvaccu(dp,intvector(sl),sv); }
423  INLINE void accumulate(dotprecision &dp,const intmatrix_subv &mv,const intvector_slice &vs)
424 #if(CXSC_INDEX_CHECK)
425  throw(OP_WITH_WRONG_DIM)
426 #else
427  throw()
428 #endif
429  { _vmvaccu(dp,intvector(vs),mv); }
430  INLINE intvector operator +(const intmatrix_subv & rv1, const intmatrix_subv &rv2)
431 #if(CXSC_INDEX_CHECK)
432  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
433 #else
434  throw()
435 #endif
436  { return _mvmvplus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
437  INLINE intvector operator +(const intmatrix_subv &rv1,const intvector &rv2)
438 #if(CXSC_INDEX_CHECK)
439  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
440 #else
441  throw()
442 #endif
443  { return _mvvplus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
444  INLINE intvector operator +(const intvector & rv1, const intmatrix_subv &rv2)
445 #if(CXSC_INDEX_CHECK)
446  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
447 #else
448  throw()
449 #endif
450  { return _mvvplus<intmatrix_subv,intvector,intvector>(rv2,rv1); }
451  INLINE intvector operator +(const intvector_slice &sl,const intmatrix_subv &mv)
452 #if(CXSC_INDEX_CHECK)
453  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
454 #else
455  throw()
456 #endif
457  { return _mvvplus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); }
458  INLINE intvector operator +(const intmatrix_subv &mv,const intvector_slice &sl)
459 #if(CXSC_INDEX_CHECK)
460  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
461 #else
462  throw()
463 #endif
464  { return _mvvplus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); }
466 #if(CXSC_INDEX_CHECK)
467  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
468 #else
469  throw()
470 #endif
471  { return _mvvplusassign(*this,rv); }
473 #if(CXSC_INDEX_CHECK)
474  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
475 #else
476  throw()
477 #endif
478  { return _mvvplusassign(*this,intvector(rv)); }
479  INLINE intvector operator -(const intmatrix_subv & rv1, const intmatrix_subv &rv2)
480 #if(CXSC_INDEX_CHECK)
481  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
482 #else
483  throw()
484 #endif
485  { return _mvmvminus<intmatrix_subv,intmatrix_subv,intvector>(rv1,rv2); }
486  INLINE intvector operator -(const intvector & rv1, const intmatrix_subv &rv2)
487 #if(CXSC_INDEX_CHECK)
488  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
489 #else
490  throw()
491 #endif
492  { return _vmvminus<intvector,intmatrix_subv,intvector>(rv1,rv2); }
493  INLINE intvector operator -(const intmatrix_subv &rv1,const intvector &rv2)
494 #if(CXSC_INDEX_CHECK)
495  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
496 #else
497  throw()
498 #endif
499  { return _mvvminus<intmatrix_subv,intvector,intvector>(rv1,rv2); }
500  INLINE intvector operator -(const intvector_slice &sl,const intmatrix_subv &mv)
501 #if(CXSC_INDEX_CHECK)
502  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
503 #else
504  throw()
505 #endif
506  { return _vmvminus<intvector,intmatrix_subv,intvector>(intvector(sl),mv); }
507  INLINE intvector operator -(const intmatrix_subv &mv,const intvector_slice &sl)
508 #if(CXSC_INDEX_CHECK)
509  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
510 #else
511  throw()
512 #endif
513  { return _mvvminus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); }
515 #if(CXSC_INDEX_CHECK)
516  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
517 #else
518  throw()
519 #endif
520  { return _mvvminusassign(*this,rv); }
522 #if(CXSC_INDEX_CHECK)
523  throw(ERROR_INTVECTOR_OP_WITH_WRONG_DIM)
524 #else
525  throw()
526 #endif
527  { return _mvvminusassign(*this,intvector(rv)); }
533  INLINE intmatrix _intmatrix(const intmatrix &rm) throw() { return rm; }
539  INLINE intmatrix _intmatrix(const intvector &v) throw() { return intmatrix(v); }
545  INLINE intmatrix _intmatrix(const intvector_slice &v) throw() { return intmatrix(v); }
551  INLINE intmatrix _intmatrix(const int &r) throw() { return intmatrix(r); }
552  INLINE intmatrix &intmatrix::operator =(const intmatrix_slice &ms) throw() { return _mmsassign<intmatrix,intmatrix_slice,int>(*this,ms); }
553  INLINE int Lb(const intmatrix &rm, const int &i)
554 #if(CXSC_INDEX_CHECK)
555  throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
556 #else
557  throw()
558 #endif
559  { return _mlb(rm,i); }
560  INLINE int Ub(const intmatrix &rm, const int &i)
561 #if(CXSC_INDEX_CHECK)
562  throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
563 #else
564  throw()
565 #endif
566  { return _mub(rm,i); }
567  INLINE int Lb(const intmatrix_slice &rm, const int &i)
568 #if(CXSC_INDEX_CHECK)
569  throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
570 #else
571  throw()
572 #endif
573  { return _mslb(rm,i); }
574  INLINE int Ub(const intmatrix_slice &rm, const int &i)
575 #if(CXSC_INDEX_CHECK)
576  throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
577 #else
578  throw()
579 #endif
580  { return _msub(rm,i); }
581  INLINE intmatrix &SetLb(intmatrix &m, const int &i,const int &j)
582 #if(CXSC_INDEX_CHECK)
583  throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
584 #else
585  throw()
586 #endif
587  { return _msetlb(m,i,j); }
588  INLINE intmatrix &SetUb(intmatrix &m, const int &i,const int &j)
589 #if(CXSC_INDEX_CHECK)
590  throw(ERROR_INTMATRIX_WRONG_ROW_OR_COL)
591 #else
592  throw()
593 #endif
594  { return _msetub(m,i,j); }
595 
596  INLINE int RowLen ( const intmatrix& A ) // Length of the rows of a integer matrix
597  { return Ub(A,2)-Lb(A,2)+1; } //---------------------------------------
598 
599  INLINE int ColLen ( const intmatrix& A ) // Length of the columns of an integer matrix
600  { return Ub(A,1)-Lb(A,1)+1; } //-------------------------------------------
601 
602  INLINE int RowLen ( const intmatrix_slice& A ) // Length of the rows of a integer matrix
603  { return Ub(A,2)-Lb(A,2)+1; } //---------------------------------------
604 
605  INLINE int ColLen ( const intmatrix_slice& A ) // Length of the columns of an integer matrix
606  { return Ub(A,1)-Lb(A,1)+1; } //-------------------------------------------
607 
608  INLINE void Resize(intmatrix &A) throw() { _mresize(A); }
609  INLINE void Resize(intmatrix &A,const int &m, const int &n)
610 #if(CXSC_INDEX_CHECK)
611  throw(ERROR_INTMATRIX_WRONG_BOUNDARIES)
612 #else
613  throw()
614 #endif
615  { _mresize<intmatrix,int>(A,m,n); }
616  INLINE void Resize(intmatrix &A,const int &m1, const int &m2,const int &n1,const int &n2)
617 #if(CXSC_INDEX_CHECK)
618  throw(ERROR_INTMATRIX_WRONG_BOUNDARIES)
619 #else
620  throw()
621 #endif
622  { _mresize<intmatrix,int>(A,m1,m2,n1,n2); }
623  INLINE intmatrix abs(const intmatrix &m) throw() { return _mabs<intmatrix,intmatrix>(m); }
624  INLINE intmatrix abs(const intmatrix_slice &ms) throw() { return _msabs<intmatrix_slice,intmatrix>(ms); }
625  INLINE intmatrix operator *(const int &c, const intmatrix &m) throw() { return _smmult<int,intmatrix,intmatrix>(c,m); }
626  INLINE intmatrix operator *(const int &c, const intmatrix_slice &ms) throw() { return _smsmult<int,intmatrix_slice,intmatrix>(c,ms); }
627  INLINE intmatrix operator *(const intmatrix &m,const int &c) throw() { return _smmult<int,intmatrix,intmatrix>(c,m); }
628  INLINE intmatrix operator *(const intmatrix_slice &ms,const int &c) throw() { return _smsmult<int,intmatrix_slice,intmatrix>(c,ms); }
629  INLINE intmatrix &operator *=(intmatrix &m,const int &c) throw() { return _msmultassign(m,c); }
630  INLINE intmatrix operator /(const intmatrix &m,const int &c) throw() { return _msdiv<intmatrix,int,intmatrix>(m,c); }
631  INLINE intmatrix operator /(const intmatrix_slice &ms, const int &c) throw() { return _mssdiv<intmatrix_slice,int,intmatrix>(ms,c); }
632  INLINE intmatrix &operator /=(intmatrix &m,const int &c) throw() { return _msdivassign(m,c); }
633  INLINE intvector::intvector(const intmatrix &sl)
634 #if(CXSC_INDEX_CHECK)
635  throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
636 #else
637  throw()
638 #endif
639  { _vmconstr<intvector,intmatrix,int>(*this,sl); }
641 #if(CXSC_INDEX_CHECK)
642  throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
643 #else
644  throw()
645 #endif
646  { _vmsconstr<intvector,intmatrix_slice,int>(*this,sl); }
648 #if(CXSC_INDEX_CHECK)
649  throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
650 #else
651  throw()
652 #endif
653  { return _vmassign<intvector,intmatrix,int>(*this,m); }
655 #if(CXSC_INDEX_CHECK)
656  throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
657 #else
658  throw()
659 #endif
660  { return _vmassign<intvector,intmatrix,int>(*this,intmatrix(m)); }
662 #if(CXSC_INDEX_CHECK)
663  throw(ERROR__OP_WITH_WRONG_DIM<intvector>,ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
664 #else
665  throw()
666 #endif
667  { return _vsvassign(*this,intvector(m)); }
669 #if(CXSC_INDEX_CHECK)
670  throw(ERROR__OP_WITH_WRONG_DIM<intvector>,ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
671 #else
672  throw()
673 #endif
674  { return _vsvassign(*this,intvector(intmatrix(m))); }
676 #if(CXSC_INDEX_CHECK)
677  throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
678 #else
679  throw()
680 #endif
681  { return _mvvassign(*this,intvector(m)); }
683 #if(CXSC_INDEX_CHECK)
684  throw(ERROR_INTMATRIX_TYPE_CAST_OF_THICK_OBJ)
685 #else
686  throw()
687 #endif
688  { return _mvvassign(*this,intvector(intmatrix(m))); }
689 
690  INLINE const intmatrix &operator +(const intmatrix &m) throw() { return m; }
691  INLINE intmatrix operator +(const intmatrix_slice &m) throw() { return intmatrix(m); }
692  INLINE intmatrix operator +(const intmatrix &m1,const intmatrix &m2)
693 #if(CXSC_INDEX_CHECK)
694  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
695 #else
696  throw()
697 #endif
698  { return _mmplus<intmatrix,intmatrix,intmatrix>(m1,m2); }
699  INLINE intmatrix operator +(const intmatrix &m,const intmatrix_slice &ms)
700 #if(CXSC_INDEX_CHECK)
701  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
702 #else
703  throw()
704 #endif
705  { return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
706  INLINE intmatrix operator +(const intmatrix_slice &ms,const intmatrix &m)
707 #if(CXSC_INDEX_CHECK)
708  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
709 #else
710  throw()
711 #endif
712  { return _mmsplus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
713  INLINE intmatrix operator +(const intmatrix_slice &m1,const intmatrix_slice &m2)
714 #if(CXSC_INDEX_CHECK)
715  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
716 #else
717  throw()
718 #endif
719  { return _msmsplus<intmatrix_slice,intmatrix_slice,intmatrix>(m1,m2); }
720  INLINE intmatrix &operator +=(intmatrix &m1,const intmatrix &m2)
721 #if(CXSC_INDEX_CHECK)
722  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
723 #else
724  throw()
725 #endif
726  { return _mmplusassign(m1,m2); }
728 #if(CXSC_INDEX_CHECK)
729  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
730 #else
731  throw()
732 #endif
733  { return _mmsplusassign(m1,ms); }
734  INLINE intmatrix operator -(const intmatrix &m) throw() { return _mminus(m); }
735  INLINE intmatrix operator -(const intmatrix_slice &m) throw() { return _msminus<intmatrix_slice,intmatrix>(m); }
736  INLINE intmatrix operator -(const intmatrix &m1,const intmatrix &m2)
737 #if(CXSC_INDEX_CHECK)
738  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
739 #else
740  throw()
741 #endif
742  { return _mmminus<intmatrix,intmatrix,intmatrix>(m1,m2); }
743  INLINE intmatrix operator -(const intmatrix &m,const intmatrix_slice &ms)
744 #if(CXSC_INDEX_CHECK)
745  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
746 #else
747  throw()
748 #endif
749  { return _mmsminus<intmatrix,intmatrix_slice,intmatrix>(m,ms); }
750  INLINE intmatrix operator -(const intmatrix_slice &ms,const intmatrix &m)
751 #if(CXSC_INDEX_CHECK)
752  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
753 #else
754  throw()
755 #endif
756  { return _msmminus<intmatrix_slice,intmatrix,intmatrix>(ms,m); }
757  INLINE intmatrix operator -(const intmatrix_slice &ms1,const intmatrix_slice &ms2)
758 #if(CXSC_INDEX_CHECK)
759  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
760 #else
761  throw()
762 #endif
763  { return _msmsminus<intmatrix_slice,intmatrix_slice,intmatrix>(ms1,ms2); }
764  INLINE intmatrix &operator -=(intmatrix &m1,const intmatrix &m2)
765 #if(CXSC_INDEX_CHECK)
766  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
767 #else
768  throw()
769 #endif
770  { return _mmminusassign(m1,m2); }
771  INLINE intmatrix &operator -=(intmatrix &m1,const intmatrix_slice &ms)
772 #if(CXSC_INDEX_CHECK)
773  throw(ERROR_INTMATRIX_OP_WITH_WRONG_DIM)
774 #else
775  throw()
776 #endif
777  { return _mmsminusassign(m1,ms); }
778  INLINE bool operator ==(const intmatrix &m1,const intmatrix &m2) throw() { return _mmeq(m1,m2); }
779  INLINE bool operator !=(const intmatrix &m1,const intmatrix &m2) throw() { return _mmneq(m1,m2); }
780  INLINE bool operator <(const intmatrix &m1,const intmatrix &m2) throw() { return _mmless(m1,m2); }
781  INLINE bool operator <=(const intmatrix &m1,const intmatrix &m2) throw() { return _mmleq(m1,m2); }
782  INLINE bool operator >(const intmatrix &m1,const intmatrix &m2) throw() { return _mmless(m2,m1); }
783  INLINE bool operator >=(const intmatrix &m1,const intmatrix &m2) throw() { return _mmleq(m2,m1); }
784  INLINE bool operator ==(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmseq(m1,ms); }
785  INLINE bool operator !=(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmsneq(m1,ms); }
786  INLINE bool operator <(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmsless(m1,ms); }
787  INLINE bool operator <=(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _mmsleq(m1,ms); }
788  INLINE bool operator >(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _msmless(ms,m1); }
789  INLINE bool operator >=(const intmatrix &m1,const intmatrix_slice &ms) throw() { return _msmleq(ms,m1); }
790  INLINE bool operator ==(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmseq(m1,m2); }
791  INLINE bool operator !=(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsneq(m1,m2); }
792  INLINE bool operator <(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsless(m1,m2); }
793  INLINE bool operator <=(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsleq(m1,m2); }
794  INLINE bool operator >(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsless(m2,m1); }
795  INLINE bool operator >=(const intmatrix_slice &m1,const intmatrix_slice &m2) throw() { return _msmsleq(m2,m1); }
796  INLINE bool operator !(const intmatrix &ms) throw() { return _mnot(ms); }
797  INLINE bool operator !(const intmatrix_slice &ms) throw() { return _msnot(ms); }
798  INLINE std::ostream &operator <<(std::ostream &s,const intmatrix &r) throw() { return _mout(s,r); }
799  INLINE std::ostream &operator <<(std::ostream &s,const intmatrix_slice &r) throw() { return _msout(s,r); }
800  INLINE std::istream &operator >>(std::istream &s,intmatrix &r) throw() { return _min(s,r); }
801  INLINE std::istream &operator >>(std::istream &s,intmatrix_slice &r) throw() { return _msin(s,r); }
802 
803  INLINE intvector permvec(const intmatrix& A) {
804  intvector p(RowLen(A));
805  SetLb(p,0);
806  for(int i=0 ; i<ColLen(A) ; i++)
807  for(int j=0 ; j<RowLen(A) ; j++)
808  if(A[i+Lb(A,1)][j+Lb(A,2)] != 0) {
809  p[i] = j;
810  j = RowLen(A);
811  }
812  return p;
813  }
814 
815  INLINE intmatrix permmat(const intvector& x) {
816  intmatrix A(0,VecLen(x)-1,0,VecLen(x)-1);
817  for(int i=0 ; i<VecLen(x) ; i++)
818  A[i][x[i+Lb(x)]] = 1;
819  return A;
820  }
821 
822  INLINE intmatrix perminv(const intmatrix& A) {
823  return transp(A);
824  }
825 
826 } // namespace cxsc
827 
828 #endif
intmatrix & operator=(const int &r)
Implementation of standard assigning operator.
Definition: intmatrix.inl:312
cimatrix & operator/=(cimatrix &m, const cinterval &c)
Implementation of division and allocation operation.
Definition: cimatrix.inl:1623
The Data Type dotprecision.
Definition: dot.hpp:111
The Data Type intmatrix.
Definition: intmatrix.hpp:313
intmatrix_slice & operator-=(const intmatrix &m1)
Implementation of subtraction and allocation operation.
Definition: intmatrix.inl:367
intmatrix_subv operator[](const int &i) const
Operator for accessing a single row of the matrix.
Definition: intmatrix.inl:166
int Lb(const cimatrix &rm, const int &i)
Returns the lower bound index.
Definition: cimatrix.inl:1156
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition: cdot.cpp:29
intmatrix_slice & operator*=(const int &c)
Implementation of multiplication and allocation operation.
Definition: intmatrix.inl:381
civector operator*(const cimatrix_subv &rv, const cinterval &s)
Implementation of multiplication operation.
Definition: cimatrix.inl:731
intmatrix_subv & operator+=(const int &c)
Implementation of addition and allocation operation.
Definition: intmatrix.inl:388
The Data Type intmatrix_subv.
Definition: intmatrix.hpp:45
cimatrix_subv Col(cimatrix &m, const int &i)
Returns one column of the matrix as a vector.
Definition: cimatrix.inl:242
cimatrix & SetLb(cimatrix &m, const int &i, const int &j)
Sets the lower bound index.
Definition: cimatrix.inl:1184
intmatrix & operator()()
Operator for accessing the whole matrix.
Definition: intmatrix.hpp:567
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
Definition: scimatrix.hpp:9966
intmatrix()
Constructor of class intmatrix.
Definition: intmatrix.inl:31
int & operator[](const int &i) const
Operator for accessing the single elements of the vector.
Definition: intmatrix.inl:95
intmatrix_slice & operator=(const intmatrix &m)
Implementation of standard assigning operator.
Definition: intmatrix.inl:317
cimatrix & SetUb(cimatrix &m, const int &i, const int &j)
Sets the upper bound index.
Definition: cimatrix.inl:1191
intmatrix_subv & operator*=(const int &c)
Implementation of multiplication and allocation operation.
Definition: intmatrix.inl:387
intmatrix _intmatrix(const intmatrix &rm)
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC...
Definition: intmatrix.inl:533
void Resize(cimatrix &A)
Resizes the matrix.
Definition: cimatrix.inl:1211
intmatrix_slice & operator()()
Operator for accessing the whole matrix.
Definition: intmatrix.hpp:802
int ColLen(const cimatrix &)
Returns the column dimension.
Definition: cimatrix.inl:1202
The Data Type intvector_slice.
Definition: intvector.hpp:422
cimatrix_subv Row(cimatrix &m, const int &i)
Returns one row of the matrix as a vector.
Definition: cimatrix.inl:231
intmatrix_subv operator[](const int &i)
Operator for accessing a single row of the matrix.
Definition: intmatrix.inl:218
The Data Type intmatrix_slice.
Definition: intmatrix.hpp:593
int RowLen(const cimatrix &)
Returns the row dimension.
Definition: cimatrix.inl:1199
intmatrix_slice & operator/=(const int &c)
Implementation of division and allocation operation.
Definition: intmatrix.inl:382
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc)
Implementation of standard algebraic addition and allocation operation.
Definition: cdot.inl:251
intmatrix_subv & operator()()
Operator for accessing the whole vector.
Definition: intmatrix.hpp:232
intvector()
Constructor of class intvector.
Definition: intvector.inl:33
intmatrix_subv & operator-=(const int &c)
Implementation of subtraction and allocation operation.
Definition: intmatrix.inl:389
int Ub(const cimatrix &rm, const int &i)
Returns the upper bound index.
Definition: cimatrix.inl:1163
civector operator/(const cimatrix_subv &rv, const cinterval &s)
Implementation of division operation.
Definition: cimatrix.inl:730
intvector_slice & operator=(const intvector_slice &sl)
Constructor of class intvector_slice.
Definition: intvector.inl:197
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
Definition: cimatrix.cpp:74
intvector & operator=(const intvector &rv)
Implementation of standard assigning operator.
Definition: intvector.inl:193
intmatrix_subv & operator/=(const int &c)
Implementation of division and allocation operation.
Definition: intmatrix.inl:390
cimatrix & operator*=(cimatrix &m, const cinterval &c)
Implementation of multiplication and allocation operation.
Definition: cimatrix.inl:1605
intmatrix_slice & operator+=(const intmatrix &m1)
Implementation of addition and allocation operation.
Definition: intmatrix.inl:353
The Data Type intvector.
Definition: intvector.hpp:51
intmatrix_subv & operator=(const intmatrix_subv &rv)
Implementation of standard assigning operator.
Definition: intmatrix.inl:296
ivector abs(const cimatrix_subv &mv)
Returns the absolute value of the matrix.
Definition: cimatrix.inl:737