/********************************************************************** Audacity: A Digital Audio Editor Matrix.cpp Dominic Mazzoni **********************************************************************/ #include #include #include #include "Matrix.h" Vector::Vector() { mCopy = false; mN = 0; mData = NULL; } Vector::Vector(int len, double *data, bool copy) { mN = len; mCopy = copy; if (mCopy || !data) { mCopy = true; mData = new double[mN]; int i; for(i=0; i absmax) { absmax = fabs(M[j][i]); argmax = j; } // If no row has a nonzero value in that column, // the matrix is singular and we have to give up. if (absmax == 0) return false; if (i != argmax) { M.SwapRows(i, argmax); Minv.SwapRows(i, argmax); } // Divide this row by the value of M[i][i] double factor = 1.0 / M[i][i]; M[i] = M[i] * factor; Minv[i] = Minv[i] * factor; // Eliminate the rest of the column for(j=0; j 0) { // Subtract a multiple of row i from row j double factor = M[j][i]; for(k=0; k