MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / addMatrixVector

Method addMatrixVector

DEVELOPER/core/Vector.cpp:323–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321
322
323int
324Vector::addMatrixVector(double thisFact, const Matrix &m, const Vector &v, double otherFact )
325{
326 // see if quick return
327 if (thisFact == 1.0 && otherFact == 0.0)
328 return 0;
329
330 // check the sizes are compatable
331#ifdef _G3DEBUG
332 // check the sizes are compatable
333 if ((sz != m.noRows()) && (m.noCols() != v.sz)) {
334 // otherwise incompatable sizes
335 opserr << "Vector::addMatrixVector() - incompatable sizes\n";
336 return -1;
337 }
338#endif
339
340 if (thisFact == 1.0) {
341
342 // want: this += m * v * otherFact
343 if (otherFact == 1.0) { // no point doing multiplication if otherFact = 1.0
344 int otherSize = v.sz;
345 double *matrixDataPtr = m.data;
346 double *otherDataPtr = v.theData;
347 for (int i=0; i<otherSize; i++) {
348 double otherData = *otherDataPtr++;
349 for (int j=0; j<sz; j++)
350 theData[j] += *matrixDataPtr++ * otherData;
351 }
352 }
353 else if (otherFact == -1.0) { // no point doing multiplication if otherFact = -1.0
354 int otherSize = v.sz;
355 double *matrixDataPtr = m.data;
356 double *otherDataPtr = v.theData;
357 for (int i=0; i<otherSize; i++) {
358 double otherData = *otherDataPtr++;
359 for (int j=0; j<sz; j++)
360 theData[j] -= *matrixDataPtr++ * otherData;
361 }
362 }
363 else { // have to do the multiplication
364 int otherSize = v.sz;
365 double *matrixDataPtr = m.data;
366 double *otherDataPtr = v.theData;
367 for (int i=0; i<otherSize; i++) {
368 double otherData = *otherDataPtr++ * otherFact;
369 for (int j=0; j<sz; j++)
370 theData[j] += *matrixDataPtr++ * otherData;
371 }
372 }
373 }
374
375 else if (thisFact == 0.0) {
376
377 // want: this = m * v * otherFact
378 for (int i=0; i<sz; i++)
379 theData[i] = 0.0;
380

Callers 15

FE_Element.cppFile · 0.45
addM_ForceMethod · 0.45
addD_ForceMethod · 0.45
addK_ForceMethod · 0.45
addKg_ForceMethod · 0.45
addLocalM_ForceMethod · 0.45
addLocalD_ForceMethod · 0.45
addM_ForceSensitivityMethod · 0.45
addD_ForceSensitivityMethod · 0.45

Calls 2

noRowsMethod · 0.45
noColsMethod · 0.45

Tested by

no test coverage detected