MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
ccmh.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbmath/ccmh.cc,v 1.26 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 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
36 
37 #include "spmapmh.h"
38 #include "ccmh.h"
39 
40 template <int off>
41 CColMatrixHandler<off>::CColMatrixHandler(std::vector<doublereal>& x,
42  const std::vector<integer>& i,
43  const std::vector<integer>& p)
44 : CompactSparseMatrixHandler_tpl<off>(p.size() - 1, p.size() - 1, x, i, p)
45 {
46  NO_OP;
47 }
48 
49 template <int off>
51 {
52  NO_OP;
53 }
54 
55 /* used by MultiThreadDataManager to duplicate the storage array
56  * while preserving the CC indices */
57 template <int off>
60 {
61  std::vector<doublereal> *pax =
62  new std::vector<doublereal>(CompactSparseMatrixHandler_tpl<off>::Ax);
66  p->bMatDuplicate = true;
67 
68  return p;
69 }
70 
71 template <int off>
72 void
74 {
75  silent_cerr("CColMatrixHandler<off>::Resize called" << std::endl);
77 }
78 
79 /* Estrae una colonna da una matrice */
80 template <int off>
83 {
84  // NOTE: out must be zeroed by caller
85 
86  if (icol > SparseMatrixHandler::iGetNumCols()) {
88  }
89 
92 
93  for ( ; idx < idxe; idx++) {
94  out(CompactSparseMatrixHandler_tpl<off>::Ai[idx] - off + 1) =
96  }
97 
98  return out;
99 }
100 
101 /* Moltiplica per uno scalare e somma a una matrice */
102 template <int off>
105  integer drow, integer dcol) const
106 {
107  silent_cerr("CColMatrixHandler<off>::MulAndSumWithShift called"
108  << std::endl);
110  if ((out.iGetNumCols() < SparseMatrixHandler::iGetNumCols() + dcol)
111  || (out.iGetNumRows() < SparseMatrixHandler::iGetNumRows() + drow)) {
112  silent_cerr("Assertion fault "
113  "in CColMatrixHandler<off>::MulAndSumWithShift"
114  << std::endl);
116  }
117  drow = drow + 1;
118  for (integer col = 0; col < SparseMatrixHandler::iGetNumCols(); col++) {
120  integer idxe = CompactSparseMatrixHandler_tpl<off>::Ap[col + 1] - off;
121  integer newcol = col + dcol + 1;
122  for (; idx < idxe; idx++) {
123  out.IncCoef(CompactSparseMatrixHandler_tpl<off>::Ai[idx] - off + drow,
125  }
126  }
127  return out;
128 }
129 
130 template <int off>
133  std::vector<bool> b,
134  doublereal s,
135  integer drow,
136  integer dcol) const
137 {
138  silent_cerr("CColMatrixHandler<off>::FakeThirdOrderMulAndSumWithShift "
139  "called" << std::endl);
141  if ((out.iGetNumCols() < SparseMatrixHandler::iGetNumCols() + dcol)
142  || (out.iGetNumRows() < SparseMatrixHandler::iGetNumRows() + drow)) {
143  silent_cerr("Assertion fault "
144  "in CColMatrixHandler<off>::MulAndSumWithShift"
145  << std::endl);
147  }
148  drow = drow + 1;
149  for (integer col = 0; col < SparseMatrixHandler::iGetNumCols(); col++) {
151  integer idxe = CompactSparseMatrixHandler_tpl<off>::Ap[col + 1] - off;
152  integer newcol = col + dcol + 1;
153  for (; idx < idxe; idx++) {
154  if (b[CompactSparseMatrixHandler_tpl<off>::Ai[idx] - off]) {
155  out.IncCoef(CompactSparseMatrixHandler_tpl<off>::Ai[idx] - off + drow,
157  }
158  }
159  }
160  return out;
161 }
162 
163 template class CColMatrixHandler<0>;
164 template class CColMatrixHandler<1>;
void Resize(integer ir, integer ic)
Definition: ccmh.cc:73
virtual integer iGetNumCols(void) const =0
virtual void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: mh.cc:374
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
#define NO_OP
Definition: myassert.h:74
CColMatrixHandler(std::vector< doublereal > &x, const std::vector< integer > &i, const std::vector< integer > &p)
Definition: ccmh.cc:41
integer iGetNumCols(void) const
Definition: spmh.h:117
MatrixHandler & FakeThirdOrderMulAndSumWithShift(MatrixHandler &out, std::vector< bool > b, doublereal s=1., integer drow=0, integer dcol=0) const
Definition: ccmh.cc:132
virtual ~CColMatrixHandler()
Definition: ccmh.cc:50
VectorHandler & GetCol(integer icol, VectorHandler &out) const
Definition: ccmh.cc:82
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
CompactSparseMatrixHandler * Copy(void) const
Definition: ccmh.cc:59
virtual integer iGetNumRows(void) const =0
MatrixHandler & MulAndSumWithShift(MatrixHandler &out, doublereal s=1., integer drow=0, integer dcol=0) const
Definition: ccmh.cc:104