Skip to content

Conversation

@ViralBShah
Copy link
Member

This moves special functions to base/math.jl. It also removes the amos library from the julia sources, and instead uses it from openlibm.

Remove amos library and update the amos license.
Move extras/specfun.jl into base/math.jl, and move the location
of the documentation as well.
@johnmyleswhite
Copy link
Member

+1

This raises an issue I sometimes wonder about: how encompassing should base/math.jl become? And should there be a companion like extras/math2.jl?

As I'm revising [https://github.com/johnmyleswhite/julia/commit/897ba33f2b189ea7ad9f6e7804d4a1d5b3c8db8d] the Distributions module, I've needed to pull in the psigamma, digamma and trigamma functions, which are derivatives of the gamma function that is included in Viral's patch. Where would functions like that belong?

Having a central place for them seems very valuable, but having that place be base/math.jl seems less desirable.

@ViralBShah
Copy link
Member Author

That's a good question. Why would base/math.jl be less desirable? If there are a few more such functions, they can certainly go to base/math.jl.

@johnmyleswhite
Copy link
Member

My concern is that I just don't know how many more special functions are left. I only need about 7 more, which is totally reasonable. But would 100 more be ok?

@StefanKarpinski
Copy link
Member

I think that's a bridge we can cross when we get there. I suspect there aren't all that many more. Another approach would be to split them into smaller logical groups, but that could get annoying.

@ViralBShah
Copy link
Member Author

Let's start with the 7. We'll worry about the refactoring when more surface. :-)

@johnmyleswhite
Copy link
Member

Ok. Should I give you code for adding them now? Or I should wait until this gets merged and then look through what's missing to create an additional pull request?

@ViralBShah
Copy link
Member Author

I think it would be simplest for you to checkout the vs/amos branch, and commit your changes in there. It will show up in this pull request, and we can merge it when ready. It will also help test out the amos build related changes.

@johnmyleswhite
Copy link
Member

I've made changes to pull in the three missing gamma-related functions from Rmath. Unfortunately I didn't see how to get this to work without making it an essential library.

I'm pushing what I've done mostly for feedback. I have no idea if I'll have power tomorrow, so I don't response to comments, that's why.

@ViralBShah
Copy link
Member Author

I didn't realize that the functions you wanted are from Rmath. I am going to mull over this for a bit.

@JeffBezanson
Copy link
Member

Let's try to find other implementations from netlib. There is a lot of code there, such as http://www.netlib.org/slatec/fnlib/

@johnmyleswhite
Copy link
Member

Ok. I'll search through and try to find another implementation.

@johnmyleswhite
Copy link
Member

Jeff is right that Netlib has what we need in the cpsi.f function. Should I translate it over to Julia?

@ViralBShah
Copy link
Member Author

If it is not too much effort, it would be a good idea to translate to julia. Otherwise, I can add it to the build as part of openlibm.

@johnmyleswhite
Copy link
Member

Sorry for the delay. I've now implemented a simpler version of the digamma function in pure Julia. We'll eventually want to upgrade to the broader algorithm used by Rmath which includes the trigamma function and other derivatives of the gamma function, but it will take me a while to work through the Fortran code for that broader algorithm. This version is simple enough that I am confident in its correctness.

Resolve FC conflict for building openlibm.

Conflicts:
	deps/Makefile
@ViralBShah
Copy link
Member Author

@johnmyleswhite I am merging this in, and we can start a new pull request for trigamma and other derivatives of the gamma function. We also need tests for these.

ViralBShah added a commit that referenced this pull request Nov 1, 2012
RFC: Special functions and amos
@ViralBShah ViralBShah merged commit c4fe43e into master Nov 1, 2012
@johnmyleswhite
Copy link
Member

I've added tests for the digamma function. I will try to work on the other derivatives of the gamma function over the weekend.

vchuravy pushed a commit to JuliaPackaging/LazyArtifacts.jl that referenced this pull request Oct 2, 2023
jishnub pushed a commit that referenced this pull request Oct 19, 2025
)

Stdlib: LinearAlgebra
URL: https://github.com/JuliaLang/LinearAlgebra.jl.git
Stdlib branch: master
Julia branch: master
Old commit: d568106
New commit: 7e11b5e
Julia version: 1.13.0-DEV
LinearAlgebra version: 1.13.0
Bump invoked by: @IanButterworth
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/LinearAlgebra.jl@d568106...7e11b5e

```
$ git log --oneline d568106..7e11b5e
7e11b5e Add `AbstractArray` conversions for `AbstractQ` (#1470)
52c41f7 Add missing methods to `diagind` documentation (#1473)
28ee87e Overload array constructors for BunchKaufman (#1461) (#1466)
6f73f65 Add 'eigmin'/'eigmax' methods for 'Eigen' (#1468)
7b21cab Use `Iterators.rest` within `generic_norm` to simplify code (#1459)
57ac0eb Make `parentof_applytri` fully type-stable (#1243)
880a9fe Add `_sym_uplo` to skip validation (#1441)
8d6ca14 Public function to access the `uplo` for `Symmetric`/`Hermitian` (#1440)
7a4b27e Make `dot` with Bool-arrays type-stable (#1456)
6fe77f8 Make `dot` with Bool-arrays type-stable
5af75df Remove zeroing in `similar` for `Hermitian` (#1455)
5685390 Index into diag in `Tridigaonal` * `Diagonal` (#1454)
51923a5 Forward structure-preserving broadcasting to diag for `Diagonal` (#1423)
35a4427 Iterator norm in `isapprox` for `Array`s (#1378)
98723df Structured broadcasting for UpperHessenberg (#1325)
```

Co-authored-by: IanButterworth <1694067+IanButterworth@users.noreply.github.com>
jishnub pushed a commit that referenced this pull request Oct 22, 2025
#59927)

Stdlib: LinearAlgebra
URL: https://github.com/JuliaLang/LinearAlgebra.jl.git
Stdlib branch: release-1.12
Julia branch: backports-release-1.12
Old commit: 24f5e21
New commit: 5567504
Julia version: 1.12.1
LinearAlgebra version: 1.12.0(Does not match)
Bump invoked by: @ViralBShah
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/LinearAlgebra.jl@24f5e21...5567504

```
$ git log --oneline 24f5e21..5567504
5567504 Backports to v1.12 (#1472)
a2a4981 Overload array constructors for BunchKaufman (#1461) (#1466)
1ebc0cb Generic fallback for `fillstored!` (#1389)
```

Co-authored-by: ViralBShah <744411+ViralBShah@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants