Can someone help me with the rules when i comes to modulo calculations in matrices:

What I mean is, say I want to calculate the rank of a 3x3 matrix in F5. At which point do I convert the entries of this matrix to F5?
So what I did, was that I put the matrix in ref as usual and then converted to F5 in the end - the result was correct.

Does this always work this way?

But now say I converted to F5 for every step of my row operations, how would that work?
If let’s say I would have to multiply some row with -2 to get rid of an entry beneath it, -2 mod5 is 3 so we already have a problem, no? Or does the modulo operation only apply to the entries of the matrix and not the scalars by which we multiply them?

For the same question I also had to calculate the determinant in F5, and I used laplace and converted every number at every step to F5 and that worked.

So basically my question is: what are the rules when it comes to the order of these operations and why are we doing them in a certain order?
> -2 mod5 is 3 so we already have a problem, no?

I'm not following why that's a problem, if you just need it to be zero mod five?

I.e. you have a 1 in a pivot position and you are trying to eliminate a 2, so you multiply the 1 by either -2 or 3 and add it to the 2, and you still get zero mod 5.
you can do it in any order you like, since these properties hold true:

∀a,b∈ℤ, ∀n∈ℕ\{0},

(a mod n)+(b mod n) = a+b mod n

(a mod n)×(b mod n) = a×b mod n

I usually find it easier to convert the whole matrix to F5 and just do the whole arithmetic in F5, it's pretty easy since these are finite fields with very few elements. Once you start going into stuff like F37 or things like that, it might be useful to carry the arithmetics as if you were in ℝ (always keeping the fractions, never going to decimal form) and convert everything to F37 at the end.

As I'm sure you already know, remember that Fn is a field if and only if n is a prime number, so you can't do stuff like gaussian elimination if n isn't a prime number.
the quotient map from Z to Z/5Z is a ring homomorphism, so as long as you're only using ring operations (+ - *), you can do it at any stage.
by
Don't treat modulo as an operation. Modulo is a *context*. When you are doing something modulo 5, you are just under the context where you consider any integers that differ by a multiple of 5 as being *the same*.