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
29namespace cxsc {
30
31INLINE intmatrix::intmatrix() noexcept:dat(NULL),lb1(1),ub1(0),lb2(1),ub2(0),xsize(0),ysize(0)
32{
33}
34
35INLINE intmatrix::intmatrix(const int &r) noexcept:lb1(1),ub1(1),lb2(1),ub2(1),xsize(1),ysize(1)
36{
37 dat=new int[1];
38 *dat=r;
39}
40
41INLINE intmatrix::intmatrix(const intmatrix &rm) noexcept: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
48INLINE intmatrix::intmatrix(const int &m, const int &n)
49#if(CXSC_INDEX_CHECK)
50:lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
51#else
52 noexcept: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
61INLINE intmatrix::intmatrix(const int &m1, const int &m2, const int &n1, const int &n2)
62#if(CXSC_INDEX_CHECK)
63:lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
64#else
65 noexcept: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
74INLINE intvector::intvector(const intmatrix_subv &v) noexcept: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
81INLINE intmatrix::intmatrix(const intvector &v) noexcept: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
88INLINE intmatrix::intmatrix(const intvector_slice &v) noexcept: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
98#else
99 noexcept
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) noexcept: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
125#else
126 noexcept
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
136#else
137 noexcept
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
147#else
148 noexcept
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
158#else
159 noexcept
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
169#else
170 noexcept
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
182#else
183 noexcept
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
195#else
196 noexcept
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
208#else
209 noexcept
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
221#else
222 noexcept
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
234#else
235 noexcept
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
247#else
248 noexcept
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
260#else
261 noexcept
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
273#else
274 noexcept
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
283INLINE intmatrix_subv intmatrix_subv::operator ()(const int &i1,const int &i2)
284#if(CXSC_INDEX_CHECK)
285
286#else
287 noexcept
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) noexcept { return _mvmvassign(*this,rv); }
297 INLINE intmatrix_subv &intmatrix_subv::operator =(const int &r) noexcept { return _mvsassign(*this,r); }
299#if(CXSC_INDEX_CHECK)
300
301#else
302 noexcept
303#endif
304 { return _mvvassign(*this,v); }
306#if(CXSC_INDEX_CHECK)
307
308#else
309 noexcept
310#endif
311 { return _mvvassign(*this,intvector(v)); }
312 INLINE intmatrix &intmatrix::operator =(const int &r) noexcept { return _msassign(*this,r); }
313 INLINE intmatrix &intmatrix::operator =(const intmatrix &m) noexcept { return _mmassign<intmatrix,intmatrix,int>(*this,m,0); }
314 INLINE intmatrix &intmatrix::operator =(const intvector &v) noexcept { return _mvassign<intmatrix,intvector,int>(*this,v); }
315 INLINE intmatrix &intmatrix::operator =(const intvector_slice &v) noexcept { return _mvassign<intmatrix,intvector,int>(*this,intvector(v)); }
316 INLINE intmatrix::operator void*() noexcept { return _mvoid(*this); }
318#if(CXSC_INDEX_CHECK)
319
320#else
321 noexcept
322#endif
323 { return _msmassign(*this,m); }
325#if(CXSC_INDEX_CHECK)
326
327#else
328 noexcept
329#endif
330 { return _msmsassign(*this,ms); }
331 INLINE intmatrix_slice &intmatrix_slice::operator =(const int &r) noexcept { return _mssassign(*this,r); }
333#if(CXSC_INDEX_CHECK)
334
335#else
336 noexcept
337#endif
338 { return _msmassign(*this,intmatrix(v)); }
340#if(CXSC_INDEX_CHECK)
341
342#else
343 noexcept
344#endif
345 { return _msmassign(*this,intmatrix(intvector(v))); }
347#if(CXSC_INDEX_CHECK)
348
349#else
350 noexcept
351#endif
352 { return _msmassign(*this,intmatrix(intvector(v))); }
354#if(CXSC_INDEX_CHECK)
355
356#else
357 noexcept
358#endif
359 { return _msmplusassign(*this,m1); }
361#if(CXSC_INDEX_CHECK)
362
363#else
364 noexcept
365#endif
366 { return _msmsplusassign(*this,ms2); }
368#if(CXSC_INDEX_CHECK)
369
370#else
371 noexcept
372#endif
373 { return _msmminusassign(*this,m1); }
375#if(CXSC_INDEX_CHECK)
376
377#else
378 noexcept
379#endif
380 { return _msmsminusassign(*this,ms2); }
381 INLINE intmatrix_slice &intmatrix_slice::operator *=(const int &c) noexcept { return _mssmultassign(*this,c); }
382 INLINE intmatrix_slice &intmatrix_slice::operator /=(const int &c) noexcept { return _mssdivassign(*this,c); }
383 INLINE intmatrix_slice::operator void*() noexcept { return _msvoid(*this); }
384 INLINE intvector operator /(const intmatrix_subv &rv, const int &s) noexcept { return _mvsdiv<intmatrix_subv,int,intvector>(rv,s); }
385 INLINE intvector operator *(const intmatrix_subv &rv, const int &s) noexcept { return _mvsmult<intmatrix_subv,int,intvector>(rv,s); }
386 INLINE intvector operator *(const int &s, const intmatrix_subv &rv) noexcept { return _mvsmult<intmatrix_subv,int,intvector>(rv,s); }
387 INLINE intmatrix_subv &intmatrix_subv::operator *=(const int &c) noexcept { return _mvsmultassign(*this,c); }
388 INLINE intmatrix_subv &intmatrix_subv::operator +=(const int &c) noexcept { return _mvsplusassign(*this,c); }
389 INLINE intmatrix_subv &intmatrix_subv::operator -=(const int &c) noexcept { return _mvsminusassign(*this,c); }
390 INLINE intmatrix_subv &intmatrix_subv::operator /=(const int &c) noexcept { return _mvsdivassign(*this,c); }
391 INLINE intvector abs(const intmatrix_subv &mv) noexcept { return _mvabs<intmatrix_subv,intvector>(mv); }
392 INLINE intvector &intvector::operator =(const intmatrix_subv &mv) noexcept { return _vmvassign<intvector,intmatrix_subv,int>(*this,mv); }
393 INLINE intvector_slice &intvector_slice::operator =(const intmatrix_subv &mv) noexcept { 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
398#else
399 noexcept
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
405#else
406 noexcept
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
412#else
413 noexcept
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
419#else
420 noexcept
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
426#else
427 noexcept
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
433#else
434 noexcept
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
440#else
441 noexcept
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
447#else
448 noexcept
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
454#else
455 noexcept
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
461#else
462 noexcept
463#endif
464 { return _mvvplus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); }
466#if(CXSC_INDEX_CHECK)
467
468#else
469 noexcept
470#endif
471 { return _mvvplusassign(*this,rv); }
473#if(CXSC_INDEX_CHECK)
474
475#else
476 noexcept
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
482#else
483 noexcept
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
489#else
490 noexcept
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
496#else
497 noexcept
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
503#else
504 noexcept
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
510#else
511 noexcept
512#endif
513 { return _mvvminus<intmatrix_subv,intvector,intvector>(mv,intvector(sl)); }
515#if(CXSC_INDEX_CHECK)
516
517#else
518 noexcept
519#endif
520 { return _mvvminusassign(*this,rv); }
522#if(CXSC_INDEX_CHECK)
523
524#else
525 noexcept
526#endif
527 { return _mvvminusassign(*this,intvector(rv)); }
533 INLINE intmatrix _intmatrix(const intmatrix &rm) noexcept { return rm; }
539 INLINE intmatrix _intmatrix(const intvector &v) noexcept { return intmatrix(v); }
545 INLINE intmatrix _intmatrix(const intvector_slice &v) noexcept { return intmatrix(v); }
551 INLINE intmatrix _intmatrix(const int &r) noexcept { return intmatrix(r); }
552 INLINE intmatrix &intmatrix::operator =(const intmatrix_slice &ms) noexcept { return _mmsassign<intmatrix,intmatrix_slice,int>(*this,ms); }
553 INLINE int Lb(const intmatrix &rm, const int &i)
554#if(CXSC_INDEX_CHECK)
555
556#else
557 noexcept
558#endif
559 { return _mlb(rm,i); }
560 INLINE int Ub(const intmatrix &rm, const int &i)
561#if(CXSC_INDEX_CHECK)
562
563#else
564 noexcept
565#endif
566 { return _mub(rm,i); }
567 INLINE int Lb(const intmatrix_slice &rm, const int &i)
568#if(CXSC_INDEX_CHECK)
569
570#else
571 noexcept
572#endif
573 { return _mslb(rm,i); }
574 INLINE int Ub(const intmatrix_slice &rm, const int &i)
575#if(CXSC_INDEX_CHECK)
576
577#else
578 noexcept
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
584#else
585 noexcept
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
591#else
592 noexcept
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) noexcept { _mresize(A); }
609 INLINE void Resize(intmatrix &A,const int &m, const int &n)
610#if(CXSC_INDEX_CHECK)
611
612#else
613 noexcept
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
619#else
620 noexcept
621#endif
622 { _mresize<intmatrix,int>(A,m1,m2,n1,n2); }
623 INLINE intmatrix abs(const intmatrix &m) noexcept { return _mabs<intmatrix,intmatrix>(m); }
624 INLINE intmatrix abs(const intmatrix_slice &ms) noexcept { return _msabs<intmatrix_slice,intmatrix>(ms); }
625 INLINE intmatrix operator *(const int &c, const intmatrix &m) noexcept { return _smmult<int,intmatrix,intmatrix>(c,m); }
626 INLINE intmatrix operator *(const int &c, const intmatrix_slice &ms) noexcept { return _smsmult<int,intmatrix_slice,intmatrix>(c,ms); }
627 INLINE intmatrix operator *(const intmatrix &m,const int &c) noexcept { return _smmult<int,intmatrix,intmatrix>(c,m); }
628 INLINE intmatrix operator *(const intmatrix_slice &ms,const int &c) noexcept { return _smsmult<int,intmatrix_slice,intmatrix>(c,ms); }
629 INLINE intmatrix &operator *=(intmatrix &m,const int &c) noexcept { return _msmultassign(m,c); }
630 INLINE intmatrix operator /(const intmatrix &m,const int &c) noexcept { return _msdiv<intmatrix,int,intmatrix>(m,c); }
631 INLINE intmatrix operator /(const intmatrix_slice &ms, const int &c) noexcept { return _mssdiv<intmatrix_slice,int,intmatrix>(ms,c); }
632 INLINE intmatrix &operator /=(intmatrix &m,const int &c) noexcept { return _msdivassign(m,c); }
634#if(CXSC_INDEX_CHECK)
635
636#else
637 noexcept
638#endif
639 { _vmconstr<intvector,intmatrix,int>(*this,sl); }
641#if(CXSC_INDEX_CHECK)
642
643#else
644 noexcept
645#endif
646 { _vmsconstr<intvector,intmatrix_slice,int>(*this,sl); }
648#if(CXSC_INDEX_CHECK)
649
650#else
651 noexcept
652#endif
653 { return _vmassign<intvector,intmatrix,int>(*this,m); }
655#if(CXSC_INDEX_CHECK)
656
657#else
658 noexcept
659#endif
660 { return _vmassign<intvector,intmatrix,int>(*this,intmatrix(m)); }
662#if(CXSC_INDEX_CHECK)
663
664#else
665 noexcept
666#endif
667 { return _vsvassign(*this,intvector(m)); }
669#if(CXSC_INDEX_CHECK)
670
671#else
672 noexcept
673#endif
674 { return _vsvassign(*this,intvector(intmatrix(m))); }
676#if(CXSC_INDEX_CHECK)
677
678#else
679 noexcept
680#endif
681 { return _mvvassign(*this,intvector(m)); }
683#if(CXSC_INDEX_CHECK)
684
685#else
686 noexcept
687#endif
688 { return _mvvassign(*this,intvector(intmatrix(m))); }
689
690 INLINE const intmatrix &operator +(const intmatrix &m) noexcept { return m; }
691 INLINE intmatrix operator +(const intmatrix_slice &m) noexcept { return intmatrix(m); }
692 INLINE intmatrix operator +(const intmatrix &m1,const intmatrix &m2)
693#if(CXSC_INDEX_CHECK)
694
695#else
696 noexcept
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
702#else
703 noexcept
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
709#else
710 noexcept
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
716#else
717 noexcept
718#endif
719 { return _msmsplus<intmatrix_slice,intmatrix_slice,intmatrix>(m1,m2); }
721#if(CXSC_INDEX_CHECK)
722
723#else
724 noexcept
725#endif
726 { return _mmplusassign(m1,m2); }
728#if(CXSC_INDEX_CHECK)
729
730#else
731 noexcept
732#endif
733 { return _mmsplusassign(m1,ms); }
734 INLINE intmatrix operator -(const intmatrix &m) noexcept { return _mminus(m); }
735 INLINE intmatrix operator -(const intmatrix_slice &m) noexcept { return _msminus<intmatrix_slice,intmatrix>(m); }
736 INLINE intmatrix operator -(const intmatrix &m1,const intmatrix &m2)
737#if(CXSC_INDEX_CHECK)
738
739#else
740 noexcept
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
746#else
747 noexcept
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
753#else
754 noexcept
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
760#else
761 noexcept
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
767#else
768 noexcept
769#endif
770 { return _mmminusassign(m1,m2); }
771 INLINE intmatrix &operator -=(intmatrix &m1,const intmatrix_slice &ms)
772#if(CXSC_INDEX_CHECK)
773
774#else
775 noexcept
776#endif
777 { return _mmsminusassign(m1,ms); }
778 INLINE bool operator ==(const intmatrix &m1,const intmatrix &m2) noexcept { return _mmeq(m1,m2); }
779 INLINE bool operator !=(const intmatrix &m1,const intmatrix &m2) noexcept { return _mmneq(m1,m2); }
780 INLINE bool operator <(const intmatrix &m1,const intmatrix &m2) noexcept { return _mmless(m1,m2); }
781 INLINE bool operator <=(const intmatrix &m1,const intmatrix &m2) noexcept { return _mmleq(m1,m2); }
782 INLINE bool operator >(const intmatrix &m1,const intmatrix &m2) noexcept { return _mmless(m2,m1); }
783 INLINE bool operator >=(const intmatrix &m1,const intmatrix &m2) noexcept { return _mmleq(m2,m1); }
784 INLINE bool operator ==(const intmatrix &m1,const intmatrix_slice &ms) noexcept { return _mmseq(m1,ms); }
785 INLINE bool operator !=(const intmatrix &m1,const intmatrix_slice &ms) noexcept { return _mmsneq(m1,ms); }
786 INLINE bool operator <(const intmatrix &m1,const intmatrix_slice &ms) noexcept { return _mmsless(m1,ms); }
787 INLINE bool operator <=(const intmatrix &m1,const intmatrix_slice &ms) noexcept { return _mmsleq(m1,ms); }
788 INLINE bool operator >(const intmatrix &m1,const intmatrix_slice &ms) noexcept { return _msmless(ms,m1); }
789 INLINE bool operator >=(const intmatrix &m1,const intmatrix_slice &ms) noexcept { return _msmleq(ms,m1); }
790 INLINE bool operator ==(const intmatrix_slice &m1,const intmatrix_slice &m2) noexcept { return _msmseq(m1,m2); }
791 INLINE bool operator !=(const intmatrix_slice &m1,const intmatrix_slice &m2) noexcept { return _msmsneq(m1,m2); }
792 INLINE bool operator <(const intmatrix_slice &m1,const intmatrix_slice &m2) noexcept { return _msmsless(m1,m2); }
793 INLINE bool operator <=(const intmatrix_slice &m1,const intmatrix_slice &m2) noexcept { return _msmsleq(m1,m2); }
794 INLINE bool operator >(const intmatrix_slice &m1,const intmatrix_slice &m2) noexcept { return _msmsless(m2,m1); }
795 INLINE bool operator >=(const intmatrix_slice &m1,const intmatrix_slice &m2) noexcept { return _msmsleq(m2,m1); }
796 INLINE bool operator !(const intmatrix &ms) noexcept { return _mnot(ms); }
797 INLINE bool operator !(const intmatrix_slice &ms) noexcept { return _msnot(ms); }
798 INLINE std::ostream &operator <<(std::ostream &s,const intmatrix &r) noexcept { return _mout(s,r); }
799 INLINE std::ostream &operator <<(std::ostream &s,const intmatrix_slice &r) noexcept { return _msout(s,r); }
800 INLINE std::istream &operator >>(std::istream &s,intmatrix &r) noexcept { return _min(s,r); }
801 INLINE std::istream &operator >>(std::istream &s,intmatrix_slice &r) noexcept { 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
The Data Type dotprecision.
Definition dot.hpp:112
The Data Type intmatrix_slice.
intmatrix_slice & operator-=(const intmatrix &m1) noexcept
Implementation of subtraction and allocation operation.
intmatrix_slice & operator=(const intmatrix &m) noexcept
Implementation of standard assigning operator.
intmatrix_slice & operator*=(const int &c) noexcept
Implementation of multiplication and allocation operation.
intmatrix_slice & operator+=(const intmatrix &m1) noexcept
Implementation of addition and allocation operation.
intmatrix_slice & operator/=(const int &c) noexcept
Implementation of division and allocation operation.
intmatrix_slice & operator()() noexcept
Operator for accessing the whole matrix.
intmatrix_subv operator[](const int &i) noexcept
Operator for accessing a single row of the matrix.
The Data Type intmatrix_subv.
Definition intmatrix.hpp:46
int & operator[](const int &i) const noexcept
Operator for accessing the single elements of the vector.
Definition intmatrix.inl:95
intmatrix_subv & operator/=(const int &c) noexcept
Implementation of division and allocation operation.
intmatrix_subv & operator=(const intmatrix_subv &rv) noexcept
Implementation of standard assigning operator.
intmatrix_subv & operator+=(const int &c) noexcept
Implementation of addition and allocation operation.
intmatrix_subv & operator()() noexcept
Operator for accessing the whole vector.
intmatrix_subv & operator-=(const int &c) noexcept
Implementation of subtraction and allocation operation.
intmatrix_subv & operator*=(const int &c) noexcept
Implementation of multiplication and allocation operation.
The Data Type intmatrix.
intmatrix & operator()() noexcept
Operator for accessing the whole matrix.
intmatrix & operator=(const int &r) noexcept
Implementation of standard assigning operator.
intmatrix() noexcept
Constructor of class intmatrix.
Definition intmatrix.inl:31
intmatrix_subv operator[](const int &i) const noexcept
Operator for accessing a single row of the matrix.
The Data Type intvector_slice.
intvector_slice & operator=(const intvector_slice &sl) noexcept
Constructor of class intvector_slice.
The Data Type intvector.
Definition intvector.hpp:52
intvector() noexcept
Constructor of class intvector.
Definition intvector.inl:33
intvector & operator=(const intvector &rv) noexcept
Implementation of standard assigning operator.
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
Definition cdot.inl:251
cimatrix_subv Col(cimatrix &m, const int &i) noexcept
Returns one column of the matrix as a vector.
Definition cimatrix.inl:242
int ColLen(const cimatrix &)
Returns the column dimension.
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
Definition cimatrix.inl:730
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
Definition cimatrix.cpp:74
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
cimatrix & SetLb(cimatrix &m, const int &i, const int &j) noexcept
Sets the lower bound index.
intmatrix _intmatrix(const intmatrix &rm) noexcept
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
int RowLen(const cimatrix &)
Returns the row dimension.
cimatrix_subv Row(cimatrix &m, const int &i) noexcept
Returns one row of the matrix as a vector.
Definition cimatrix.inl:231
cimatrix & operator*=(cimatrix &m, const cinterval &c) noexcept
Implementation of multiplication and allocation operation.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
Definition cimatrix.inl:737
civector operator*(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of multiplication operation.
Definition cimatrix.inl:731
void Resize(cimatrix &A) noexcept
Resizes the matrix.
cimatrix & SetUb(cimatrix &m, const int &i, const int &j) noexcept
Sets the upper bound index.
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.
cimatrix & operator/=(cimatrix &m, const cinterval &c) noexcept
Implementation of division and allocation operation.