MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
dirccmh.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbmath/dirccmh.h,v 1.30 2017/01/12 14:43:53 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 2003-2017
7  *
8  * This code is a partial merge of HmFe and MBDyn.
9  *
10  * Pierangelo Masarati <masarati@aero.polimi.it>
11  * Paolo Mantegazza <mantegazza@aero.polimi.it>
12  * Marco Morandini <morandini@aero.polimi.it>
13  *
14  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
15  * via La Masa, 34 - 20156 Milano, Italy
16  * http://www.aero.polimi.it
17  *
18  * Changing this copyright notice is forbidden.
19  *
20  * This program is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation (version 2 of the License).
23  *
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33  */
34 
35 #ifndef DirCColMatrixHandler_hh
36 #define DirCColMatrixHandler_hh
37 
38 #include <vector>
39 
40 #include "myassert.h"
41 #include "solman.h"
42 #include "spmh.h"
43 
44 /* Sparse Matrix in columns form */
45 template <int off>
47 private:
48 #ifdef DEBUG
49  void IsValid(void) const {
50  NO_OP;
51  };
52 #endif /* DEBUG */
53  std::vector<integer *> pindices;
54  std::vector<integer> indices;
55 
56  // don't allow copy constructor!
58 
59 public:
60  DirCColMatrixHandler(std::vector<doublereal>& x,
61  const std::vector<integer>& i,
62  const std::vector<integer>& p);
63 
64  virtual ~DirCColMatrixHandler();
65 
66  /* used by MultiThreadDataManager to duplicate the storage array
67  * while preserving the CC indices */
68  CompactSparseMatrixHandler *Copy(void) const;
69 
70 public:
72  ASSERTMSGBREAK(i_row > 0 && i_row <= SparseMatrixHandler::iGetNumRows(),
73  "Error in CColMatrixHandler::operator(), "
74  "row index out of range");
75  ASSERTMSGBREAK(i_col > 0 && i_col <= SparseMatrixHandler::iGetNumCols(),
76  "Error in CColMatrixHandler::operator(), "
77  "col index out of range");
78 
79  integer idx = pindices[i_col][i_row];
80  if (idx == -1) {
81  /* matrix must be rebuilt */
83  }
84 
86  };
87 
88  const doublereal& operator () (integer i_row, integer i_col) const {
89  ASSERTMSGBREAK(i_row > 0 && i_row <= SparseMatrixHandler::iGetNumRows(),
90  "Error in CColMatrixHandler::operator(), "
91  "row index out of range");
92  ASSERTMSGBREAK(i_col > 0 && i_col <= SparseMatrixHandler::iGetNumCols(),
93  "Error in CColMatrixHandler::operator(), "
94  "col index out of range");
95 
96  integer idx = pindices[i_col][i_row];
97  if (idx == -1) {
98  /* matrix must be rebuilt */
100 
101  }
102 
104  };
105 
106  void Resize(integer n, integer nn);
107 
108  /* Estrae una colonna da una matrice */
109  VectorHandler& GetCol(integer icol, VectorHandler& out) const;
110 
111  /* Moltiplica per uno scalare e somma a una matrice */
113  doublereal s = 1.,
114  integer drow = 0, integer dcol = 0) const;
115 
117  std::vector<bool> b, doublereal s = 1.,
118  integer drow = 0, integer dcol = 0) const;
119 };
120 
121 
122 #endif /* DirCColMatrixHandler_hh */
123 
doublereal & operator()(integer i_row, integer i_col)
Definition: dirccmh.h:71
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
#define NO_OP
Definition: myassert.h:74
MatrixHandler & FakeThirdOrderMulAndSumWithShift(MatrixHandler &out, std::vector< bool > b, doublereal s=1., integer drow=0, integer dcol=0) const
Definition: dirccmh.cc:145
CompactSparseMatrixHandler * Copy(void) const
Definition: dirccmh.cc:69
integer iGetNumCols(void) const
Definition: spmh.h:117
const doublereal Zero1
std::vector< integer * > pindices
Definition: dirccmh.h:53
virtual ~DirCColMatrixHandler()
Definition: dirccmh.cc:60
void Resize(integer n, integer nn)
Definition: dirccmh.cc:83
std::vector< integer > indices
Definition: dirccmh.h:54
double doublereal
Definition: colamd.c:52
MatrixHandler & MulAndSumWithShift(MatrixHandler &out, doublereal s=1., integer drow=0, integer dcol=0) const
Definition: dirccmh.cc:116
long int integer
Definition: colamd.c:51
DirCColMatrixHandler(const DirCColMatrixHandler &)
VectorHandler & GetCol(integer icol, VectorHandler &out) const
Definition: dirccmh.cc:92