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

Method addVector

SRC/matrix/Vector.cpp:252–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

MEFI.cppFile · 0.45
SSPquadUP.cppFile · 0.45
SSPbrick.cppFile · 0.45
SSPquad.cppFile · 0.45
SSPbrickUP.cppFile · 0.45
meshMethod · 0.45
getdDMethod · 0.45
identifyMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected