fmatvec 0.0.0

var_general_matrix.h
1 /* Copyright (C) 2003-2012 Martin Förg
2
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact:
18 * martin.o.foerg@googlemail.com
19 *
20 */
21
22 #ifndef var_general_matrix_h
23 #define var_general_matrix_h
24
25 #include "types.h"
26 #include "range.h"
27 #include "indices.h"
28 #include <cstdlib>
29 #include <stdexcept>
30
31 namespace fmatvec {
32
41 template <class AT> class Matrix<General,Var,Var,AT> {
42
43 public:
44 static constexpr bool isVector {false};
45 using value_type = AT;
46 using shape_type = General;
47
49
50 protected:
51
52 int M{0};
53 int N{0};
54
55 AT *ele;
56
57 template <class Type, class Row, class Col> inline Matrix<General,Var,Var,AT>& copy(const Matrix<Type,Row,Col,AT> &A);
58
60
61 public:
62
67 explicit Matrix() : ele(nullptr) { }
68
69 // Works with -std=gnu++0x only
70 // template<class Ini=All<AT>>
71 // Matrix(int m, int n, Ini ini=All<AT>()) : M(m), N(n), ele(new AT[M*N]) {
72 // init(ini);
73 // }
74
75 explicit Matrix(int m, int n, Noinit) : M(m), N(n), ele(new AT[M*N]) { }
76 explicit Matrix(int m, int n, Init ini=INIT, const AT &a=AT()) : M(m), N(n), ele(new AT[M*N]) { init(a); }
77 explicit Matrix(int m, int n, Eye ini, const AT &a=1) : M(m), N(n), ele(new AT[M*N]) { init(ini,a); }
78
79 // move
80 Matrix(Matrix<General,Var,Var,AT> &&src) noexcept {
81 M=src.M;
82 src.M=0;
83 N=src.N;
84 src.N=0;
85 ele=src.ele;
86 src.ele=nullptr;
87 }
88 Matrix<General,Var,Var,AT>& operator=(Matrix<General,Var,Var,AT> &&src) noexcept {
89 FMATVEC_ASSERT(M == src.rows(), AT);
90 FMATVEC_ASSERT(N == src.cols(), AT);
91 src.M=0;
92 src.N=0;
93 delete[]ele;
94 ele=src.ele;
95 src.ele=nullptr;
96 return *this;
97 }
98
104 Matrix(const Matrix<General,Var,Var,AT> &A) : M(A.M), N(A.N), ele(new AT[M*N]) {
105 copy(A);
106 }
107
113 template<class Row, class Col>
114 Matrix(const Matrix<General,Row,Col,AT> &A) : M(A.rows()), N(A.cols()), ele(new AT[M*N]) {
115 copy(A);
116 }
117
123 template<class Type, class Row, class Col>
124 explicit Matrix(const Matrix<Type,Row,Col,AT> &A) : M(A.rows()), N(A.cols()), ele(new AT[M*N]) {
125 copy(A);
126 }
127
140 Matrix(const std::string &strs);
141 Matrix(const char *strs);
142
145 ~Matrix() {
146 delete[] ele;
147 }
148
149 using iterator = AT *;
150 using const_iterator = const AT *;
151 iterator begin() { return &ele[0]; }
152 iterator end() { return &ele[M*N]; }
153 const_iterator begin() const { return &ele[0]; }
154 const_iterator end() const { return &ele[M*N]; }
155
156 Matrix<General,Var,Var,AT>& resize(int m, int n, Noinit) {
157 delete[] ele;
158 M = m;
159 N = n;
160 ele = new AT[M*N];
161 return *this;
162 }
163
164 Matrix<General,Var,Var,AT>& resize(int m, int n, Init ini=INIT, const AT &a=AT()) { return resize(m,n,Noinit()).init(a); }
165
166 Matrix<General,Var,Var,AT>& resize(int m, int n, Eye ini, const AT &a=1) { return resize(m,n,Noinit()).init(ini,a); }
167
174 inline Matrix<General,Var,Var,AT>& operator=(const Matrix<General,Var,Var,AT> &A) {
175 FMATVEC_ASSERT(M == A.rows(), AT);
176 FMATVEC_ASSERT(N == A.cols(), AT);
177 return copy(A);
178 }
179
186 template <class Type, class Row, class Col>
187 inline Matrix<General,Var,Var,AT>& operator=(const Matrix<Type,Row,Col,AT> &A) {
188 FMATVEC_ASSERT(M == A.rows(), AT);
189 FMATVEC_ASSERT(N == A.cols(), AT);
190 return copy(A);
191 }
192
199 template<class Type, class Row, class Col>
200 inline Matrix<General,Var,Var,AT>& operator<<=(const Matrix<Type,Row,Col,AT> &A) {
201 if(M!=A.rows() || N!=A.cols()) resize(A.rows(),A.cols(),NONINIT);
202 return copy(A);
203 }
204 // move
205 inline Matrix<General,Var,Var,AT>& operator<<=(Matrix<General,Var,Var,AT> &&src) {
206 M=src.M;
207 src.M=0;
208 N=src.N;
209 src.N=0;
210 delete[]ele;
211 ele=src.ele;
212 src.ele=nullptr;
213 return *this;
214 }
215
216 template <class AT2>
217 operator Matrix<General,Var,Var,AT2>() const {
218 Matrix<General,Var,Var,AT2> ret(rows(), cols());
219 for(size_t r=0; r<rows(); ++r)
220 for(size_t c=0; c<cols(); ++c)
221 ret(r,c) = (*this)(r,c);
222 return ret;
223 }
224
234 AT& operator()(int i, int j) {
235 FMATVEC_ASSERT(i>=0, AT);
236 FMATVEC_ASSERT(j>=0, AT);
237 FMATVEC_ASSERT(i<M, AT);
238 FMATVEC_ASSERT(j<N, AT);
239
240 return e(i,j);
241 }
242
247 const AT& operator()(int i, int j) const {
248 FMATVEC_ASSERT(i>=0, AT);
249 FMATVEC_ASSERT(j>=0, AT);
250 FMATVEC_ASSERT(i<M, AT);
251 FMATVEC_ASSERT(j<N, AT);
252
253 return e(i,j);
254 }
255
256 AT& e(int i, int j) {
257 return ele[i*N+j];
258 }
259
264 const AT& e(int i, int j) const {
265 return ele[i*N+j];
266 }
267
268 AT& e(int i) {
269 return ele[i];
270 }
271
276 const AT& e(int i) const {
277 return ele[i];
278 }
279
285 AT* operator()() {return ele;}
286
291 const AT* operator()() const {return ele;}
292
297 constexpr int rows() const {return M;}
298
303 constexpr int cols() const {return N;}
304
309 int ldim() const {return N;}
310
317 const CBLAS_TRANSPOSE blasTrans() const {
318 return CblasNoTrans;
319 }
320
328 const CBLAS_ORDER blasOrder() const {
329 return CblasRowMajor;
330 }
331
336 inline const Matrix<General,Var,Var,AT> operator()(const Range<Var,Var> &I, const Range<Var,Var> &J) const;
337
338 template <int M1, int M2, int N1, int N2>
339 inline const Matrix<General,Fixed<M2-M1+1>,Fixed<N2-N1+1>,AT> operator()(const Range<Fixed<M1>,Fixed<M2>> &I, const Range<Fixed<N1>,Fixed<N2>> &J) const;
340
341 template <int M1, int M2>
342 inline const Matrix<General,Fixed<M2-M1+1>,Var,AT> operator()(const Range<Fixed<M1>,Fixed<M2>> &I, const Range<Var,Var > &J) const;
343
344 template <int N1, int N2>
345 inline const Matrix<General,Var,Fixed<N2-N1+1>,AT> operator()(const Range<Var,Var> &I, const Range<Fixed<N1>,Fixed<N2>> &J) const;
346
347 inline const RowVector<Var,AT> row(int i) const;
348 inline const Vector<Var,AT> col(int j) const;
349
357 inline Matrix<General,Var,Var,AT>& init(const AT &val=AT());
358 inline Matrix<General,Var,Var,AT>& init(Init all, const AT &a=AT()) { return init(a); }
359 inline Matrix<General,Var,Var,AT>& init(Eye eye, const AT &val=1);
360 inline Matrix<General,Var,Var,AT>& init(Noinit, const AT &a=AT()) { return *this; }
361
366 explicit inline operator std::vector<std::vector<AT>>() const;
367
373 explicit inline Matrix(const std::vector<std::vector<AT>> &m);
374
375 // /*! \brief Cast to AT.
376 // *
377 // * \return The AT representation of the matrix
378 // * */
379 // explicit operator AT() const {
380 // FMATVEC_ASSERT(M==1, AT);
381 // FMATVEC_ASSERT(N==1, AT);
382 // return ele[0];
383 // }
384 //
385 // /*! \brief AT Constructor.
386 // * Constructs and initializes a matrix with a AT object.
387 // * \param x The AT the matrix will be initialized with.
388 // * */
389 // explicit Matrix(const AT &x) : M(1), N(1), ele(new AT[1]) { ele[0] = x; }
390
391 inline const Matrix<General,Var,Var,AT> T() const;
392
393 template<class Row> inline void set(int j, const Vector<Row,AT> &x);
394
395 template<class Col> inline void set(int i, const RowVector<Col,AT> &x);
396
397 template<class Type, class Row, class Col> inline void set(const Range<Var,Var> &I, const Range<Var,Var> &J, const Matrix<Type,Row,Col,AT> &A);
398
399 template<class Row> inline void add(int j, const Vector<Row,AT> &x);
400
401 template<class Col> inline void add(int i, const RowVector<Col,AT> &x);
402
403 template<class Type, class Row, class Col> inline void add(const Range<Var,Var> &I, const Range<Var,Var> &J, const Matrix<Type,Row,Col,AT> &A);
404
405 inline const Matrix<General,Var,Var,AT> operator()(const Indices &I, const Indices &J) const;
406
407 inline const Matrix<General,Var,Var,AT> operator()(const Range<Var,Var> &I, const Indices &J) const;
408
409 inline const Matrix<General,Var,Var,AT> operator()(const Indices &I, const Range<Var,Var> &J) const;
410
411 template<class Row> inline void set(const Indices &I, int j, const Vector<Row,AT> &x);
412
413 template<class Type, class Row, class Col> inline void set(const Indices &I, const Indices &J, const Matrix<Type,Row,Col,AT> &A);
414
415 template<class Type, class Row, class Col> inline void set(const Range<Var,Var> &I, const Indices &J, const Matrix<Type,Row,Col,AT> &A);
416
417 template<class Type, class Row, class Col> inline void set(const Indices &I, const Range<Var,Var> &J, const Matrix<Type,Row,Col,AT> &A);
418 };
419
420 template <class AT>
421 Matrix<General,Var,Var,AT>::Matrix(const std::string &strs) : ele(nullptr) {
422 std::istringstream iss(strs);
423 iss>>*this;
424
425 // check end of stream
426 iss>>std::ws;
427 if(!iss.eof())
428 throw std::runtime_error("Input not fully read.");
429 }
430 template <class AT> Matrix<General,Var,Var,AT>::Matrix(const char *strs) : Matrix<General,Var,Var,AT>::Matrix(std::string(strs)) {}
431
432 template <class AT>
433 inline Matrix<General,Var,Var,AT>& Matrix<General,Var,Var,AT>::init(const AT &val) {
434 for(int i=0; i<M*N; i++)
435 e(i) = val;
436 return *this;
437 }
438
439 template <class AT>
440 inline Matrix<General,Var,Var,AT>& Matrix<General,Var,Var,AT>::init(Eye eye, const AT &val) {
441 for(int i=0; i<M; i++)
442 for(int j=0; j<N; j++)
443 e(i,j) = (i==j) ? val : 0;
444 return *this;
445 }
446
447 template <class AT>
448 inline const Matrix<General,Var,Var,AT> Matrix<General,Var,Var,AT>::operator()(const Range<Var,Var> &I, const Range<Var,Var> &J) const {
449 FMATVEC_ASSERT(I.end()<M, AT);
450 FMATVEC_ASSERT(J.end()<N, AT);
451 Matrix<General,Var,Var,AT> A(I.size(),J.size(),NONINIT);
452
453 for(int i=0; i<A.rows(); i++)
454 for(int j=0; j<A.cols(); j++)
455 A.e(i,j) = e(I.start()+i,J.start()+j);
456
457 return A;
458 }
459
460 template <class AT> template <int M1, int M2, int N1, int N2>
461 inline const Matrix<General,Fixed<M2-M1+1>,Fixed<N2-N1+1>,AT> Matrix<General,Var,Var,AT>::operator()(const Range<Fixed<M1>,Fixed<M2>> &I, const Range<Fixed<N1>,Fixed<N2>> &J) const {
462 FMATVEC_ASSERT(M2<M, AT);
463 FMATVEC_ASSERT(N2<N, AT);
464 Matrix<General,Fixed<M2-M1+1>,Fixed<N2-N1+1>,AT> A(NONINIT);
465
466 for(int i=0; i<A.rows(); i++)
467 for(int j=0; j<A.cols(); j++)
468 A.e(i,j) = e(I.start()+i,J.start()+j);
469
470 return A;
471 }
472
473 template <class AT> template <int M1, int M2>
474 inline const Matrix<General,Fixed<M2-M1+1>,Var,AT> Matrix<General,Var,Var,AT>::operator()(const Range<Fixed<M1>,Fixed<M2>> &I, const Range<Var,Var> &J) const {
475 FMATVEC_ASSERT(M2<M, AT);
476 FMATVEC_ASSERT(J.end()<N, AT);
477 Matrix<General,Fixed<M2-M1+1>,Var,AT> A(J.size(),NONINIT);
478
479 for(int i=0; i<A.rows(); i++)
480 for(int j=0; j<A.cols(); j++)
481 A.e(i,j) = e(I.start()+i,J.start()+j);
482
483 return A;
484 }
485
486 template <class AT> template <int N1, int N2>
487 inline const Matrix<General,Var,Fixed<N2-N1+1>,AT> Matrix<General,Var,Var,AT>::operator()(const Range<Var,Var> &I, const Range<Fixed<N1>,Fixed<N2>> &J) const {
488 FMATVEC_ASSERT(I.end()<M, AT);
489 FMATVEC_ASSERT(N2<N, AT);
490 Matrix<General,Var,Fixed<N2-N1+1>,AT> A(I.size(),NONINIT);
491
492 for(int i=0; i<A.rows(); i++)
493 for(int j=0; j<A.cols(); j++)
494 A.e(i,j) = e(I.start()+i,J.start()+j);
495
496 return A;
497 }
498
499 template <class AT>
500 inline const RowVector<Var,AT> Matrix<General,Var,Var,AT>::row(int i) const {
501
502 FMATVEC_ASSERT(i>=0, AT);
503 FMATVEC_ASSERT(i<M, AT);
504
505 RowVector<Var,AT> x(N,NONINIT);
506
507 for(int j=0; j<N; j++)
508 x.e(j) = e(i,j);
509
510 return x;
511 }
512
513 template <class AT>
514 inline const Vector<Var,AT> Matrix<General,Var,Var,AT>::col(int j) const {
515
516 FMATVEC_ASSERT(j>=0, AT);
517 FMATVEC_ASSERT(j<N, AT);
518
519 Vector<Var,AT> x(M,NONINIT);
520
521 for(int i=0; i<M; i++)
522 x.e(i) = e(i,j);
523
524 return x;
525 }
526
527 template <class AT>
528 inline const Matrix<General,Var,Var,AT> Matrix<General,Var,Var,AT>::T() const {
529 Matrix<General,Var,Var,AT> A(N,M,NONINIT);
530 for(int i=0; i<N; i++)
531 for(int j=0; j<M; j++)
532 A.e(i,j) = e(j,i);
533 return A;
534 }
535
536 template <class AT> template <class Row>
537 inline void Matrix<General,Var,Var,AT>::set(int j, const Vector<Row,AT> &x) {
538 FMATVEC_ASSERT(j<cols(), AT);
539 FMATVEC_ASSERT(rows()==x.size(), AT);
540 for(int i=0; i<rows(); i++)
541 e(i,j) = x.e(i);
542 }
543
544 template <class AT> template <class Col>
545 inline void Matrix<General,Var,Var,AT>::set(int i, const RowVector<Col,AT> &x) {
546 FMATVEC_ASSERT(i<rows(), AT);
547 FMATVEC_ASSERT(cols()==x.size(), AT);
548 for(int j=0; j<cols(); j++)
549 e(i,j) = x.e(j);
550 }
551
552 template <class AT> template<class Type, class Row, class Col>
553 inline void Matrix<General,Var,Var,AT>::set(const Range<Var,Var> &I, const Range<Var,Var> &J, const Matrix<Type,Row,Col,AT> &A) {
554
555 FMATVEC_ASSERT(I.end()<rows(), AT);
556 FMATVEC_ASSERT(J.end()<cols(), AT);
557 FMATVEC_ASSERT(I.size()==A.rows(), AT);
558 FMATVEC_ASSERT(J.size()==A.cols(), AT);
559
560 for(int i=I.start(), ii=0; i<=I.end(); i++, ii++)
561 for(int j=J.start(), jj=0; j<=J.end(); j++, jj++)
562 e(i,j) = A.e(ii,jj);
563 }
564
565 template <class AT> template <class Row>
566 inline void Matrix<General,Var,Var,AT>::add(int j, const Vector<Row,AT> &x) {
567 FMATVEC_ASSERT(j<cols(), AT);
568 FMATVEC_ASSERT(rows()==x.size(), AT);
569 for(int i=0; i<rows(); i++)
570 e(i,j) += x.e(i);
571 }
572
573 template <class AT> template <class Col>
574 inline void Matrix<General,Var,Var,AT>::add(int i, const RowVector<Col,AT> &x) {
575 FMATVEC_ASSERT(i<rows(), AT);
576 FMATVEC_ASSERT(cols()==x.size(), AT);
577 for(int j=0; j<cols(); j++)
578 e(i,j) += x.e(j);
579 }
580
581 template <class AT> template<class Type, class Row, class Col>
582 inline void Matrix<General,Var,Var,AT>::add(const Range<Var,Var> &I, const Range<Var,Var> &J, const Matrix<Type,Row,Col,AT> &A) {
583
584 FMATVEC_ASSERT(I.end()<rows(), AT);
585 FMATVEC_ASSERT(J.end()<cols(), AT);
586 FMATVEC_ASSERT(I.size()==A.rows(), AT);
587 FMATVEC_ASSERT(J.size()==A.cols(), AT);
588
589 for(int i=I.start(), ii=0; i<=I.end(); i++, ii++)
590 for(int j=J.start(), jj=0; j<=J.end(); j++, jj++)
591 e(i,j) += A.e(ii,jj);
592 }
593
594 template <class AT>
595 inline const Matrix<General,Var,Var,AT> Matrix<General,Var,Var,AT>::operator()(const Indices &I, const Indices &J) const {
596 FMATVEC_ASSERT(I.max()<rows(), AT);
597 FMATVEC_ASSERT(J.max()<cols(), AT);
598
599 Matrix<General,Var,Var,AT> A(I.size(),J.size(),NONINIT);
600
601 for(int i=0; i<A.rows(); i++)
602 for(int j=0; j<A.cols(); j++)
603 A.e(i,j) = e(I[i],J[j]);
604
605 return A;
606 }
607
608 template <class AT>
609 inline const Matrix<General,Var,Var,AT> Matrix<General,Var,Var,AT>::operator()(const Range<Var,Var> &I, const Indices &J) const {
610 FMATVEC_ASSERT(I.end()<M, AT);
611 FMATVEC_ASSERT(J.max()<cols(), AT);
612
613 Matrix<General,Var,Var,AT> A(I.size(),J.size(),NONINIT);
614
615 for(int i=0; i<A.rows(); i++)
616 for(int j=0; j<A.cols(); j++)
617 A.e(i,j) = e(I.start()+i,J[j]);
618
619 return A;
620 }
621
622 template <class AT>
623 inline const Matrix<General,Var,Var,AT> Matrix<General,Var,Var,AT>::operator()(const Indices &I, const Range<Var,Var> &J) const {
624 FMATVEC_ASSERT(I.max()<rows(), AT);
625 FMATVEC_ASSERT(J.end()<N, AT);
626
627 Matrix<General,Var,Var,AT> A(I.size(),J.size(),NONINIT);
628
629 for(int i=0; i<A.rows(); i++)
630 for(int j=0; j<A.cols(); j++)
631 A.e(i,j) = e(I[i],J.start()+j);
632
633 return A;
634 }
635
636 template <class AT> template<class Row>
637 inline void Matrix<General,Var,Var,AT>::set(const Indices &I, int j, const Vector<Row,AT> &x) {
638 FMATVEC_ASSERT(I.max()<rows(), AT);
639 FMATVEC_ASSERT(j<cols(), AT);
640 FMATVEC_ASSERT(I.size()==x.size(), AT);
641 for(int i=0; i<I.size(); i++)
642 e(I[i],j) = x.e(i);
643 }
644
645 template <class AT> template <class Type, class Row, class Col>
646 inline void Matrix<General,Var,Var,AT>::set(const Indices &I, const Indices &J, const Matrix<Type,Row,Col,AT> &A) {
647 FMATVEC_ASSERT(I.max()<rows(), AT);
648 FMATVEC_ASSERT(J.max()<cols(), AT);
649 FMATVEC_ASSERT(I.size()==A.rows(), AT);
650 FMATVEC_ASSERT(J.size()==A.cols(), AT);
651 for(int i=0; i<I.size(); i++)
652 for(int j=0; j<J.size(); j++)
653 e(I[i],J[j]) = A.e(i,j);
654 }
655
656 template <class AT> template <class Type, class Row, class Col>
657 inline void Matrix<General,Var,Var,AT>::set(const Range<Var,Var> &I, const Indices &J, const Matrix<Type,Row,Col,AT> &A) {
658 FMATVEC_ASSERT(I.end()<rows(), AT);
659 FMATVEC_ASSERT(J.max()<cols(), AT);
660 FMATVEC_ASSERT(I.size()==A.rows(), AT);
661 FMATVEC_ASSERT(J.size()==A.cols(), AT);
662 for(int i=I.start(), ii=0; i<=I.end(); i++, ii++)
663 for(int j=0; j<J.size(); j++)
664 e(i,J[j]) = A.e(ii,j);
665 }
666
667 template <class AT> template <class Type, class Row, class Col>
668 inline void Matrix<General,Var,Var,AT>::set(const Indices &I, const Range<Var,Var> &J, const Matrix<Type,Row,Col,AT> &A) {
669 FMATVEC_ASSERT(I.max()<rows(), AT);
670 FMATVEC_ASSERT(J.end()<cols(), AT);
671 FMATVEC_ASSERT(I.size()==A.rows(), AT);
672 FMATVEC_ASSERT(J.size()==A.cols(), AT);
673 for(int i=0; i<I.size(); i++)
674 for(int j=J.start(), jj=0; j<=J.end(); j++, jj++)
675 e(I[i],j) = A.e(i,jj);
676 }
677
678 template <class AT>
679 inline Matrix<General,Var,Var,AT>::operator std::vector<std::vector<AT>>() const {
680 std::vector<std::vector<AT>> ret(rows(),std::vector<AT>(cols()));
681 for(int r=0; r<rows(); r++) {
682 for(int c=0; c<cols(); c++)
683 ret[r][c]=e(r,c);
684 }
685 return ret;
686 }
687
688 template <class AT>
689 inline Matrix<General,Var,Var,AT>::Matrix(const std::vector<std::vector<AT>> &m) : M(static_cast<int>(m.size())), N(static_cast<int>(m[0].size())), ele(new AT[M*N]) {
690 for(int r=0; r<rows(); r++) {
691 if(static_cast<int>(m[r].size())!=cols())
692 throw std::runtime_error("The rows of the input have different length.");
693 for(int c=0; c<cols(); c++)
694 e(r,c)=m[r][c];
695 }
696 }
697
699
700 template <class AT> template <class Type, class Row, class Col>
701 inline Matrix<General,Var,Var,AT>& Matrix<General,Var,Var,AT>::copy(const Matrix<Type,Row,Col,AT> &A) {
702 for(int i=0; i<M; i++)
703 for(int j=0; j<N; j++)
704 e(i,j) = A.e(i,j);
705 return *this;
706 }
707
709
710 }
711
712 #endif
fmatvec::Matrix< General, Var, Var, AT >::rows
constexpr int rows() const
Number of rows.
Definition: var_general_matrix.h:297
fmatvec::Range< Var, Var >::end
int end() const
Last element.
Definition: range.h:91
fmatvec::Fixed
Definition: fmatvec.h:39
fmatvec::Matrix< General, Var, Var, AT >::Matrix
Matrix(const Matrix< Type, Row, Col, AT > &A)
Copy Constructor.
Definition: var_general_matrix.h:124
fmatvec::Matrix
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:42
fmatvec::Matrix< General, Var, Var, AT >::~Matrix
~Matrix()
Destructor.
Definition: var_general_matrix.h:145
fmatvec::Matrix< General, Var, Var, AT >::operator=
Matrix< General, Var, Var, AT > & operator=(const Matrix< General, Var, Var, AT > &A)
Assignment operator.
Definition: var_general_matrix.h:174
fmatvec::Vector< Var, AT >
This is a vector class of general shape in dense storage format.
Definition: var_vector.h:39
fmatvec::Matrix< General, Var, Var, AT >
This is a matrix class for general matrices.
Definition: var_general_matrix.h:41
fmatvec::Matrix< General, Var, Var, AT >::operator()
AT & operator()(int i, int j)
Element operator.
Definition: var_general_matrix.h:234
fmatvec::Matrix::operator()
AT & operator()(int i, int j)
Standard constructor.
Definition: matrix.h:84
fmatvec::Init
Definition: types.h:89
fmatvec::Matrix< General, Var, Var, AT >::operator=
Matrix< General, Var, Var, AT > & operator=(const Matrix< Type, Row, Col, AT > &A)
Assignment operator.
Definition: var_general_matrix.h:187
fmatvec::Var
Definition: types.h:101
fmatvec::Matrix< General, Var, Var, AT >::Matrix
Matrix(const Matrix< General, Row, Col, AT > &A)
Copy Constructor.
Definition: var_general_matrix.h:114
fmatvec::Matrix< General, Var, Var, AT >::cols
constexpr int cols() const
Number of columns.
Definition: var_general_matrix.h:303
fmatvec::Matrix< General, Var, Var, AT >::operator()
const AT & operator()(int i, int j) const
Element operator.
Definition: var_general_matrix.h:247
fmatvec::Range< Var, Var >::start
int start() const
First element.
Definition: range.h:85
fmatvec::Vector
Definition: fmatvec.h:48
fmatvec::Matrix::cols
int cols() const
Number of columns.
fmatvec::Matrix< General, Var, Var, AT >::Matrix
Matrix()
Standard constructor.
Definition: var_general_matrix.h:67
fmatvec::Matrix< General, Var, Var, AT >::e
const AT & e(int i, int j) const
Element operator.
Definition: var_general_matrix.h:264
fmatvec::Matrix< General, Var, Var, AT >::Matrix
Matrix(const Matrix< General, Var, Var, AT > &A)
Copy Constructor.
Definition: var_general_matrix.h:104
fmatvec::Range
This is an index class for creating submatrices.
Definition: range.h:35
fmatvec
Namespace fmatvec.
Definition: _memory.cc:28
fmatvec::Matrix< General, Var, Var, AT >::operator()
AT * operator()()
Pointer operator.
Definition: var_general_matrix.h:285
fmatvec::Range< Var, Var >::size
int size() const
Size.
Definition: range.h:97
fmatvec::Matrix< General, Var, Var, AT >::blasTrans
const CBLAS_TRANSPOSE blasTrans() const
Transposed status.
Definition: var_general_matrix.h:317
fmatvec::Noinit
Definition: types.h:88
fmatvec::Matrix< General, Var, Var, AT >::ldim
int ldim() const
Leading dimension.
Definition: var_general_matrix.h:309
fmatvec::General
Shape class for general matrices.
Definition: types.h:112
fmatvec::Matrix< General, Var, Var, AT >::operator()
const AT * operator()() const
Pointer operator.
Definition: var_general_matrix.h:291
fmatvec::Matrix< General, Var, Var, AT >::blasOrder
const CBLAS_ORDER blasOrder() const
Storage convention.
Definition: var_general_matrix.h:328
fmatvec::Matrix::rows
int rows() const
Number of rows.
fmatvec::Range< Var, Var >
This is an index class for creating submatrices.
Definition: range.h:44
fmatvec::Matrix< General, Var, Var, AT >::e
const AT & e(int i) const
Element operator.
Definition: var_general_matrix.h:276
fmatvec::RowVector< Var, AT >
This is a vector class of general shape in dense storage format.
Definition: var_row_vector.h:39
fmatvec::Eye
Definition: types.h:90