/*--------------------------------------------------------------------------*/ int sci_umf_ludel(char* fname, unsigned long l) { int mLU_ptr = 0, nLU_ptr = 0, lLU_ptr = 0, it_flag = 0; void * Numeric = NULL; CellAdr *Cell = NULL; Rhs = Max(Rhs, 0); /* Check numbers of input/output arguments */ CheckRhs(0, 1); CheckLhs(1, 1); if (Rhs == 0) /* destroy all */ { while ( ListNumeric ) { Cell = ListNumeric; ListNumeric = ListNumeric->next; if (Cell->it == 0) { umfpack_di_free_numeric(&(Cell->adr)); } else { umfpack_zi_free_numeric(&(Cell->adr)); } FREE(Cell); } } else { /* get the pointer to the LU factors */ GetRhsVar(1,SCILAB_POINTER_DATATYPE, &mLU_ptr, &nLU_ptr, &lLU_ptr); Numeric = (void *) ((unsigned long int) *stk(lLU_ptr)); /* Check if the pointer is a valid ref to ... */ if (RetrieveAdrFromList(Numeric, &ListNumeric, &it_flag)) { /* free the memory of the numeric object */ if ( it_flag == 0 ) { umfpack_di_free_numeric(&Numeric); } else { umfpack_zi_free_numeric(&Numeric); } } else { Scierror(999,_("%s: Wrong value for input argument #%d: Must be a valid reference to (umf) LU factors.\n"),fname,1); return 0; } } PutLhsVar(); return 0; }
/*--------------------------------------------------------------------------*/ int sci_taucs_chdel(char* fname, unsigned long l) { int mC_ptr = 0, nC_ptr = 0, lC_ptr = 0, it_flag = 0; taucs_handle_factors * pC = NULL; CellAdr * Cell = NULL; int NbRhsVar; Rhs = Max(Rhs, 0); /* Check numbers of input/output arguments */ CheckRhs(0, 1); CheckLhs(1, 1); NbRhsVar = Rhs; if (NbRhsVar == 0) /* destroy all */ { while ( ListCholFactors ) { Cell = ListCholFactors; ListCholFactors = ListCholFactors->next; pC = (taucs_handle_factors *) Cell->adr; taucs_supernodal_factor_free(pC->C); /* free the super nodal struct */ FREE(pC->p); /* free the permutation vector */ FREE(pC); /* free the handle */ FREE(Cell); } } else { /* get the pointer to the Cholesky factors */ GetRhsVar(1, SCILAB_POINTER_DATATYPE, &mC_ptr, &nC_ptr, &lC_ptr); pC = (taucs_handle_factors *) ((unsigned long int) *stk(lC_ptr)); /* Check if the pointer is a valid ref to ... */ if (RetrieveAdrFromList(pC, &ListCholFactors, &it_flag)) /* free the memory of the objects */ { taucs_supernodal_factor_free(pC->C); FREE(pC->p); FREE(pC); } else { Scierror(999,_("%s: Wrong value for input argument #%d: not a valid reference to Cholesky factors.\n"), fname, 1); return 0; } } PutLhsVar(); return 0; }
int RetrieveAdrFromList(Adr adr, CellAdr **L, int *it_flag) { /* teste si l'adresse adr est presente ds la liste L, si oui on la retire et la fonction renvoie 1, sinon 0 */ CellAdr * Cell; if ( *L == NULL ) { return 0; } else if ( (*L)->adr == adr ) { Cell = *L; *it_flag = Cell->it; *L = (*L)->next; FREE(Cell); return 1; } else { return ( RetrieveAdrFromList(adr, &((*L)->next), it_flag)); } }