Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

pFq with Matrix argument

Open
#60 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia
Domain
backend

Research direction

Start by reviewing the existing pFq implementation and the shown pFqdrummond method for Matrix{BigFloat} arguments. Compare its matrix operations and convergence check with the scalar rational algorithms. Done means the relevant pFq call accepts matrix arguments and produces results consistent with matrix exponential behavior in the provided example.

Written by the indexing model from the issue text.

Description

This could be pretty useful. In Base, exp(z::Matrix{BigFloat}) doesn't exist but we could support it with some minor modifications of the rational algorithms

julia> using LinearAlgebra

julia> @inline errcheck(x::Matrix, y::Matrix, tol) = (norm(x-y) > max(norm(x), norm(y))*tol)
errcheck (generic function with 1 method)

julia> function pFqdrummond(::Tuple{}, ::Tuple{}, z::Matrix{T}; kmax::Int = 10_000) where T
           if norm(z) < eps(real(T))
               return Matrix{T}(I, size(z, 1), size(z, 2))
           end
           ζ = inv(z)
           Nlo = Matrix{T}(I, size(z, 1), size(z, 2))
           Dlo = Matrix{T}(I, size(z, 1), size(z, 2))
           Tlo = Nlo/Dlo
           Nhi = (2I - z)*Nlo + 2z
           Dhi = (2I - z)*Dlo
           Thi = Nhi/Dhi
           k = 1
           Nhi, Nlo = ((k+2)*I-z)*Nhi + k*z*Nlo + z*z, Nhi
           Dhi, Dlo = ((k+2)*I-z)*Dhi + k*z*Dlo, Dhi
           Thi, Tlo = Nhi/Dhi, Thi
           k += 1
           while k < kmax && errcheck(Tlo, Thi, 10eps(real(T)))
               Nhi, Nlo = ((k+2)*I-z)*Nhi + k*z*Nlo, Nhi
               Dhi, Dlo = ((k+2)*I-z)*Dhi + k*z*Dlo, Dhi
               Thi, Tlo = Nhi/Dhi, Thi
               k += 1
           end
           return Thi
       end
pFqdrummond (generic function with 1 method)

julia> Z = big.(rand(2, 2))
2×2 Matrix{BigFloat}:
 0.82811   0.0613331
 0.449884  0.073366

julia> pFqdrummond((), (), Z)
2×2 Matrix{BigFloat}:
 2.31398   0.0990111
 0.726256  1.09558

julia> exp(Float64.(Z))
2×2 Matrix{Float64}:
 2.31398   0.0990111
 0.726256  1.09558

julia> pFqdrummond((), (), Z) - exp(Float64.(Z))
2×2 Matrix{BigFloat}:
 6.85325e-16   3.73548e-17
 2.05869e-16  -7.37797e-17

julia> exp(Z)
ERROR: MethodError: no method matching exp(::Matrix{BigFloat})
Closest candidates are:
  exp(::Union{Float16, Float32, Float64}) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/special/exp.jl:296
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Float32, Float64, ComplexF32, ComplexF64}) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:560
  exp(::StridedMatrix{var"#s859"} where var"#s859"<:Union{Integer, Complex{<:Integer}}) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/LinearAlgebra/src/dense.jl:561
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

julia> 
Dominant language
Julia
Stars
76
Forks
12
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaMath/HypergeometricFunctions.jl

All issues in JuliaMath/HypergeometricFunctions.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.