# tell xerus to convert sparse tensors to dense if 1 in 4 entries are non-zero

xerus.Tensor.sparsityFactor = 4

~~~

in particular, setting the [`sparsityFactor`](\ref xerus::Tensor::sparsityFactor) to 0 will disable this feature.

in particular, setting the [sparsityFactor](\ref xerus::Tensor::sparsityFactor) to 0 will disable this feature.

~~~.cpp

// stop xerus from automatically converting sparse tensors to dense

xerus::Tensor::sparsityFactor = 0;

...

...

@@ -169,7 +175,7 @@ member functions [.use_dense_representation()](\ref xerus::Tensor::use_dense_rep

[.sparse_copy()](\ref xerus::Tensor::sparse_copy()) to obtain new tensor objects with the desired representation.

To make more informed decisions about whether a conversion might be useful the tensor objects can be queried for the number of

defined entries with [.sparsity()](\ref xerus::Tensor::sparsity()) or for the number of non-zero entries with [.count_non_zero_entries()](\ref xerus::Tensor::count_non_zero_entries()).

defined entries with [.sparsity()](\ref xerus::Tensor::sparsity()) or for the number of non-zero entries with [.count_non_zero_entries()](\ref xerus::Tensor::count_non_zero_entries()) ().