 # Does matrix decomposition only work on floats?

Im trying to use LU to reduce a system of equation to get the solution. When I try to do something like

``````let m = na::Matrix3::new(11, 12, 13,
21, 22, 23,
31, 32, 33);
let decomp = m.lu();
``````

i get that `lu()` has error:

``````no method named 'lu' found for struct na::Matrix<{integer},...
note: the method 'lu' exists but the following trait bounds were not satisfied: '{integer}: na::ComplexField'r
``````

Does nalgebra only support matrix decomp for floating-point matrices? So I would need to convert my ints to floats and then back again? Or am I missing something fundamental?

Hi! That’s correct, LU decomposition will only work with floats and complex numbers.

1 Like

Gotcha, thanks for the quick reply! If I know that my coefficients are always integers, is there a better way to solving a linear system of eq than converting the matrix to FP, using one of the decomposition methods (LU,QR), then back to int?

I don’t think there is a better option right now.

1 Like

good to know, thanks!