void InvertMatrix( Matrix * theInvertedMatrix, const Matrix * theSourceMatrix ){ Matrix temp; if (theInvertedMatrix == theSourceMatrix) { temp = *theSourceMatrix; theSourceMatrix = &temp; } // теперь инвертируем Гауссом и.т.п. ....}
Matrix M = ......InvertMatrix(&M, M):
void InvertMatrix(Matrix& theInvertedMatrix, const Matrix* theSourceMatrix=NULL){ if (theSourceMatrix && theSourceMatrix != &theInvertedMatrix) {theInvertedMatrix= *theSourceMatrix;} // invert matrix theInvertedMatrix}
void InvertMatrix(Matrix& theInvertedMatrix, const Matrix* theSourceMatrix=NULL){ const Matrix* src; if (theSourceMatrix && theSourceMatrix != &theInvertedMatrix) { src = theSourceMatrix; } else { src = new Matrix(theInvertedMatrix); //copy theInvertedMatrix }// invert matrix// use src instead theSourceMatrix if(src != theSourceMatrix) {delete src;}}
Matrix src; if (theSourceMatrix && theSourceMatrix != &theInvertedMatrix) { src = theSourceMatrix; } else { src = theInvertedMatrix; }