| 326 | |
| 327 | |
| 328 | int |
| 329 | Vector::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 |
no test coverage detected