#18732: Add tableau query functions glp_eval_tab_row, glp_eval_tab_col to GLPK
backend
-------------------------------------+-------------------------------------
Reporter: mkoeppe | Owner:
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-6.8
Component: numerical | Resolution:
Keywords: LP, glpk | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/yzh/add_tableau_query_functions_glp_eval_tab_row__glp_eval_tab_col_to_glpk_backend|
1cf22a926b785affdf53e33ea30c539850ae406a
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by ncohen):
> Nathann, if the second allocation fails, your version would leak the
memory of the first allocation.
Sorry, I wrote this yesterday evening just before going to sleep and I was
exhausted:
{{{
+ cdef int * c_indices = <int*> sage_malloc((n+1)*sizeof(int))
+ cdef double * c_values = <double*>
sage_malloc((n+1)*sizeof(double))
+ if c_indices == NULL or c_values == NULL:
+ sage_free(c_indices)
+ sage_free(c_values)
+ raise MemoryError
}}}
> sig_on/sig_off catches all kinds of signals, and here it is used to
catch SIGABRT, which GLPK invokes via abort() whenever there is an error.
Oh, okay. Sorry.
> Is there a way to distinguish which signal was caught?
Just type "raise" instead of "raise <something>". It will raise what was
caught. You can also use this model:
{{{
try:
your_glpk_function(...)
else: # only executed if everything went well
<copy the C data wherever you need>
finally: #whatever happens
<free the memory>
return <whatever you need>
}}}
Also, I don't think you should both with a loop of 'append'. Something
like `values = [c_values[j] for j in range(i)]` works fine.
Nathann
--
Ticket URL: <http://trac.sagemath.org/ticket/18732#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.