Revision ba125e3b utility/matrix.h

View differences:

utility/matrix.h
192 192

  
193 193
    double determinant() const
194 194
    {
195
        if(N == 1)
196
            return cell(0, 0);
197

  
198
        float det = 0.0;
199
        for(int i = 0; i < N; i++ )
200
        {
201
            Matrix<N-1> minor = minor_matrix(0, i);
202
            det += (i%2==1?-1.0:1.0) * cell(0, i) * minor.determinant();
203
        }
195
        // specialization for N == 1 given below this class
196
        double det = 0.0, sign = 1.0;
197
        for (int i = 0; i < N; ++i, sign = -sign)
198
            det += sign * cell(0, i) * minor_matrix(0, i).determinant();
204 199
        return det;
205 200
    }
206 201

  
......
226 221
};
227 222

  
228 223

  
224
template<>
225
inline double Matrix<1>::determinant() const
226
{
227
    return cell(0, 0);
228
}
229

  
229 230
};
230 231

  
231 232
#endif

Also available in: Unified diff