# Doubt about "nzval" field in factorization?

**URL:** <https://discourse.julialang.org/t/doubt-about-nzval-field-in-factorization/91151>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 2, 2022, 4:02pm UTC](https://discourse.julialang.org/t/doubt-about-nzval-field-in-factorization/91151 "2022-12-02T16:02:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [December 2, 2022, 4:02pm UTC](https://discourse.julialang.org/t/doubt-about-nzval-field-in-factorization/91151/1 "2022-12-02T16:02:46Z")

</div>

I have the below MWE. I have two things:  
1- The matrices of `factor` and `factor1` are different. However, why the fifth element of `factor.nzval=7` not `6`. but the matrices of ``?

```julia
using SparseArrays, LinearAlgebra, KLU
A_Mat = spzeros(3,3);
A_Mat[diagind(A_Mat)[1:3]] .= 1.0;
A_Mat[2,1] = 9; A_Mat[3,1] = 10; A_Mat[1,3] = 6;
b_Mat = zeros(3); b_Mat[1,1] = 2.0; b_Mat[2,1] = 3; b_Mat[3,1] = 4;
x_Mat = zeros(3);
factor = klu(A_Mat);
A_Mat[1,3] = 7;
factor1 = klu(A_Mat);
ldiv!(x_Mat, factor, b_Mat)
julia> factor.nzval
6-element Vector{Float64}:
  1.0
  9.0
 10.0
  1.0
  7.0
  1.0

julia> factor1.nzval
6-element Vector{Float64}:
  1.0
  9.0
 10.0
  1.0
  7.0
  1.0

```

2- In the REPL, I can see all the matrices of factor, for example `factor.L`, but I cannot see them in the workspace (variables/global(main)) in VS code. Any reason for that?

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [December 2, 2022, 9:09pm UTC](https://discourse.julialang.org/t/doubt-about-nzval-field-in-factorization/91151/2 "2022-12-02T21:09:10Z")

</div>

`factor.nzval` and `factor1.nzval` work, but they are not properties of `KLUFactorization`. `factor.L.nzval` and `factor1.L.nzval` give the different results that are expected.

The way `KLUFactorization` `getproperty` function is defined passes unrecognized values to `getfield` on the structure, which has an `nzval` (the purpose of which I hadn’t investigated).

Hope this clear up something. Maybe a PR is necessary not to allow access to every `KLUFactorization` field with `getproperty`.

---

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [December 2, 2022, 9:34pm UTC](https://discourse.julialang.org/t/doubt-about-nzval-field-in-factorization/91151/3 "2022-12-02T21:34:36Z")

</div>

Thanks for your reply and assistance.

> [@Dan](#):
>
> `factor.nzval` and `factor1.nzval` work, but they are not properties of `KLUFactorization`.

They are properties of `A_Mat`, right?

> [@Dan](#):
>
> Hope this clear up something. Maybe a PR is necessary not to allow access to every `KLUFactorization` field with `getproperty`.

What is `PR`?

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [December 3, 2022, 12:22am UTC](https://discourse.julialang.org/t/doubt-about-nzval-field-in-factorization/91151/4 "2022-12-03T00:22:40Z")

</div>

> [@Amro](#):
>
> What is `PR`?

Short for Pull Request (on GitHub). The way package development is often organized.
