Revision 322c0d59

View differences:

utility/matrix.h
192 192
        return ret;
193 193
    }
194 194

  
195
    double determinant()
195
    double determinant() const
196 196
    {
197 197
        if(N == 1)
198 198
            return cell(0, 0);
......
206 206
        return det;
207 207
    }
208 208

  
209
    Matrix invert()
209
    Matrix invert() const
210 210
    {
211 211
        Matrix ret;
212 212
        float det = determinant();
213 213

  
214
        for(int x = 0; x < N; x++)
214
        for (int i = 0; i < N; i++)
215 215
        {
216
            for(int y = 0; y < N; y++)
216
            for (int j = 0; j < N; j++)
217 217
            {
218
                Matrix<N-1> minor = minor_matrix(y, x);
219
                ret(x, y) = det*minor.determinant();
220
                if( (x+y)%2 == 1)
221
                    ret(x, y) = -ret(x, y);
218
                ret(i, j) = minor_matrix(j, i).determinant() / det;
219
                if ((i+j)%2 == 1)
220
                    ret(i, j) = -ret(i, j);
222 221
            }
223 222
        }
224 223
        return ret;

Also available in: Unified diff