# Is Julia lazy?

**URL:** <https://discourse.julialang.org/t/is-julia-lazy/64192>\
**Category:** New to Julia\
**Created:** [July 7, 2021, 4:25am UTC](https://discourse.julialang.org/t/is-julia-lazy/64192 "2021-07-07T04:25:57Z")\
**Posts on this page:** 3\
**Page:** 6

<div class="post-metadata">

**Author:** ![genkuroki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/genkuroki/32/18030_2.png) [@genkuroki](https://discourse.julialang.org/u/genkuroki)\
**Post date:** [July 15, 2021, 1:27pm UTC](https://discourse.julialang.org/t/is-julia-lazy/64192/101 "2021-07-15T13:27:15Z")

</div>

Example of Nemo.jl ([Matrices · Nemo.jl](https://nemocas.github.io/Nemo.jl/dev/matrix/))

Code:

```julia
using Nemo
matrix(T, A) = MatrixSpace(T, size(A)...)(A)
pl(x...) = println(x...)
macro s(expr)
    :(println($(string(expr)), " ="); show(stdout, "text/plain", $expr); println("\n"))
end

F, a = FiniteField(7, 2, "a")
P, x = F["x"]
X = matrix(F, (0:6)' .* a .+ (0:6))
A = F[a+1 a+2; a+3 3a+4]
v = F[5a+2; 3a+6]

@show F P; pl()
@show [F(3)^k for k in 1:6]; pl()
@show [a^k for k in 1:48]; pl()
@s X
@s rref(X)[2]
@show det(X) tr(X) rank(X) charpoly(P, X) minpoly(P, X); pl()
@s A
@s A'
@s A'A
@show det(A) tr(A) rank(A) charpoly(P, A) lu(A) inv(A); pl()
@show v A*v; pl()

```

Output:

```julia
F = Finite field of degree 2 over F_7
P = Univariate Polynomial Ring in x over Finite field of degree 2 over F_7

[F(3) ^ k for k = 1:6] = fq_nmod[3, 2, 6, 4, 5, 1]

[a ^ k for k = 1:48] = fq_nmod[a, a + 4, 5*a + 4, 2*a + 6, a + 1, 2*a + 4, 6*a + 1, 3, 3*a, 3*a + 5, a + 5, 6*a + 4, 3*a + 3, 6*a + 5, 4*a + 3, 2, 2*a, 2*a + 1, 3*a + 1, 4*a + 5, 2*a + 2, 4*a + 1, 5*a + 2, 6, 6*a, 6*a + 3, 2*a + 3, 5*a + 1, 6*a + 6, 5*a + 3, a + 6, 4, 4*a, 4*a + 2, 6*a + 2, a + 3, 4*a + 4, a + 2, 3*a + 4, 5, 5*a, 5*a + 6, 4*a + 6, 3*a + 2, 5*a + 5, 3*a + 6, 2*a + 5, 1]

X =
[0 a 2*a 3*a 4*a 5*a 6*a]
[1 a + 1 2*a + 1 3*a + 1 4*a + 1 5*a + 1 6*a + 1]
[2 a + 2 2*a + 2 3*a + 2 4*a + 2 5*a + 2 6*a + 2]
[3 a + 3 2*a + 3 3*a + 3 4*a + 3 5*a + 3 6*a + 3]
[4 a + 4 2*a + 4 3*a + 4 4*a + 4 5*a + 4 6*a + 4]
[5 a + 5 2*a + 5 3*a + 5 4*a + 5 5*a + 5 6*a + 5]
[6 a + 6 2*a + 6 3*a + 6 4*a + 6 5*a + 6 6*a + 6]

(rref(X))[2] =
[1 0 6 5 4 3 2]
[0 1 2 3 4 5 6]
[0 0 0 0 0 0 0]
[0 0 0 0 0 0 0]
[0 0 0 0 0 0 0]
[0 0 0 0 0 0 0]
[0 0 0 0 0 0 0]

det(X) = 0
tr(X) = 0
rank(X) = 2
charpoly(P, X) = x^7
minpoly(P, X) = x^2

A =
[a + 1 a + 2]
[a + 3 3*a + 4]

A' =
[a + 1 a + 3]
[a + 2 3*a + 4]

A' * A =
[3*a + 4 6*a + 2]
[6*a + 2 3*a + 4]

det(A) = 4*a + 6
tr(A) = 4*a + 5
rank(A) = 2
charpoly(P, A) = x^2 + (3*a + 2)*x + 4*a + 6
lu(A) = (2, (), [1 0; a+6 1], [a+1 a+2; 0 a+2])
inv(A) = [3*a+2 3*a+1; 2*a 3*a+5]

v = [5*a+2; 3*a+6]
A * v = [6*a+4; 5*a+2]

```

---

<div class="post-metadata">

**Author:** ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)\
**Post date:** [July 15, 2021, 6:59pm UTC](https://discourse.julialang.org/t/is-julia-lazy/64192/102 "2021-07-15T18:59:21Z")

</div>

Thank you for this reference and your examples I will study this carefully.

---

<div class="post-metadata">

**Author:** ![Gilles\_Dubois](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gilles_dubois/32/25830_2.png) [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)\
**Post date:** [July 15, 2021, 11:33pm UTC](https://discourse.julialang.org/t/is-julia-lazy/64192/103 "2021-07-15T23:33:48Z")

</div>

I’m really impressed by Nemo.  
Changing GaloisFields for Nemo is an option.  
But it implies a lot of changes for example for affine geometry.  
I’m presently making tests.

[Previous page](https://discourse.julialang.org/t/is-julia-lazy/64192.md?page=5)
