# Warning/Error handling from complex, sparse array on SVD (PROPACK)

**URL:** <https://discourse.julialang.org/t/warning-error-handling-from-complex-sparse-array-on-svd-propack/110779>\
**Category:** Data\
**Tags:** error, complex-numbers, svd, sparsearrays\
**Created:** [February 26, 2024, 2:16pm UTC](https://discourse.julialang.org/t/warning-error-handling-from-complex-sparse-array-on-svd-propack/110779 "2024-02-26T14:16:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KSfairopoulos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ksfairopoulos/32/35673_2.png) [@KSfairopoulos](https://discourse.julialang.org/u/KSfairopoulos)\
**Post date:** [February 26, 2024, 2:16pm UTC](https://discourse.julialang.org/t/warning-error-handling-from-complex-sparse-array-on-svd-propack/110779/1 "2024-02-26T14:16:45Z")

</div>

Let’s assume I have a sparse matrix with complex entries.  
I want to perform svd on it. So, I use the Propack package (do you have any better suggestions?).  
I do this with the command: `tsvdvals(gs, k=p)`, where I retain the p largest singular values of matrix `gs`.  
Now, depending on the input matrix, there are some errors that come out which I do not know how to handle. For example, for a given matrix, I get the following:

```julia
WARNING: Maximum dimension of Krylov subspace exceeded prior to convergence. Try increasing KMAX.
 neig = 13
ERROR: lansvd return code: -1

```

This means I used very big value for p and I have to decrease it to 13 in this situation. However, this value depends on the given matrix used.

The question: How can I handle the warning message, save it (the value 13 of the second line of the warning) to a given variable and use it for updating the calculation for the correct value of p?
