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

Method addMatrix

DEVELOPER/core/Matrix.cpp:659–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657
658
659int
660Matrix::addMatrix(double factThis, const Matrix &other, double factOther)
661{
662 if (factThis == 1.0 && factOther == 0.0)
663 return 0;
664
665#ifdef _G3DEBUG
666 if ((other.numRows != numRows) || (other.numCols != numCols)) {
667 opserr << "Matrix::addMatrix(): incompatable matrices\n";
668 return -1;
669 }
670#endif
671
672 if (factThis == 1.0) {
673
674 // want: this += other * factOther
675 if (factOther == 1.0) {
676 double *dataPtr = data;
677 double *otherDataPtr = other.data;
678 for (int i=0; i<dataSize; i++)
679 *dataPtr++ += *otherDataPtr++;
680 } else {
681 double *dataPtr = data;
682 double *otherDataPtr = other.data;
683 for (int i=0; i<dataSize; i++)
684 *dataPtr++ += *otherDataPtr++ * factOther;
685 }
686 }
687
688 else if (factThis == 0.0) {
689
690 // want: this = other * factOther
691 if (factOther == 1.0) {
692 double *dataPtr = data;
693 double *otherDataPtr = other.data;
694 for (int i=0; i<dataSize; i++)
695 *dataPtr++ = *otherDataPtr++;
696 } else {
697 double *dataPtr = data;
698 double *otherDataPtr = other.data;
699 for (int i=0; i<dataSize; i++)
700 *dataPtr++ = *otherDataPtr++ * factOther;
701 }
702 }
703
704 else {
705
706 // want: this = this * thisFact + other * factOther
707 if (factOther == 1.0) {
708 double *dataPtr = data;
709 double *otherDataPtr = other.data;
710 for (int i=0; i<dataSize; i++) {
711 double value = *dataPtr * factThis + *otherDataPtr++;
712 *dataPtr++ = value;
713 }
714 } else {
715 double *dataPtr = data;
716 double *otherDataPtr = other.data;

Callers 13

addKtToTangMethod · 0.45
addCtoTangMethod · 0.45
addMtoTangMethod · 0.45
addKiToTangMethod · 0.45
addKgToTangMethod · 0.45
addKpToTangMethod · 0.45
addMtoTangMethod · 0.45
addCtoTangMethod · 0.45
operator+Method · 0.45
operator-Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected