Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Feb 20, 2024
1 parent e5032b0 commit 3b8a459
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions SPEX/SPEX_Utilities/Source/SPEX_matrix_free.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,69 +26,99 @@ SPEX_info SPEX_matrix_free
// check inputs
//--------------------------------------------------------------------------

HERE
if (!spex_initialized ( )) { return (SPEX_PANIC); } ;

HERE
if (A_handle == NULL || (*A_handle) == NULL)
{
// nothing to free (not an error)
HERE
return (SPEX_OK);
}
SPEX_matrix A = (*A_handle);
HERE

//--------------------------------------------------------------------------
// free any non-shallow components
//--------------------------------------------------------------------------


// free the integer pattern
HERE
if (!(A->p_shallow)) SPEX_FREE (A->p);
HERE
if (!(A->i_shallow)) SPEX_FREE (A->i);
HERE
if (!(A->j_shallow)) SPEX_FREE (A->j);
HERE

// free the values
if (!(A->x_shallow))
{
switch (A->type)
{
case SPEX_MPZ:
HERE
if ( A->x.mpz != NULL)
{
HERE
for (int64_t i = 0; i < A->nzmax; i++)
{
HERE
fprintf (stderr, "i: %" PRId64"\n", i) ;
SPEX_MPZ_CLEAR( A->x.mpz[i]);
HERE
}
}
HERE
SPEX_FREE (A->x.mpz);
HERE
break ;

case SPEX_MPQ:
HERE
if ( A->x.mpq != NULL)
{
HERE
for (int64_t i = 0; i < A->nzmax; i++)
{
HERE
SPEX_MPQ_CLEAR( A->x.mpq[i]);
HERE
}
}
HERE
SPEX_FREE (A->x.mpq);
break ;

case SPEX_MPFR:
HERE
if ( A->x.mpfr != NULL)
{
HERE
for (int64_t i = 0; i < A->nzmax; i++)
{
HERE
SPEX_MPFR_CLEAR( A->x.mpfr[i]);
HERE
}
}
HERE
SPEX_FREE (A->x.mpfr);
HERE
break ;

case SPEX_INT64:
HERE
SPEX_FREE (A->x.int64);
HERE
break ;

case SPEX_FP64:
HERE
SPEX_FREE (A->x.fp64);
HERE
break ;

default:
Expand All @@ -99,15 +129,20 @@ SPEX_info SPEX_matrix_free


// A->scale is never shallow
HERE
SPEX_MPQ_CLEAR (A->scale);
HERE

//--------------------------------------------------------------------------
// free the header
//--------------------------------------------------------------------------

// the header is never shallow
HERE
SPEX_FREE (A);
HERE
(*A_handle) = NULL ;
HERE
return (SPEX_OK);
}

0 comments on commit 3b8a459

Please sign in to comment.