C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
rmatrix.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: rmatrix.inl,v 1.29 2014/01/30 17:23:48 cxsc Exp $ */
25 
26 #ifndef _CXSC_RMATRIX_INL_INCLUDED
27 #define _CXSC_RMATRIX_INL_INCLUDED
28 
29 #include "intmatrix.hpp"
30 
31 namespace cxsc {
32 
33 INLINE rmatrix::rmatrix() noexcept:dat(NULL),lb1(1),ub1(0),lb2(1),ub2(0),xsize(0),ysize(0)
34 {
35 }
36 
37 INLINE rmatrix::rmatrix(const real &r) noexcept:lb1(1),ub1(1),lb2(1),ub2(1),xsize(1),ysize(1)
38 {
39  dat=new real[1];
40  *dat=r;
41 }
42 
43 INLINE rmatrix::rmatrix(const rmatrix &rm) noexcept:lb1(rm.lb1),ub1(rm.ub1),lb2(rm.lb2),ub2(rm.ub2),xsize(rm.xsize),ysize(rm.ysize)
44 {
45  dat=new real[xsize*ysize];
46  for(int i=0;i<xsize*ysize;i++)
47  dat[i]=rm.dat[i];
48 }
49 
50 INLINE rmatrix::rmatrix(const int &m, const int &n)
51 #if(CXSC_INDEX_CHECK)
52 :lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
53 #else
54  noexcept:lb1(1),ub1(m),lb2(1),ub2(n),xsize(n),ysize(m)
55 #endif
56 {
57 #if(CXSC_INDEX_CHECK)
58  if((n<0)||(m<0)) cxscthrow(ERROR_RMATRIX_WRONG_BOUNDARIES("rmatrix::rmatrix(const int &m, const int &n)"));
59 #endif
60  dat=new real[m*n];
61 }
62 
63 INLINE rmatrix::rmatrix(const int &m1, const int &m2, const int &n1, const int &n2)
64 #if(CXSC_INDEX_CHECK)
65 :lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
66 #else
67  noexcept:lb1(m1),ub1(m2),lb2(n1),ub2(n2),xsize(n2-n1+1),ysize(m2-m1+1)
68 #endif
69 {
70 #if(CXSC_INDEX_CHECK)
71  if((m2<m1)||(n2<n1)) cxscthrow(ERROR_RMATRIX_WRONG_BOUNDARIES("rmatrix::rmatrix(const int &m1, const int &n1, const int &m2, const int &n2)"));
72 #endif
73  dat=new real[xsize*ysize];
74 }
75 
76 INLINE rvector::rvector(const rmatrix_subv &v) noexcept:l(v.lb),u(v.ub),size(v.size)
77 {
78  dat=new real[size];
79  for (int i=0, j=v.start;i<v.size;i++,j+=v.offset)
80  dat[i]=v.dat[j];
81 }
82 
83 INLINE rmatrix::rmatrix(const rvector &v) noexcept:lb1(v.l),ub1(v.u),lb2(1),ub2(1),xsize(1),ysize(v.size)
84 {
85  dat=new real[v.size];
86  for(int i=0;i<v.size;i++)
87  dat[i]=v.dat[i];
88 }
89 
90 INLINE rmatrix::rmatrix(const rvector_slice &v) noexcept:lb1(v.start),ub1(v.end),lb2(1),ub2(1),xsize(1),ysize(v.size)
91 {
92  dat=new real[v.size];
93  for(int i=0,j=v.start-v.l;i<v.size;i++,j++)
94  dat[i]=v.dat[j];
95 }
96 
97 
98  INLINE rmatrix::rmatrix(const rmatrix_slice &sl) noexcept:lb1(sl.start1),ub1(sl.end1),lb2(sl.start2),ub2(sl.end2),xsize(sl.sxsize),ysize(sl.sysize)
99  {
100  int i,j;
101 
102  dat=new real[xsize*ysize];
103  for (i=0;i<ysize;i++)
104  {
105  for(j=0;j<xsize;j++)
106  {
107  dat[i*xsize+j]=sl.dat[(sl.offset1+i)*sl.mxsize+sl.offset2+j];
108  }
109  }
110  }
111 
112 INLINE rmatrix::rmatrix(const intmatrix& I) : lb1(Lb(I,1)),ub1(Ub(I,1)),lb2(Lb(I,2)),ub2(Ub(I,2)),xsize(RowLen(I)),ysize(ColLen(I)) {
113  dat=new real[xsize*ysize];
114  for(int i=0 ; i<ysize ; i++)
115  for(int j=0 ; j<xsize ; j++)
116  dat[i*xsize+j] = I[i+lb1][j+lb2];
117 }
118 
119  INLINE rmatrix_subv Row(rmatrix &m,const int &i)
120 #if(CXSC_INDEX_CHECK)
121 
122 #else
123  noexcept
124 #endif
125 
126  {
127  return m[i];
128  }
129 
130  INLINE rmatrix_subv Col(rmatrix &m,const int &i)
131 #if(CXSC_INDEX_CHECK)
132 
133 #else
134  noexcept
135 #endif
136 
137  {
138  return m[Col(i)];
139  }
140  INLINE rmatrix_subv Row(const rmatrix &m,const int &i)
141 #if(CXSC_INDEX_CHECK)
142 
143 #else
144  noexcept
145 #endif
146 
147  {
148  return m[i];
149  }
150 
151  INLINE rmatrix_subv Col(const rmatrix &m,const int &i)
152 #if(CXSC_INDEX_CHECK)
153 
154 #else
155  noexcept
156 #endif
157 
158  {
159  return m[Col(i)];
160  }
161 
162  INLINE real& rmatrix_subv::operator [](const int &i) const
163 #if(CXSC_INDEX_CHECK)
164 
165 #else
166  noexcept
167 #endif
168  {
169 #if(CXSC_INDEX_CHECK)
170  if((i<lb)||(i>ub)) cxscthrow(ERROR_RVECTOR_ELEMENT_NOT_IN_VEC("real &rmatrix_subv::operator [](const int &i) const"));
171 #endif
172  return dat[start+((i-lb)*offset)];
173  }
174 
175  INLINE real& rmatrix_subv::operator [](const int &i)
176 #if(CXSC_INDEX_CHECK)
177 
178 #else
179  noexcept
180 #endif
181  {
182 #if(CXSC_INDEX_CHECK)
183  if((i<lb)||(i>ub)) cxscthrow(ERROR_RVECTOR_ELEMENT_NOT_IN_VEC("real &rmatrix_subv::operator [](const int &i)"));
184 #endif
185  return dat[start+((i-lb)*offset)];
186  }
187 
188 
189 
190  INLINE rmatrix_subv rmatrix::operator [](const int &i) const
191 #if(CXSC_INDEX_CHECK)
192 
193 #else
194  noexcept
195 #endif
196  {
197 #if(CXSC_INDEX_CHECK)
198  if((i<lb1)||(i>ub1)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT("rmatrix_subv rmatrix::operator [](const int &i)"));
199 #endif
200  return rmatrix_subv(dat, lb2, ub2, xsize, xsize*(i-lb1),1);
201  }
202 
203  INLINE rmatrix_subv rmatrix::operator [](const cxscmatrix_column &i) const
204 #if(CXSC_INDEX_CHECK)
205 
206 #else
207  noexcept
208 #endif
209  {
210 #if(CXSC_INDEX_CHECK)
211  if((i.col()<lb2)||(i.col()>ub2)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT("rmatrix_subv rmatrix::operator [](const cxscmatrix_column &i)"));
212 #endif
213  return rmatrix_subv(dat, lb1, ub1, ysize, i.col()-lb2, xsize);
214  }
215 
216  INLINE rmatrix_slice rmatrix::operator ()(const int &m, const int &n)
217 #if(CXSC_INDEX_CHECK)
218 
219 #else
220  noexcept
221 #endif
222  {
223 #if(CXSC_INDEX_CHECK)
224  if((m<1)||(n<1)||(m<lb1)||(n<lb2)||(m>ub1)||(n>ub2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG("rmatrix_slice rmatrix::operator ()(const int &m, const int &n)"));
225 #endif
226  return rmatrix_slice(*this,1,m,1,n);
227  }
228 
229  INLINE rmatrix_slice rmatrix::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)
230 #if(CXSC_INDEX_CHECK)
231 
232 #else
233  noexcept
234 #endif
235  {
236 #if(CXSC_INDEX_CHECK)
237  if((m1<lb1)||(n1<lb2)||(m2>ub1)||(n2>ub2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG("rmatrix_slice rmatrix::operator ()(const int &m1, const int &n1, const int &m2, const int &n2)"));
238 #endif
239  return rmatrix_slice(*this,m1,m2,n1,n2);
240  }
241 
242  INLINE rmatrix_subv rmatrix_slice::operator [](const int &i) const
243 #if(CXSC_INDEX_CHECK)
244 
245 #else
246  noexcept
247 #endif
248  {
249 #if(CXSC_INDEX_CHECK)
250  if((i<start1)||(i>end1)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT("rmatrix_subv rmatrix_slice::operator [](const int &i)"));
251 #endif
252  return rmatrix_subv(dat, start2, end2, sxsize, mxsize*(i-start1+offset1)+offset2,1);
253  }
254 
255  INLINE rmatrix_subv rmatrix_slice::operator [](const cxscmatrix_column &i) const
256 #if(CXSC_INDEX_CHECK)
257 
258 #else
259  noexcept
260 #endif
261  {
262 #if(CXSC_INDEX_CHECK)
263  if((i.col()<start2)||(i.col()>end2)) cxscthrow(ERROR_RMATRIX_ROW_OR_COL_NOT_IN_MAT("rmatrix_subv rmatrix_slice::operator [](const cxscmatrix_column &i)"));
264 #endif
265  return rmatrix_subv(dat, start1, end1, sysize, offset1*mxsize+i.col()-start2+offset2, mxsize);
266  }
267 
268  INLINE rmatrix_slice rmatrix_slice::operator ()(const int &m, const int &n)
269 #if(CXSC_INDEX_CHECK)
270 
271 #else
272  noexcept
273 #endif
274  {
275 #if(CXSC_INDEX_CHECK)
276  if((m<1)||(n<1)||(m<start1)||(n<start2)||(m>end1)||(n>end2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG("rmatrix_slice rmatrix_slice::operator ()(const int &m, const int &n)"));
277 #endif
278  return rmatrix_slice(*this,1,m,1,n);
279  }
280 
281  INLINE rmatrix_slice rmatrix_slice::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)
282 #if(CXSC_INDEX_CHECK)
283 
284 #else
285  noexcept
286 #endif
287  {
288 #if(CXSC_INDEX_CHECK)
289  if((m1<start1)||(n1<start2)||(m2>end1)||(n2>end2)) cxscthrow(ERROR_RMATRIX_SUB_ARRAY_TOO_BIG("rmatrix_slice rmatrix_slice::operator ()(const int &m1, const int &m2, const int &n1, const int &n2)"));
290 #endif
291  return rmatrix_slice(*this,m1,m2,n1,n2);
292  }
293 
295 #if(CXSC_INDEX_CHECK)
296 
297 #else
298  noexcept
299 #endif
300 {
301 #if(CXSC_INDEX_CHECK)
302  if(1<lb||i>ub) cxscthrow(ERROR_RVECTOR_SUB_ARRAY_TOO_BIG("rmatrix_subv rmatrix_subv::operator ()(const int &i)"));
303 #endif
304  return rmatrix_subv(dat,1,i,i,start+(1-lb)*offset,offset);
305 }
306 
307 INLINE rmatrix_subv rmatrix_subv::operator ()(const int &i1,const int &i2)
308 #if(CXSC_INDEX_CHECK)
309 
310 #else
311  noexcept
312 #endif
313 {
314 #if(CXSC_INDEX_CHECK)
315  if(i1<lb||i2>ub) cxscthrow(ERROR_RVECTOR_SUB_ARRAY_TOO_BIG("rmatrix_subv rmatrix_subv::operator ()(const int &i1,const int &i2)"));
316 #endif
317  return rmatrix_subv(dat,i1,i2,i2-i1+1,start+(i1-lb)*offset,offset);
318 }
319 
320 // the following is generated from .hpp
321 
322  INLINE rmatrix_subv &rmatrix_subv::operator =(const rmatrix_subv &rv) noexcept { return _mvmvassign(*this,rv); }
323  INLINE rmatrix_subv &rmatrix_subv::operator =(const real &r) noexcept { return _mvsassign(*this,r); }
325 #if(CXSC_INDEX_CHECK)
326 
327 #else
328  noexcept
329 #endif
330  { return _mvvassign(*this,v); }
332 #if(CXSC_INDEX_CHECK)
333 
334 #else
335  noexcept
336 #endif
337  { return _mvvassign(*this,rvector(v)); }
338  INLINE rmatrix &rmatrix::operator =(const real &r) noexcept { return _msassign(*this,r); }
339  INLINE rmatrix &rmatrix::operator =(const rmatrix &m) noexcept { return _mmassign<rmatrix,rmatrix,real>(*this,m,0); }
340  INLINE rmatrix &rmatrix::operator =(const rvector &v) noexcept { return _mvassign<rmatrix,rvector,real>(*this,v); }
341  INLINE rmatrix &rmatrix::operator =(const rvector_slice &v) noexcept { return _mvassign<rmatrix,rvector,real>(*this,rvector(v)); }
342  INLINE rmatrix::operator void*() noexcept { return _mvoid(*this); }
344 #if(CXSC_INDEX_CHECK)
345 
346 #else
347  noexcept
348 #endif
349  { return _msmassign(*this,m); }
351 #if(CXSC_INDEX_CHECK)
352 
353 #else
354  noexcept
355 #endif
356  { return _msmsassign(*this,ms); }
357  INLINE rmatrix_slice &rmatrix_slice::operator =(const real &r) noexcept { return _mssassign(*this,r); }
359 #if(CXSC_INDEX_CHECK)
360 
361 #else
362  noexcept
363 #endif
364  { return _msmassign(*this,rmatrix(v)); }
366 #if(CXSC_INDEX_CHECK)
367 
368 #else
369  noexcept
370 #endif
371  { return _msmassign(*this,rmatrix(rvector(v))); }
373 #if(CXSC_INDEX_CHECK)
374 
375 #else
376  noexcept
377 #endif
378  { return _msmassign(*this,rmatrix(rvector(v))); }
380 #if(CXSC_INDEX_CHECK)
381 
382 #else
383  noexcept
384 #endif
385  { return _msmplusassign(*this,m1); }
387 #if(CXSC_INDEX_CHECK)
388 
389 #else
390  noexcept
391 #endif
392  { return _msmsplusassign(*this,ms2); }
394 #if(CXSC_INDEX_CHECK)
395 
396 #else
397  noexcept
398 #endif
399  { return _msmminusassign(*this,m1); }
401 #if(CXSC_INDEX_CHECK)
402 
403 #else
404  noexcept
405 #endif
406  { return _msmsminusassign(*this,ms2); }
408 #if(CXSC_INDEX_CHECK)
409 
410 #else
411  noexcept
412 #endif
413  { return (*this=*this*m); }
415 #if(CXSC_INDEX_CHECK)
416 
417 #else
418  noexcept
419 #endif
420  { return (*this=*this*m); }
421  INLINE rmatrix_slice &rmatrix_slice::operator *=(const real &c) noexcept { return _mssmultassign(*this,c); }
422  INLINE rmatrix_slice &rmatrix_slice::operator /=(const real &c) noexcept { return _mssdivassign(*this,c); }
423  INLINE rmatrix_slice::operator void*() noexcept { return _msvoid(*this); }
424  INLINE rvector operator /(const rmatrix_subv &rv, const real &s) noexcept { return _mvsdiv<rmatrix_subv,real,rvector>(rv,s); }
425  INLINE rvector operator *(const rmatrix_subv &rv, const real &s) noexcept { return _mvsmult<rmatrix_subv,real,rvector>(rv,s); }
426  INLINE rvector operator *(const real &s, const rmatrix_subv &rv) noexcept { return _mvsmult<rmatrix_subv,real,rvector>(rv,s); }
427  INLINE rmatrix_subv &rmatrix_subv::operator *=(const real &c) noexcept { return _mvsmultassign(*this,c); }
428  INLINE rmatrix_subv &rmatrix_subv::operator +=(const real &c) noexcept { return _mvsplusassign(*this,c); }
429  INLINE rmatrix_subv &rmatrix_subv::operator -=(const real &c) noexcept { return _mvsminusassign(*this,c); }
430  INLINE rmatrix_subv &rmatrix_subv::operator /=(const real &c) noexcept { return _mvsdivassign(*this,c); }
431  INLINE rvector abs(const rmatrix_subv &mv) noexcept { return _mvabs<rmatrix_subv,rvector>(mv); }
432  INLINE rvector &rvector::operator =(const rmatrix_subv &mv) noexcept { return _vmvassign<rvector,rmatrix_subv,real>(*this,mv); }
433  INLINE rvector_slice &rvector_slice::operator =(const rmatrix_subv &mv) noexcept { return _vsvassign(*this,rvector(mv)); }
434 
435 
436  INLINE real operator *(const rmatrix_subv & rv1, const rmatrix_subv &rv2)
437 #if(CXSC_INDEX_CHECK)
438 
439 #else
440  noexcept
441 #endif
442  { return _mvmvmult<rmatrix_subv,rmatrix_subv,real>(rv1,rv2); }
443  INLINE real operator *(const rvector & rv1, const rmatrix_subv &rv2)
444 #if(CXSC_INDEX_CHECK)
445 
446 #else
447  noexcept
448 #endif
449  { return _vmvmult<rvector,rmatrix_subv,real>(rv1,rv2); }
450  INLINE real operator *(const rmatrix_subv &rv1,const rvector &rv2)
451 #if(CXSC_INDEX_CHECK)
452 
453 #else
454  noexcept
455 #endif
456  { return _vmvmult<rvector,rmatrix_subv,real>(rv2,rv1); }
457  INLINE real operator *(const rvector_slice &sl,const rmatrix_subv &sv)
458 #if(CXSC_INDEX_CHECK)
459 
460 #else
461  noexcept
462 #endif
463  { return _vmvmult<rvector,rmatrix_subv,real>(rvector(sl),sv); }
464  INLINE real operator *(const rmatrix_subv &mv,const rvector_slice &vs)
465 #if(CXSC_INDEX_CHECK)
466 
467 #else
468  noexcept
469 #endif
470  { return _vmvmult<rvector,rmatrix_subv,real>(rvector(vs),mv); }
471  INLINE rvector operator +(const rmatrix_subv & rv1, const rmatrix_subv &rv2)
472 #if(CXSC_INDEX_CHECK)
473 
474 #else
475  noexcept
476 #endif
477  { return _mvmvplus<rmatrix_subv,rmatrix_subv,rvector>(rv1,rv2); }
478  INLINE rvector operator +(const rmatrix_subv &rv1,const rvector &rv2)
479 #if(CXSC_INDEX_CHECK)
480 
481 #else
482  noexcept
483 #endif
484  { return _mvvplus<rmatrix_subv,rvector,rvector>(rv1,rv2); }
485  INLINE rvector operator +(const rvector & rv1, const rmatrix_subv &rv2)
486 #if(CXSC_INDEX_CHECK)
487 
488 #else
489  noexcept
490 #endif
491  { return _mvvplus<rmatrix_subv,rvector,rvector>(rv2,rv1); }
492  INLINE rvector operator +(const rvector_slice &sl,const rmatrix_subv &mv)
493 #if(CXSC_INDEX_CHECK)
494 
495 #else
496  noexcept
497 #endif
498  { return _mvvplus<rmatrix_subv,rvector,rvector>(mv,rvector(sl)); }
499  INLINE rvector operator +(const rmatrix_subv &mv,const rvector_slice &sl)
500 #if(CXSC_INDEX_CHECK)
501 
502 #else
503  noexcept
504 #endif
505  { return _mvvplus<rmatrix_subv,rvector,rvector>(mv,rvector(sl)); }
507 #if(CXSC_INDEX_CHECK)
508 
509 #else
510  noexcept
511 #endif
512  { return _mvvplusassign(*this,rv); }
514 #if(CXSC_INDEX_CHECK)
515 
516 #else
517  noexcept
518 #endif
519  { return _mvvplusassign(*this,rvector(rv)); }
520  INLINE rvector operator -(const rmatrix_subv & rv1, const rmatrix_subv &rv2)
521 #if(CXSC_INDEX_CHECK)
522 
523 #else
524  noexcept
525 #endif
526  { return _mvmvminus<rmatrix_subv,rmatrix_subv,rvector>(rv1,rv2); }
527  INLINE rvector operator -(const rvector & rv1, const rmatrix_subv &rv2)
528 #if(CXSC_INDEX_CHECK)
529 
530 #else
531  noexcept
532 #endif
533  { return _vmvminus<rvector,rmatrix_subv,rvector>(rv1,rv2); }
534  INLINE rvector operator -(const rmatrix_subv &rv1,const rvector &rv2)
535 #if(CXSC_INDEX_CHECK)
536 
537 #else
538  noexcept
539 #endif
540  { return _mvvminus<rmatrix_subv,rvector,rvector>(rv1,rv2); }
541  INLINE rvector operator -(const rvector_slice &sl,const rmatrix_subv &mv)
542 #if(CXSC_INDEX_CHECK)
543 
544 #else
545  noexcept
546 #endif
547  { return _vmvminus<rvector,rmatrix_subv,rvector>(rvector(sl),mv); }
548  INLINE rvector operator -(const rmatrix_subv &mv,const rvector_slice &sl)
549 #if(CXSC_INDEX_CHECK)
550 
551 #else
552  noexcept
553 #endif
554  { return _mvvminus<rmatrix_subv,rvector,rvector>(mv,rvector(sl)); }
556 #if(CXSC_INDEX_CHECK)
557 
558 #else
559  noexcept
560 #endif
561  { return _mvvminusassign(*this,rv); }
563 #if(CXSC_INDEX_CHECK)
564 
565 #else
566  noexcept
567 #endif
568  { return _mvvminusassign(*this,rvector(rv)); }
574  INLINE rmatrix _rmatrix(const rmatrix &rm) noexcept { return rm; }
580  INLINE rmatrix _rmatrix(const rvector &v) noexcept { return rmatrix(v); }
586  INLINE rmatrix _rmatrix(const rvector_slice &v) noexcept { return rmatrix(v); }
592  INLINE rmatrix _rmatrix(const real &r) noexcept { return rmatrix(r); }
593  INLINE rmatrix &rmatrix::operator =(const rmatrix_slice &ms) noexcept { return _mmsassign<rmatrix,rmatrix_slice,real>(*this,ms); }
594  INLINE int Lb(const rmatrix &rm, const int &i)
595 #if(CXSC_INDEX_CHECK)
596 
597 #else
598  noexcept
599 #endif
600  { return _mlb(rm,i); }
601  INLINE int Ub(const rmatrix &rm, const int &i)
602 #if(CXSC_INDEX_CHECK)
603 
604 #else
605  noexcept
606 #endif
607  { return _mub(rm,i); }
608  INLINE int Lb(const rmatrix_slice &rm, const int &i)
609 #if(CXSC_INDEX_CHECK)
610 
611 #else
612  noexcept
613 #endif
614  { return _mslb(rm,i); }
615  INLINE int Ub(const rmatrix_slice &rm, const int &i)
616 #if(CXSC_INDEX_CHECK)
617 
618 #else
619  noexcept
620 #endif
621  { return _msub(rm,i); }
622  INLINE rmatrix &SetLb(rmatrix &m, const int &i,const int &j)
623 #if(CXSC_INDEX_CHECK)
624 
625 #else
626  noexcept
627 #endif
628  { return _msetlb(m,i,j); }
629  INLINE rmatrix &SetUb(rmatrix &m, const int &i,const int &j)
630 #if(CXSC_INDEX_CHECK)
631 
632 #else
633  noexcept
634 #endif
635  { return _msetub(m,i,j); }
636 
637 
638  INLINE int RowLen ( const rmatrix& A ) // Length of the rows of a real matrix
639  { return Ub(A,2)-Lb(A,2)+1; } //------------------------------------
640 
641  INLINE int ColLen ( const rmatrix& A ) // Length of the columns of a real matrix
642  { return Ub(A,1)-Lb(A,1)+1; } //---------------------------------------
643 
644  INLINE int RowLen ( const rmatrix_slice& A ) // Length of the rows of a real matrix
645  { return Ub(A,2)-Lb(A,2)+1; } //------------------------------------
646 
647  INLINE int ColLen ( const rmatrix_slice& A ) // Length of the columns of a real matrix
648  { return Ub(A,1)-Lb(A,1)+1; } //---------------------------------------
649 
650  INLINE void Resize(rmatrix &A) noexcept { _mresize(A); }
651  INLINE void Resize(rmatrix &A,const int &m, const int &n)
652 #if(CXSC_INDEX_CHECK)
653 
654 #else
655  noexcept
656 #endif
657  { _mresize<rmatrix,real>(A,m,n); }
658  INLINE void Resize(rmatrix &A,const int &m1, const int &m2,const int &n1,const int &n2)
659 #if(CXSC_INDEX_CHECK)
660 
661 #else
662  noexcept
663 #endif
664  { _mresize<rmatrix,real>(A,m1,m2,n1,n2); }
665  INLINE rmatrix abs(const rmatrix &m) noexcept { return _mabs<rmatrix,rmatrix>(m); }
666  INLINE rmatrix abs(const rmatrix_slice &ms) noexcept { return _msabs<rmatrix_slice,rmatrix>(ms); }
667  INLINE real::real(const rmatrix &m)
668 #if(CXSC_INDEX_CHECK)
669 
670 #else
671  noexcept
672 #endif
673  { _smconstr(*this,m); }
674 // INLINE real real::_real(const rmatrix &m) { _smconstr(*this,m); return *this; }
675  INLINE rmatrix operator *(const real &c, const rmatrix &m) noexcept { return _smmult<real,rmatrix,rmatrix>(c,m); }
676  INLINE rmatrix operator *(const real &c, const rmatrix_slice &ms) noexcept { return _smsmult<real,rmatrix_slice,rmatrix>(c,ms); }
677  INLINE rmatrix operator *(const rmatrix &m,const real &c) noexcept { return _smmult<real,rmatrix,rmatrix>(c,m); }
678  INLINE rmatrix operator *(const rmatrix_slice &ms,const real &c) noexcept { return _smsmult<real,rmatrix_slice,rmatrix>(c,ms); }
679  INLINE rmatrix &operator *=(rmatrix &m,const real &c) noexcept { return _msmultassign(m,c); }
680  INLINE rmatrix operator /(const rmatrix &m,const real &c) noexcept { return _msdiv<rmatrix,real,rmatrix>(m,c); }
681  INLINE rmatrix operator /(const rmatrix_slice &ms, const real &c) noexcept { return _mssdiv<rmatrix_slice,real,rmatrix>(ms,c); }
682  INLINE rmatrix &operator /=(rmatrix &m,const real &c) noexcept { return _msdivassign(m,c); }
683  INLINE rvector::rvector(const rmatrix &sl)
684 #if(CXSC_INDEX_CHECK)
685 
686 #else
687  noexcept
688 #endif
689  { _vmconstr<rvector,rmatrix,real>(*this,sl); }
690  INLINE rvector::rvector(const rmatrix_slice &sl)
691 #if(CXSC_INDEX_CHECK)
692 
693 #else
694  noexcept
695 #endif
696  { _vmsconstr<rvector,rmatrix_slice,real>(*this,sl); }
698 #if(CXSC_INDEX_CHECK)
699 
700 #else
701  noexcept
702 #endif
703  { return _vmassign<rvector,rmatrix,real>(*this,m); }
705 #if(CXSC_INDEX_CHECK)
706 
707 #else
708  noexcept
709 #endif
710  { return _vmassign<rvector,rmatrix,real>(*this,rmatrix(m)); }
712 #if(CXSC_INDEX_CHECK)
713 
714 #else
715  noexcept
716 #endif
717  { return _vsvassign(*this,rvector(m)); }
719 #if(CXSC_INDEX_CHECK)
720 
721 #else
722  noexcept
723 #endif
724  { return _vsvassign(*this,rvector(rmatrix(m))); }
726 #if(CXSC_INDEX_CHECK)
727 
728 #else
729  noexcept
730 #endif
731  { return _mvvassign(*this,rvector(m)); }
733 #if(CXSC_INDEX_CHECK)
734 
735 #else
736  noexcept
737 #endif
738  { return _mvvassign(*this,rvector(rmatrix(m))); }
739  INLINE rvector operator *(const rmatrix &m,const rvector &v)
740 #if(CXSC_INDEX_CHECK)
741 
742 #else
743  noexcept
744 #endif
745  { return _mvmult<rmatrix,rvector,rvector>(m,v); };
746  INLINE rvector operator *(const rmatrix_slice &ms,const rvector &v)
747 #if(CXSC_INDEX_CHECK)
748 
749 #else
750  noexcept
751 #endif
752  { return _msvmult<rmatrix_slice,rvector,rvector>(ms,v); }
753  INLINE rvector operator *(const rvector &v,const rmatrix &m)
754 #if(CXSC_INDEX_CHECK)
755 
756 #else
757  noexcept
758 #endif
759  { return _vmmult<rvector,rmatrix,rvector>(v,m); }
760  INLINE rvector operator *(const rvector &v,const rmatrix_slice &ms)
761 #if(CXSC_INDEX_CHECK)
762 
763 #else
764  noexcept
765 #endif
766  { return _vmsmult<rvector,rmatrix_slice,rvector>(v,ms); }
767  INLINE rvector &operator *=(rvector &v,const rmatrix &m)
768 #if(CXSC_INDEX_CHECK)
769 
770 #else
771  noexcept
772 #endif
773  { return _vmmultassign<rvector,rmatrix,real>(v,m); }
774  INLINE rvector &operator *=(rvector &v,const rmatrix_slice &ms)
775 #if(CXSC_INDEX_CHECK)
776 
777 #else
778  noexcept
779 #endif
780  { return _vmsmultassign<rvector,rmatrix_slice,real>(v,ms); }
782 #if(CXSC_INDEX_CHECK)
783 
784 #else
785  noexcept
786 #endif
787  { return _vsmmultassign<rvector_slice,rmatrix,real>(*this,m); }
788  INLINE rvector operator *(const rvector_slice &v,const rmatrix &m)
789 #if(CXSC_INDEX_CHECK)
790 
791 #else
792  noexcept
793 #endif
794  { return _vmmult<rvector,rmatrix,rvector>(rvector(v),m); }
795 
796  INLINE const rmatrix &operator +(const rmatrix &m) noexcept { return m; }
797  INLINE rmatrix operator +(const rmatrix_slice &m) noexcept { return rmatrix(m); }
798  INLINE rmatrix operator +(const rmatrix &m1,const rmatrix &m2)
799 #if(CXSC_INDEX_CHECK)
800 
801 #else
802  noexcept
803 #endif
804  { return _mmplus<rmatrix,rmatrix,rmatrix>(m1,m2); }
805  INLINE rmatrix operator +(const rmatrix &m,const rmatrix_slice &ms)
806 #if(CXSC_INDEX_CHECK)
807 
808 #else
809  noexcept
810 #endif
811  { return _mmsplus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
812  INLINE rmatrix operator +(const rmatrix_slice &ms,const rmatrix &m)
813 #if(CXSC_INDEX_CHECK)
814 
815 #else
816  noexcept
817 #endif
818  { return _mmsplus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
819  INLINE rmatrix operator +(const rmatrix_slice &m1,const rmatrix_slice &m2)
820 #if(CXSC_INDEX_CHECK)
821 
822 #else
823  noexcept
824 #endif
825  { return _msmsplus<rmatrix_slice,rmatrix_slice,rmatrix>(m1,m2); }
826  INLINE rmatrix &operator +=(rmatrix &m1,const rmatrix &m2)
827 #if(CXSC_INDEX_CHECK)
828 
829 #else
830  noexcept
831 #endif
832  { return _mmplusassign(m1,m2); }
833  INLINE rmatrix &operator +=(rmatrix &m1,const rmatrix_slice &ms)
834 #if(CXSC_INDEX_CHECK)
835 
836 #else
837  noexcept
838 #endif
839  { return _mmsplusassign(m1,ms); }
840  INLINE rmatrix operator -(const rmatrix &m) noexcept { return _mminus(m); }
841  INLINE rmatrix operator -(const rmatrix_slice &m) noexcept { return _msminus<rmatrix_slice,rmatrix>(m); }
842  INLINE rmatrix operator -(const rmatrix &m1,const rmatrix &m2)
843 #if(CXSC_INDEX_CHECK)
844 
845 #else
846  noexcept
847 #endif
848  { return _mmminus<rmatrix,rmatrix,rmatrix>(m1,m2); }
849  INLINE rmatrix operator -(const rmatrix &m,const rmatrix_slice &ms)
850 #if(CXSC_INDEX_CHECK)
851 
852 #else
853  noexcept
854 #endif
855  { return _mmsminus<rmatrix,rmatrix_slice,rmatrix>(m,ms); }
856  INLINE rmatrix operator -(const rmatrix_slice &ms,const rmatrix &m)
857 #if(CXSC_INDEX_CHECK)
858 
859 #else
860  noexcept
861 #endif
862  { return _msmminus<rmatrix_slice,rmatrix,rmatrix>(ms,m); }
863  INLINE rmatrix operator -(const rmatrix_slice &ms1,const rmatrix_slice &ms2)
864 #if(CXSC_INDEX_CHECK)
865 
866 #else
867  noexcept
868 #endif
869  { return _msmsminus<rmatrix_slice,rmatrix_slice,rmatrix>(ms1,ms2); }
870  INLINE rmatrix &operator -=(rmatrix &m1,const rmatrix &m2)
871 #if(CXSC_INDEX_CHECK)
872 
873 #else
874  noexcept
875 #endif
876  { return _mmminusassign(m1,m2); }
877  INLINE rmatrix &operator -=(rmatrix &m1,const rmatrix_slice &ms)
878 #if(CXSC_INDEX_CHECK)
879 
880 #else
881  noexcept
882 #endif
883  { return _mmsminusassign(m1,ms); }
884  INLINE rmatrix operator *(const rmatrix &m1, const rmatrix &m2)
885 #if(CXSC_INDEX_CHECK)
886 
887 #else
888  noexcept
889 #endif
890  { return _mmmult<rmatrix,rmatrix,rmatrix>(m1,m2); }
891  INLINE rmatrix operator *(const rmatrix &m1, const rmatrix_slice &ms)
892 #if(CXSC_INDEX_CHECK)
893 
894 #else
895  noexcept
896 #endif
897  { return _mmsmult<rmatrix,rmatrix_slice,rmatrix>(m1,ms); }
898  INLINE rmatrix operator *(const rmatrix_slice &ms, const rmatrix &m1)
899 #if(CXSC_INDEX_CHECK)
900 
901 #else
902  noexcept
903 #endif
904  { return _msmmult<rmatrix_slice,rmatrix,rmatrix>(ms,m1); }
905  INLINE rmatrix operator *(const rmatrix_slice &ms1, const rmatrix_slice &ms2)
906 #if(CXSC_INDEX_CHECK)
907 
908 #else
909  noexcept
910 #endif
911  { return _msmsmult<rmatrix_slice,rmatrix_slice,rmatrix>(ms1,ms2); }
912  INLINE rmatrix &operator *=(rmatrix &m1,const rmatrix &m2)
913 #if(CXSC_INDEX_CHECK)
914 
915 #else
916  noexcept
917 #endif
918  { return _mmmultassign<rmatrix,rmatrix,real>(m1,m2); }
919  INLINE rmatrix &operator *=(rmatrix &m1,const rmatrix_slice &ms)
920 #if(CXSC_INDEX_CHECK)
921 
922 #else
923  noexcept
924 #endif
925  { return _mmsmultassign<rmatrix,rmatrix_slice,real>(m1,ms); }
926  INLINE bool operator ==(const rmatrix &m1,const rmatrix &m2) noexcept { return _mmeq(m1,m2); }
927  INLINE bool operator !=(const rmatrix &m1,const rmatrix &m2) noexcept { return _mmneq(m1,m2); }
928  INLINE bool operator <(const rmatrix &m1,const rmatrix &m2) noexcept { return _mmless(m1,m2); }
929  INLINE bool operator <=(const rmatrix &m1,const rmatrix &m2) noexcept { return _mmleq(m1,m2); }
930  INLINE bool operator >(const rmatrix &m1,const rmatrix &m2) noexcept { return _mmless(m2,m1); }
931  INLINE bool operator >=(const rmatrix &m1,const rmatrix &m2) noexcept { return _mmleq(m2,m1); }
932  INLINE bool operator ==(const rmatrix &m1,const rmatrix_slice &ms) noexcept { return _mmseq(m1,ms); }
933  INLINE bool operator !=(const rmatrix &m1,const rmatrix_slice &ms) noexcept { return _mmsneq(m1,ms); }
934  INLINE bool operator <(const rmatrix &m1,const rmatrix_slice &ms) noexcept { return _mmsless(m1,ms); }
935  INLINE bool operator <=(const rmatrix &m1,const rmatrix_slice &ms) noexcept { return _mmsleq(m1,ms); }
936  INLINE bool operator >(const rmatrix &m1,const rmatrix_slice &ms) noexcept { return _msmless(ms,m1); }
937  INLINE bool operator >=(const rmatrix &m1,const rmatrix_slice &ms) noexcept { return _msmleq(ms,m1); }
938  INLINE bool operator ==(const rmatrix_slice &m1,const rmatrix_slice &m2) noexcept { return _msmseq(m1,m2); }
939  INLINE bool operator !=(const rmatrix_slice &m1,const rmatrix_slice &m2) noexcept { return _msmsneq(m1,m2); }
940  INLINE bool operator <(const rmatrix_slice &m1,const rmatrix_slice &m2) noexcept { return _msmsless(m1,m2); }
941  INLINE bool operator <=(const rmatrix_slice &m1,const rmatrix_slice &m2) noexcept { return _msmsleq(m1,m2); }
942  INLINE bool operator >(const rmatrix_slice &m1,const rmatrix_slice &m2) noexcept { return _msmsless(m2,m1); }
943  INLINE bool operator >=(const rmatrix_slice &m1,const rmatrix_slice &m2) noexcept { return _msmsleq(m2,m1); }
944  INLINE bool operator !(const rmatrix &ms) noexcept { return _mnot(ms); }
945  INLINE bool operator !(const rmatrix_slice &ms) noexcept { return _msnot(ms); }
946  INLINE std::ostream &operator <<(std::ostream &s,const rmatrix &r) noexcept { return _mout(s,r); }
947  INLINE std::ostream &operator <<(std::ostream &s,const rmatrix_slice &r) noexcept { return _msout(s,r); }
948  INLINE std::istream &operator >>(std::istream &s,rmatrix &r) noexcept { return _min(s,r); }
949  INLINE std::istream &operator >>(std::istream &s,rmatrix_slice &r) noexcept { return _msin(s,r); }
950 
952  INLINE rmatrix rmatrix::operator()(const intvector& p, const intvector& q) {
953  rmatrix A(*this);
954  for(int i=0 ; i<ColLen(A) ; i++)
955  for(int j=0 ; j<RowLen(A) ; j++)
956  A[i+Lb(A,1)][j+Lb(A,2)] = (*this)[p[i+Lb(p)]+Lb(A,1)][q[j+Lb(q)]+Lb(A,2)];
957  return A;
958  }
959 
962  rmatrix A(*this);
963  for(int i=0 ; i<ColLen(A) ; i++)
964  A[i+Lb(A,1)] = (*this)[p[i+Lb(p)]+Lb(A,1)];
965  return A;
966  }
967 
970  intvector p = permvec(P);
971  return (*this)(p);
972  }
973 
975  INLINE rmatrix rmatrix::operator()(const intmatrix& P, const intmatrix& Q) {
976  intvector p = permvec(P);
977  intvector q = perminv(permvec(Q));
978  return (*this)(p,q);
979  }
980 
983  intvector p = permvec(P);
984  return (*this)(p);
985  }
986 
987 } // namespace cxsc
988 
989 #endif
990 
The Data Type intmatrix.
Definition: intmatrix.hpp:314
The Data Type intvector.
Definition: intvector.hpp:52
The Scalar Type real.
Definition: real.hpp:114
real(void) noexcept
Constructor of class real.
Definition: real.hpp:122
The Data Type rmatrix_slice.
Definition: rmatrix.hpp:1443
rmatrix_slice & operator=(const srmatrix &m)
Implementation of standard assigning operator.
Definition: srmatrix.hpp:1151
rmatrix_subv operator[](const int &i) const noexcept
Operator for accessing a single row of the matrix.
Definition: rmatrix.inl:242
rmatrix_slice & operator-=(const srmatrix &m)
Implementation of multiplication and allocation operation.
Definition: srmatrix.hpp:1168
rmatrix_slice & operator*=(const srmatrix &m)
Implementation of multiplication and allocation operation.
Definition: srmatrix.hpp:1176
rmatrix_slice & operator+=(const srmatrix &m)
Implementation of multiplication and allocation operation.
Definition: srmatrix.hpp:1160
rmatrix_slice & operator/=(const real &c) noexcept
Implementation of division and allocation operation.
Definition: rmatrix.inl:422
rmatrix_slice & operator()() noexcept
Operator for accessing the whole matrix.
Definition: rmatrix.hpp:2106
The Data Type rmatrix_subv.
Definition: rmatrix.hpp:54
rmatrix_subv & operator()() noexcept
Operator for accessing the whole vector.
Definition: rmatrix.hpp:337
rmatrix_subv & operator+=(const real &c) noexcept
Implementation of addition and allocation operation.
Definition: rmatrix.inl:428
rmatrix_subv & operator=(const rmatrix_subv &rv) noexcept
Implementation of standard assigning operator.
Definition: rmatrix.inl:322
rmatrix_subv & operator/=(const real &c) noexcept
Implementation of division and allocation operation.
Definition: rmatrix.inl:430
rmatrix_subv & operator*=(const real &c) noexcept
Implementation of multiplication and allocation operation.
Definition: rmatrix.inl:427
real & operator[](const int &i) const noexcept
Operator for accessing the single elements of the vector (read-only)
Definition: rmatrix.inl:162
rmatrix_subv & operator-=(const real &c) noexcept
Implementation of subtraction and allocation operation.
Definition: rmatrix.inl:429
The Data Type rmatrix.
Definition: rmatrix.hpp:471
rmatrix_subv operator[](const int &i) const noexcept
Operator for accessing a single row of the matrix.
Definition: rmatrix.inl:190
rmatrix & operator=(const real &r) noexcept
Implementation of standard assigning operator.
Definition: rmatrix.inl:338
rmatrix() noexcept
Constructor of class rmatrix.
Definition: rmatrix.inl:33
rmatrix & operator()() noexcept
Operator for accessing the whole matrix.
Definition: rmatrix.hpp:1416
The Data Type rvector_slice.
Definition: rvector.hpp:1064
rvector_slice & operator=(const rvector_slice &sl) noexcept
Implementation of standard assigning operator.
Definition: rvector.inl:258
rvector_slice & operator*=(const real &r) noexcept
Implementation of multiplication and allocation operation.
Definition: rvector.inl:311
The Data Type rvector.
Definition: rvector.hpp:58
rvector & operator=(const rvector &rv) noexcept
Implementation of standard assigning operator.
Definition: rvector.inl:254
rvector & operator()() noexcept
Operator for accessing the whole vector.
Definition: rvector.hpp:1027
rvector() noexcept
Constructor of class rvector.
Definition: rvector.inl:37
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition: cdot.cpp:29
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.
Definition: cimatrix.inl:1202
rmatrix _rmatrix(const rmatrix &rm) noexcept
Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
Definition: rmatrix.inl:574
civector operator/(const cimatrix_subv &rv, const cinterval &s) noexcept
Implementation of division operation.
Definition: cimatrix.inl:730
cimatrix_subv Row(cimatrix &m, const int &i) noexcept
Returns one row of the matrix as a vector.
Definition: cimatrix.inl:231
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
Definition: cimatrix.inl:1163
cimatrix & SetLb(cimatrix &m, const int &i, const int &j) noexcept
Sets the lower bound index.
Definition: cimatrix.inl:1184
int RowLen(const cimatrix &)
Returns the row dimension.
Definition: cimatrix.inl:1199
cdotprecision & operator+=(cdotprecision &cd, const l_complex &lc) noexcept
Implementation of standard algebraic addition and allocation operation.
Definition: cdot.inl:251
cimatrix & operator*=(cimatrix &m, const cinterval &c) noexcept
Implementation of multiplication and allocation operation.
Definition: cimatrix.inl:1605
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.
Definition: cimatrix.inl:1211
cimatrix & SetUb(cimatrix &m, const int &i, const int &j) noexcept
Sets the upper bound index.
Definition: cimatrix.inl:1191
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.
Definition: cimatrix.inl:1156
cimatrix & operator/=(cimatrix &m, const cinterval &c) noexcept
Implementation of division and allocation operation.
Definition: cimatrix.inl:1623