| 245 | } |
| 246 | |
| 247 | int |
| 248 | Vector::addVector(double thisFact, const Vector &other, double otherFact ) |
| 249 | { |
| 250 | // check if quick return |
| 251 | if (otherFact == 0.0 && thisFact == 1.0) |
| 252 | return 0; |
| 253 | |
| 254 | // if sizes are compatable add |
| 255 | #ifdef _G3DEBUG |
| 256 | if (sz != other.sz) { |
| 257 | // else sizes are incompatable, do nothing but warning |
| 258 | opserr << "WARNING Vector::addVector() - incompatable Vector sizes\n"; |
| 259 | return -1; |
| 260 | } |
| 261 | #endif |
| 262 | |
| 263 | |
| 264 | if (thisFact == 1.0) { |
| 265 | |
| 266 | // want: this += other * otherFact |
| 267 | double *dataPtr = theData; |
| 268 | double *otherDataPtr = other.theData; |
| 269 | if (otherFact == 1.0) { // no point doing a multiplication if otherFact == 1.0 |
| 270 | for (int i=0; i<sz; i++) |
| 271 | *dataPtr++ += *otherDataPtr++; |
| 272 | } else if (otherFact == -1.0) { // no point doing a multiplication if otherFact == 1.0 |
| 273 | for (int i=0; i<sz; i++) |
| 274 | *dataPtr++ -= *otherDataPtr++; |
| 275 | } else |
| 276 | for (int i=0; i<sz; i++) |
| 277 | *dataPtr++ += *otherDataPtr++ * otherFact; |
| 278 | } |
| 279 | |
| 280 | else if (thisFact == 0.0) { |
| 281 | |
| 282 | // want: this = other * otherFact |
| 283 | double *dataPtr = theData; |
| 284 | double *otherDataPtr = other.theData; |
| 285 | if (otherFact == 1.0) { // no point doing a multiplication if otherFact == 1.0 |
| 286 | for (int i=0; i<sz; i++) |
| 287 | *dataPtr++ = *otherDataPtr++; |
| 288 | } else if (otherFact == -1.0) { // no point doing a multiplication if otherFact == 1.0 |
| 289 | for (int i=0; i<sz; i++) |
| 290 | *dataPtr++ = -(*otherDataPtr++); |
| 291 | } else |
| 292 | for (int i=0; i<sz; i++) |
| 293 | *dataPtr++ = *otherDataPtr++ * otherFact; |
| 294 | } |
| 295 | |
| 296 | else { |
| 297 | |
| 298 | // want: this = this * thisFact + other * otherFact |
| 299 | double *dataPtr = theData; |
| 300 | double *otherDataPtr = other.theData; |
| 301 | if (otherFact == 1.0) { // no point doing a multiplication if otherFact == 1.0 |
| 302 | for (int i=0; i<sz; i++) { |
| 303 | double value = *dataPtr * thisFact + *otherDataPtr++; |
| 304 | *dataPtr++ = value; |
no outgoing calls
no test coverage detected