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

Method addMatrixVector

SRC/matrix/Vector.cpp:328–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

Element.cppFile · 0.45
SSPquadUP.cppFile · 0.45
SSPbrickUP.cppFile · 0.45
PFEMElement3D.cppFile · 0.45
getFMethod · 0.45
PFEMElement2D.cppFile · 0.45
TaylorHood2D.cppFile · 0.45

Calls 2

noRowsMethod · 0.45
noColsMethod · 0.45

Tested by

no test coverage detected