On Tuesday, December 20, 2016 at 3:36:19 AM UTC+1, saad khalid wrote:
>
> 1. It appears we don't have a native q-gamma or q-digamma function. We do 
> have access to q-gamma from mpmath. However, a wrapper function in Sage 
> hasn't been added yet:
> https://trac.sagemath.org/ticket/19032
>
Would adding this be a simple as importing qgamma from mpmath?
>

No. Take any special function in the functions folder that derives from
BuiltinFunction as example.
 

> My worry in implementing it that way is about efficiency. If a user uses 
> calls qgamma many times, then it would be doing "from mpmath import qgamma" 
> many times, which seems pretty inefficient. Is there a more efficient way 
> of doing this?
>

The way Sage handles repeated calls of symbolic numerics is through
fast_callable see src/sage/ext/fast_callable.pyx
 

> for the gamma function in sage (I believe it uses GiNaC?), I don't see it 
> say "import gamma" anywhere. Does it not have to do that because GiNaC 
> isn't in python? Also, is there a reason we don't use mpmath for the gamma 
> function? 
>

GiNaC/Pynac calls py_tgamma in libs/pynac.pyx for numerics
if the argument has no gamma member (which it has if it's from
RR or CC, so see these rings for which library is used).
 

> 2. Going off of what I was talking about in question 1, how can I see the 
> implementation of the gamma function? I'm looking at the source in 
> sage/functions/other.py:
> https://github.com/sagemath/sage/blob/master/src/sage/functions/other.py
>

As I said it depends on the type of the argument.
 

> but I can't see the code for the actual function. I just see that it calls 
> something called gamma1, apparently. What is gamma1 here
>

gamma1 is an alias for Function_gamma() which is the one
argument version.
  

> and where can I see the code for the actual function?
>

For numerics see the gamma method of the resp. function argument.
 

> It mentions that Gamma uses various libraries in sage, but it looks like 
> it just uses gamma1(from ginac?) and gamma_inc. Is this correct?
>

No. Integer arguments use libgmp, floats probably mpmath,
balls use arb etc.
 

> 3. The formula for q-digamma is for q = 1. Since we don't have an 
> implementation of q-digamma as far as i can tell, I was thinking I would 
> try to find a library with an implementation of it, import that, and then 
> add the q = 1 case implementation as an if statement?
>

Yes that is an idea.
 

> And if I can't find a library with it, would it work okay to simply write 
> the formula for it directly there? Or would that be slow because it's in 
> python? I was thinking that since the code gets cythonized, the fact that 
> I'd be writing it in python wouldn't be cause it to be slow. 
>

New numeric algorithms are best implemented in one of the numerics
libraries used by Sage. I would implement it exclusively in arb (for inexact
argument).

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to