DACE 2.0 API Manual
Differential Algebra Core Engine
AlgebraicMatrix_t.h
Go to the documentation of this file.
1 /******************************************************************************
2 * *
3 * DIFFERENTIAL ALGEBRA CORE ENGINE *
4 * *
5 *******************************************************************************
6 * *
7 * Copyright 2016 Politecnico di Milano (2014 Dinamica Srl) *
8 * Licensed under the Apache License, Version 2.0 (the "License"); *
9 * you may not use this file except in compliance with the License. *
10 * You may obtain a copy of the License at *
11 * *
12 * http://www.apache.org/licenses/LICENSE-2.0 *
13 * *
14 * Unless required by applicable law or agreed to in writing, software *
15 * distributed under the License is distributed on an "AS IS" BASIS, *
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
17 * See the License for the specific language governing permissions and *
18 * limitations under the License. *
19 * *
20 *******************************************************************************/
21 
22 /*
23  * AlgebraicMatrix_t.h
24  *
25  * Created on: July 17, 2014
26  * Author: Dinamica Srl
27  */
28 
29 #ifndef DINAMICA_DAMATRIX_T_H_
30 #define DINAMICA_DAMATRIX_T_H_
31 
32 // C++ stdlib classes used only internally in this implementation
33 #include <cmath>
34 #include <sstream>
35 #include <stdexcept>
36 #include <algorithm>
37 #include <string>
38 
39 // DACE classes
40 #include "dace/PromotionTrait.h"
41 #include "dace/AlgebraicVector.h"
42 #include "dace/AlgebraicMatrix.h"
43 
44 namespace DACE{
45 
53  // Check that vector length and number of rows of matrix are equal
54  if (obj1.size()!=obj2.nrows())
55  throw std::runtime_error("DACE::AlgebraicMatrix<T>::operator*: objects in vector/matrix multiplication must have compatible size.");
56 
58 
59  for(unsigned int i=0; i<obj2.ncols(); i++){
60  temp[i] = 0.;
61  for (unsigned int j=0; j<obj2.nrows();j++)
62  temp[i] += obj1[j]*obj2.at(j,i);
63  }
64 
65  return temp;
66 }
67 
75  // Check that vector length and number of columns of matrix are equal
76  if (obj1.ncols()!=obj2.size())
77  throw std::runtime_error("DACE::AlgebraicMatrix<T>::operator*: objects in vector/matrix multiplication must have compatible size.");
78 
80 
81  for(unsigned int i=0; i<obj1.nrows(); i++){
82  temp[i] = 0.;
83  for (unsigned int j=0; j<obj1.ncols();j++)
84  temp[i] += obj1.at(i,j)*obj2[j];
85  }
86 
87  return temp;
88 }
89 
90 template<class T> void AlgebraicMatrix<T>::resize(int size) {
96  // store initial data
97  unsigned int oldrows = this->nrows();
98  unsigned int oldcols = this->ncols();
99 
100  std::vector<T> temp(this->_data);
101 
102  this->_nrows = size;
103  this->_ncols = size;
104  this->_data.resize(size*size);
105 
106  // Sort old values to keep same position of original matrix
107  for(unsigned int irow=0; irow<(unsigned)size; irow++)
108  for(unsigned int icol=0; icol<(unsigned)size; icol++)
109  if ((irow<oldrows)&&(icol<oldcols))
110  this->_data[irow*this->_ncols + icol] = temp[irow*oldcols+icol];
111  else
112  this->_data[irow*this->_ncols + icol] = 0.;
113 }
114 
115 template<class T> void AlgebraicMatrix<T>::resize(int rows, int cols) {
122  // store initial data
123  unsigned int oldrows = this->nrows();
124  unsigned int oldcols = this->ncols();
125  std::vector<T> temp(this->_data);
126 
127  this->_nrows = rows;
128  this->_ncols = cols;
129  this->_data.resize(rows * cols);
130 
131  // Sort old values to keep same position of original matrix
132  for(unsigned int irow=0; irow<(unsigned)rows; irow++)
133  for(unsigned int icol=0; icol<(unsigned)cols; icol++)
134  if ((irow<oldrows)&&(icol<oldcols))
135  this->_data[irow*cols + icol] = temp[irow*oldcols+icol];
136  else
137  this->_data[irow*cols + icol] = 0.;
138 }
139 
140 /***********************************************************************************
141 * Element access routines
142 ************************************************************************************/
143 template<class T> T& AlgebraicMatrix<T>::at(const unsigned int irow, const unsigned int icol) {
150  if ( !(irow<(this->_nrows) )&&!( icol<(this->_ncols) ))
151  throw std::runtime_error("DACE::AlgebraicMatrix<T>::at: matrix element position out of bound.");
152 
153  return this->_data[irow*this->_ncols + icol];
154 }
155 
156 template<class T> const T& AlgebraicMatrix<T>::at(const unsigned int irow, const unsigned int icol) const {
163  if ( !(irow<(this->_nrows) )&&!( icol<(this->_ncols)) )
164  throw std::runtime_error("DACE::AlgebraicMatrix<T>::at: matrix element position out of bound.");
165 
166  return this->_data[irow*this->_ncols + icol];
167 }
168 
169 template<class T> std::vector<T> AlgebraicMatrix<T>::getrow(const unsigned int irow) const {
176  // check that desired row is within matrix bounds
177  if( !(irow<(this->_nrows)) )
178  throw std::runtime_error("DACE::AlgebraicMatrix<T>::row: row out of bound.");
179 
180  // Declare a vector with length equal to number of columns of the matrix
181  std::vector<T> temp(this->_ncols);
182 
183  // Extract row and store elements into vector
184  for(unsigned int i=0; i<(this->_ncols); i++)
185  {
186  temp[i] = this->_data[irow*this->_ncols+i];
187  }
188 
189  return temp;
190 }
191 
192 template<class T> std::vector<T> AlgebraicMatrix<T>::getcol(const unsigned int icol) const {
199  // check that desired column is within matrix bounds
200  if( !(icol<(this->_ncols)) )
201  throw std::runtime_error("DACE::AlgebraicMatrix<T>::col: column out of bound.");
202 
203  // Declare a vector with length equal to number of rows of the matrix
204  std::vector<T> temp(this->_nrows);
205 
206  // Extract column and store elements into vector
207  for(unsigned int i=0; i<(this->_nrows); i++)
208  {
209  temp[i] = this->_data[i*this->_ncols+icol];
210  }
211 
212  return temp;
213 }
214 
215 template<class T> void AlgebraicMatrix<T>::setrow(const unsigned int irow, const std::vector< T >& obj) {
221  // check that length of vector and number of columns match
222  if (obj.size()!=this->_ncols)
223  throw std::runtime_error("DACE::AlgebraicMatrix<T>::setrow: vector too large to be stored in matrix.");
224 
225  // Insert elements at desired row
226  for(unsigned int j=0; j<(this->_ncols); j++)
227  this->_data[irow*this->_ncols+j] = obj[j];
228 }
229 
230 template<class T> void AlgebraicMatrix<T>::setcol(const unsigned int icol, const std::vector< T >& obj) {
236  // check that length of vector and number of rows match
237  if (obj.size()!=this->_nrows)
238  throw std::runtime_error("DACE::AlgebraicMatrix<T>::setcol: vector too large to be stored in matrix.");
239 
240  // Insert elements at desired column
241  for(unsigned int i=0; i<(this->_nrows); i++)
242  this->_data[i*this->_ncols+icol] = obj[i];
243 }
244 
245 template<class T> AlgebraicMatrix<T> AlgebraicMatrix<T>::submat(const unsigned int first_row, const unsigned int first_col, const unsigned int last_row, const unsigned int last_col) const {
254  // Check that desired last_row and last_col are actually larger than first_row and first_col
255  if( (last_row<first_row)||(last_col<first_col) )
256  throw std::runtime_error("DACE::AlgebraicMatrix<T>::submat: first row/column index larger than last row/column index.");
257 
258  // Check that desired submatrix can be extracted from original matrix
259  if( !(last_row<(this->_nrows))||!(last_col<(this->_ncols)) )
260  throw std::runtime_error("DACE::AlgebraicMatrix<T>::submat: last row/column index exceeds number of rows/columns.");
261 
262  unsigned int nrows = last_row-first_row+1;
263  unsigned int ncols = last_col-first_col+1;
264 
265  // Declare temporary matrix for output
266  AlgebraicMatrix<T> temp(nrows, ncols);
267 
268  for (unsigned int i=0; i<nrows; i++)
269  for (unsigned int j=0; j<ncols; j++)
270  temp.at(i,j) = this->at(i+first_row,j+first_col);
271 
272  return temp;
273 }
274 
275 template<class T> AlgebraicMatrix<T> AlgebraicMatrix<T>::submat(const unsigned int last_row, const unsigned int last_col) const {
283  return this->submat(0,0,last_row,last_col);
284 }
285 
286 /***********************************************************************************
287 * Algebraic operations
288 ************************************************************************************/
296  // check that the two matrices have the same size
297  if((obj1.ncols()!=obj2.ncols())||(obj1.nrows()!=obj2.nrows()))
298  throw std::runtime_error("DACE::AlgebraicMatrix<T>::operator+: Inputs must have the same size, unless one is a scalar value.");
299 
300  unsigned int n_rows = obj1.nrows();
301  unsigned int n_cols = obj1.ncols();
302 
304 
305  for (unsigned int i=0; i<n_rows; i++)
306  for (unsigned int j=0; j<n_cols; j++)
307  temp.at(i,j) = obj1.at(i,j) + obj2.at(i,j);
308 
309  return temp;
310 }
311 
312 template<typename U,typename V> AlgebraicMatrix<typename PromotionTrait< U, V >::returnType> operator+( const AlgebraicMatrix<U> &obj1, const V &obj2 ) {
319  unsigned int n_rows = obj1.nrows();
320  unsigned int n_cols = obj1.ncols();
321 
323 
324  for (unsigned int i=0; i<n_rows; i++)
325  for (unsigned int j=0; j<n_cols; j++)
326  temp.at(i,j) = obj1.at(i,j) + obj2;
327 
328  return temp;
329 }
330 
331 template<typename U,typename V> AlgebraicMatrix<typename PromotionTrait< U, V >::returnType> operator+( const U &obj1, const AlgebraicMatrix<V> &obj2 ) {
338  unsigned int n_rows = obj2.nrows();
339  unsigned int n_cols = obj2.ncols();
340 
342 
343  for (unsigned int i=0; i<n_rows; i++)
344  for (unsigned int j=0; j<n_cols; j++)
345  temp.at(i,j) = obj1 + obj2.at(i,j);
346 
347  return temp;
348 }
349 
357  // check that the two matrices have the same size
358  if((obj1.ncols()!=obj2.ncols())||(obj1.nrows()!=obj2.nrows()))
359  throw std::runtime_error("DACE::AlgebraicMatrix<T>::operator-: Inputs must have the same size, unless one is a scalar value.");
360 
361  unsigned int n_rows = obj1.nrows();
362  unsigned int n_cols = obj1.ncols();
363 
365 
366  for (unsigned int i=0; i<n_rows; i++)
367  for (unsigned int j=0; j<n_cols; j++)
368  temp.at(i,j) = obj1.at(i,j)-obj2.at(i,j);
369 
370  return temp;
371 }
372 
373 template<typename U,typename V> AlgebraicMatrix<typename PromotionTrait< U, V >::returnType> operator-( const AlgebraicMatrix<U> &obj1, const V &obj2 ) {
380  unsigned int n_rows = obj1.nrows();
381  unsigned int n_cols = obj1.ncols();
382 
384 
385  for (unsigned int i=0; i<n_rows; i++)
386  for (unsigned int j=0; j<n_cols; j++)
387  temp.at(i,j) = obj1.at(i,j) - obj2;
388 
389  return temp;
390 }
391 
392 
393 template<typename U,typename V> AlgebraicMatrix<typename PromotionTrait< U, V >::returnType> operator-( const U &obj1, const AlgebraicMatrix<V> &obj2 ) {
400  unsigned int n_rows = obj2.nrows();
401  unsigned int n_cols = obj2.ncols();
402 
404 
405  for (unsigned int i=0; i<n_rows; i++)
406  for (unsigned int j=0; j<n_cols; j++)
407  temp.at(i,j) = obj1 - obj2.at(i,j);
408 
409  return temp;
410 }
411 
419  // check that first matrix columns and second matrix row are equal
420  if( obj1.ncols()!=obj2.nrows() )
421  throw std::runtime_error("DACE::AlgebraicMatrix<T>::operator*: Number of columns of first matrix must be equal to num,ber of rows of second matrix.");
422 
423  unsigned int N = obj1.nrows();
424  unsigned int M = obj1.ncols();
425  unsigned int P = obj2.ncols();
426 
428 
429  for (unsigned int i=0; i<N; i++)
430  for (unsigned int j=0; j<P; j++) {
431  temp.at(i,j) = 0;
432  for (unsigned int k=0; k<M; k++)
433  temp.at(i,j) += obj1.at(i,k)*obj2.at(k,j); }
434 
435  return temp;
436 }
437 
438 template<typename U,typename V> AlgebraicMatrix<typename PromotionTrait< U, V >::returnType> operator*( const AlgebraicMatrix<U> &obj1, const V &obj2 ) {
445  unsigned int n_rows = obj1.nrows();
446  unsigned int n_cols = obj1.ncols();
447 
449 
450  for (unsigned int i=0; i<n_rows; i++)
451  for (unsigned int j=0; j<n_cols; j++)
452  temp.at(i,j) = obj1.at(i,j)*obj2;
453 
454  return temp;
455 }
456 
457 template<typename U,typename V> AlgebraicMatrix<typename PromotionTrait< U, V >::returnType> operator*( const U &obj1, const AlgebraicMatrix<V> &obj2 ) {
464  unsigned int n_rows = obj2.nrows();
465  unsigned int n_cols = obj2.ncols();
466 
468 
469  for (unsigned int i=0; i<n_rows; i++)
470  for (unsigned int j=0; j<n_cols; j++)
471  temp.at(i,j) = obj1*obj2.at(i,j);
472 
473  return temp;
474 }
475 
476 /***********************************************************************************
477 * Matrix operations
478 ************************************************************************************/
484  // Allocate a matrix with ncols rows and nrows cols
485  AlgebraicMatrix<T> temp(this->_ncols,this->_nrows);
486 
487  // Cycle over rows and colunms
488  for(unsigned int i=0; i<(this->_nrows); i++)
489  for(unsigned int j=0; j<(this->_ncols); j++)
490  temp.at(j,i) = this->_data[i*(this->_ncols)+j];
491 
492  return temp;
493 }
494 
496 /* Auxiliary functions for inverse and determinant computation, ignored in Doxygen Documentation */
497 template<class T> unsigned int AlgebraicMatrix<T>::pivot(unsigned int& k, const unsigned int ii, const AlgebraicMatrix<T>& A, std::vector<unsigned int>& P, std::vector<unsigned int>& R, std::vector<unsigned int>& C1, std::vector<unsigned int>& C2, T& det) {
498  using std::abs;
499 
500  unsigned int im = 0;
501  double t, m = 0;
502  const unsigned int n = A.nrows();
503 
504  for (unsigned int i=0; i<n; i++){
505  if (P[i]==0){
506  for (unsigned int j=0; j<n; j++){
507  if (P[j]==0){
508  t = abs( A.at(R[i],j) );
509  if (!(t<m)){
510  im = i;
511  k = j;
512  m = t;
513  }
514  }
515  }
516  }
517  }
518 
519  if (m<1.e-12){
520  det = 0.0;
521  return 123;}
522  else{
523  det = det*A.at( R[im], k ); // multiply pivot into determinant
524  if (im!=k) det = -1.0*det; // adjust sign of determinant
525  std::swap(R[k], R[im]);
526  P[k] = 1; // mark column as done
527 
528  // record original row/column of pivot
529  C1[ii] = im;
530  C2[ii] = k;
531 
532  return 0;}
533 }
534 
535 /* Auxiliary functions for inverse and determinant computation */
536 template<class T> void AlgebraicMatrix<T>::eliminate( const unsigned int k, AlgebraicMatrix<T>& A, std::vector<unsigned int>& R) {
537  unsigned int n = A.nrows();
538 
539 // // Better speed, less accuracy
540 // for (unsigned int j=0; j<n; j++)
541 // {
542 // if (j!=k){
543 // A.at(R[k],j) = A.at(R[k],j)*A.at(R[k],k);
544 // }
545 // }
546 
547  // Better accuracy, less speed
548  for (unsigned int j=0; j<n; j++){
549  if (j!=k)
550  A.at(R[k],j) = A.at(R[k],j)/A.at(R[k],k);}
551 
552  A.at(R[k],k) = 1.0/A.at(R[k],k);
553 
554  for (unsigned int i=0; i<n; i++){
555  if(i!=k){
556  for (unsigned int j=0; j<n; j++){
557  if (j!=k) A.at(R[i],j) = A.at(R[i],j) - A.at(R[i],k)*A.at(R[k],j);
558  }
559  A.at(R[i],k) = -1.0*A.at(R[i],k)*A.at(R[k],k);
560  }
561  }
562 }
565 template<class T> AlgebraicMatrix<T> AlgebraicMatrix<T>::inv() const{
572  // Check if matrix is square
573  if (_nrows!=_ncols)
574  throw std::runtime_error("DACE::AlgebraicMatrix<T>::inv: Matrix must be square to compute the inverse.");
575 
576  const unsigned int n = _nrows;
577  unsigned int k=0;
578  T det = 1.0;
579  std::vector<unsigned int> R(n);
580  std::vector<unsigned int> P(n,0);
581  std::vector<unsigned int> C1(n,0);
582  std::vector<unsigned int> C2(n,0);
583  AlgebraicMatrix<T> AI(n);
584  AlgebraicMatrix<T> AA(*this);
585 
586  for (unsigned int i=0; i<n; i++) R[i] = i;
587 
588  for (unsigned int i=0; i<n; i++){
589  unsigned int err = pivot(k, i, AA, P, R, C1, C2, det);
590  if (err==0)
591  eliminate(k, AA, R);
592  else
593  throw std::runtime_error("DACE::AlgebraicMatrix<T>::inv: Matrix inverse does not exist.");
594  }
595 
596  for (unsigned int i=0; i<n; i++) P[i] = i;
597  for (int i=n-1; i>=0; i--) std::swap(P[C1[i]], P[C2[i]]);
598  for (unsigned int i=0; i<n; i++)
599  for (unsigned int j=0; j<n; j++)
600  AI.at(i,j) = AA.at(R[i], P[j]);
601 
602  return AI;
603 }
604 
605 template<class T> T AlgebraicMatrix<T>::det() const{
610  // Check if matrix is square
611  if (_nrows!=_ncols)
612  throw std::runtime_error("DACE::AlgebraicMatrix<T>::inv: Matrix must be square to compute the inverse.");
613 
614  const unsigned int n = _nrows;
615  unsigned int k=0;
616  T det = 1.0;
617  std::vector<unsigned int> R(n);
618  std::vector<unsigned int> P(n,0);
619  std::vector<unsigned int> C1(n,0);
620  std::vector<unsigned int> C2(n,0);
621  AlgebraicMatrix<T> AA(*this);
622 
623  for (unsigned int i=0; i<n; i++) R[i] = i;
624 
625  for (unsigned int i=0; i<n; i++){
626  unsigned int err = pivot(k, i, AA, P, R, C1, C2, det);
627  if (err==0)
628  eliminate(k, AA, R);
629  else
630  return 0.0;
631  }
632 
633  return det;
634 }
635 
636 /***********************************************************************************
637 * Coefficient access routines
638 ************************************************************************************/
645  AlgebraicMatrix<double> temp(this->_nrows, this->_ncols);
646 
647  for(unsigned int i=0; i<(this->_nrows); i++)
648  for(unsigned int j=0; j<(this->_ncols); j++)
649  temp.at(i,j) = DACE::cons(this->_data[i*this->_ncols+j]);
650 
651  return temp;
652 }
653 
654 /***********************************************************************************
655 * Input/Output routines
656 ************************************************************************************/
657 template<typename U> std::ostream& operator<< (std::ostream &out, const AlgebraicMatrix<U> &obj){
663  // Output each column at a time
664  unsigned int nrows = obj.nrows();
665  unsigned int ncols = obj.ncols();
666 
667  out << "[[[ " << nrows << "x" << ncols << " matrix" << std::endl;
668  for(unsigned int i = 0; i<nrows;i++){
669  for(unsigned int j = 0; j<ncols; j++){
670  out << obj.at(i,j);
671  if((j+1)==ncols)
672  out<<std::endl;
673  else
674  out<<'\t';
675  }
676  }
677 
678  out << "]]]" << std::endl;
679 
680  return out;
681 }
682 
683 template<typename U> std::istream& operator>> (std::istream &in, AlgebraicMatrix<U> &obj){
689  // read the first line
690  std::string init_line;
691  std::getline(in, init_line);
692 
693  // initialize the size of the vector to be read
694  unsigned int n_rows = 0;
695  unsigned int n_cols = 0;
696 
697  // retrieve the size of the vector to be read
698  if(in.good() ){
699  // Find the number of rows
700  std::size_t found = init_line.find_first_of("x");
701  int j = 4;
702  std::string size_str;
703  while(j<(int)found){
704  size_str = size_str + init_line[j];
705  j++;}
706  if (!(std::istringstream(size_str) >> n_rows)) n_rows = 0;
707 
708  // Find the number of columns (stop when matrix is met)
709  j = (int)found+1;
710  found = init_line.find_first_of("m",found);
711  size_str.clear();
712  while(j<(int)found){
713  size_str = size_str + init_line[j];
714  j++;}
715  if (!(std::istringstream(size_str) >> n_cols)) n_cols = 0;
716 
717  // resize the object to meet the size of the vector to be read
718  if ((obj.nrows() != n_rows)&&(obj.ncols() != n_cols))
719  obj.resize(n_rows, n_cols);
720 
721  // fill the AlgebraicMatrix
722  int i = 0;
723  while(in.good() && (i<n_rows)) {
724  // read value and allocate in the i-th component of obj
725  for(int j=0; j<n_cols; j++)
726  in >> obj.at(i,j);
727  i++;
728  }
729 
730  // check the next character
731  if (in.peek() == '\n') // the previous operator>> does not consume the \n character when an AlgebraicVector<T> (with T != DA) is considered
732  in.ignore(); // ignore the next character
733 
734  // skip the line at the end of a AlgebraicMatrix (containing ]]])
735  std::string skip_line;
736  std::getline(in, skip_line);
737  }
738  return in;
739 }
740 
741 /***********************************************************************************
742 * Matrix operations
743 ************************************************************************************/
744 template<class T> AlgebraicMatrix<T> transpose(const AlgebraicMatrix<T>& obj){
750  return obj.transpose();
751 }
752 
753 template<class T> T det(const AlgebraicMatrix<T>& obj){
759  return obj.det();
760 }
761 
762 template<class T> AlgebraicMatrix<T> inv(const AlgebraicMatrix<T>& obj) {
768  return obj.inv();
769 }
770 
771 /***********************************************************************************
772 * Coefficient access routines
773 ************************************************************************************/
774 template<class T> AlgebraicMatrix<double> cons(const AlgebraicMatrix<T>& obj) {
781  return obj.cons();
782 }
783 
784 }
785 #endif /* DINAMICA_DAMATRIX_T_H_ */
AlgebraicMatrix< T > inv(const AlgebraicMatrix< T > &obj)
Definition: AlgebraicMatrix_t.h:762
std::istream & operator>>(std::istream &in, AlgebraicMatrix< DA > &obj)
DA specialization of input stream operator.
Definition: AlgebraicMatrix.cpp:65
unsigned int ncols() const
Definition: AlgebraicMatrix.h:82
T det() const
Matrix determinant.
Definition: AlgebraicMatrix_t.h:605
DA operator*(const DA &da1, const DA &da2)
Definition: DA.cpp:759
DA operator-(const DA &da1, const DA &da2)
Definition: DA.cpp:714
double abs(const DA &da)
Definition: DA.cpp:2558
AlgebraicMatrix< double > cons() const
Return the costant part of a AlgebraicMatrix<T>
Definition: AlgebraicMatrix_t.h:639
T det(const AlgebraicMatrix< T > &obj)
Definition: AlgebraicMatrix_t.h:753
void resize(int size)
Definition: AlgebraicMatrix_t.h:90
Definition: AlgebraicMatrix.h:43
AlgebraicMatrix< T > transpose() const
Matrix transpose.
Definition: AlgebraicMatrix_t.h:479
Definition: AlgebraicMatrix.h:46
std::vector< T > getcol(const unsigned int icol) const
Reading column.
Definition: AlgebraicMatrix_t.h:192
void setrow(const unsigned int irow, const std::vector< T > &obj)
Set row equal to std::vector.
Definition: AlgebraicMatrix_t.h:215
void setcol(const unsigned int icol, const std::vector< T > &obj)
Set column equal to std::vector.
Definition: AlgebraicMatrix_t.h:230
T & at(const unsigned int irow, const unsigned int icol)
Reading/Writing single element.
Definition: AlgebraicMatrix_t.h:143
Definition: AlgebraicMatrix.cpp:39
double cons(const DA &da)
Definition: DA.cpp:1970
#define abs(x)
Definition: f2c.h:157
AlgebraicMatrix< T > inv() const
Matrix inverse XXX: name.
Definition: AlgebraicMatrix_t.h:565
AlgebraicMatrix< T > submat(const unsigned int first_row, const unsigned int first_col, const unsigned int last_row, const unsigned int last_col) const
Extract submatrix.
Definition: AlgebraicMatrix_t.h:245
unsigned int size(const DA &da)
Definition: DA.cpp:2549
AlgebraicMatrix< T > transpose(const AlgebraicMatrix< T > &obj)
Definition: AlgebraicMatrix_t.h:744
std::vector< T > getrow(const unsigned int irow) const
Reading row.
Definition: AlgebraicMatrix_t.h:169
DA operator+(const DA &da1, const DA &da2)
Definition: DA.cpp:669
unsigned int nrows() const
Definition: AlgebraicMatrix.h:88