Skip to content

Commit

Permalink
Merge branch 'master' into jishnub/eigen
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Jul 21, 2024
2 parents 42f7c9d + a7ddcca commit 7771273
Show file tree
Hide file tree
Showing 15 changed files with 885 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: ${{ runner.arch }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/Invalidations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Invalidations

on:
pull_request:
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'

concurrency:
# Skip intermediate builds: always.
Expand All @@ -16,7 +20,7 @@ jobs:
if: github.base_ref == github.event.repository.default_branch
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: actions/checkout@v4
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ on:
push:
branches:
- master
tags: [v*]
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'
pull_request:
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'


concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}-${{ github.workflow }}
Expand All @@ -28,9 +38,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- 'lts'
- '1'
- '~1.10.0-0'
os:
- ubuntu-latest
- macOS-latest
Expand All @@ -39,14 +48,15 @@ jobs:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2.2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: lcov.info
10 changes: 9 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ name: Documentation

on:
pull_request:
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'
push:
branches:
- 'master'
- 'release-'
tags: '*'
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'
release:
types: [published]

Expand All @@ -23,7 +31,7 @@ jobs:
with:
version: ${{ matrix.julia-version }}
- name: Cache artifacts
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
push:
branches: [master]
tags: [v*]
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'
pull_request:
paths-ignore:
- 'LICENSE'
Expand All @@ -29,24 +33,24 @@ jobs:
name: ${{ matrix.package.group }}/${{ matrix.package.repo }}/${{ matrix.julia-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
julia-version: ['1']
os: [ubuntu-latest]
package:
- {repo: Distributions.jl, group: JuliaStats}
- {repo: BlockArrays.jl, group: JuliaArrays}
- {repo: LazyArrays.jl, group: JuliaArrays}
# - {repo: LazyArrays.jl, group: JuliaArrays}
- {repo: ArrayLayouts.jl, group: JuliaLinearAlgebra}
- {repo: LazyBandedMatrices.jl, group: JuliaLinearAlgebra}
# - {repo: LazyBandedMatrices.jl, group: JuliaLinearAlgebra}
- {repo: BandedMatrices.jl, group: JuliaLinearAlgebra}
- {repo: BlockBandedMatrices.jl, group: JuliaLinearAlgebra}
- {repo: InfiniteLinearAlgebra.jl, group: JuliaLinearAlgebra}
# - {repo: InfiniteLinearAlgebra.jl, group: JuliaLinearAlgebra}
- {repo: Optim.jl, group: JuliaNLSolvers}

steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
arch: x64
Expand Down Expand Up @@ -74,6 +78,7 @@ jobs:
exit(0) # Exit immediately, as a success
end
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
deps/deps.jl
.DS_Store
Manifest.toml
Manifest-v*.*.toml
docs/build
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name = "FillArrays"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "1.10.0"
version = "1.11"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

Expand Down Expand Up @@ -42,11 +41,12 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Infinities = "e1ba4f0e-776d-440f-acd9-e1d2e9742647"
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Test", "Base64", "Infinities", "PDMats", "ReverseDiff", "SparseArrays", "StaticArrays", "Statistics", "Quaternions", "Documenter"]
test = ["Aqua", "Test", "Base64", "Infinities", "PDMats", "ReverseDiff", "SparseArrays", "StaticArrays", "Statistics", "Quaternions", "Documenter", "Random"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![codecov](https://codecov.io/gh/JuliaArrays/FillArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaArrays/FillArrays.jl)
[![deps](https://juliahub.com/docs/FillArrays/deps.svg)](https://juliahub.com/ui/Packages/FillArrays/2Dg1l?t=2)
[![version](https://juliahub.com/docs/FillArrays/version.svg)](https://juliahub.com/ui/Packages/FillArrays/2Dg1l)
[![pkgeval](https://juliahub.com/docs/FillArrays/pkgeval.svg)](https://juliahub.com/ui/Packages/FillArrays/2Dg1l)
[![pkgeval](https://juliahub.com/docs/FillArrays/pkgeval.svg)](https://juliaci.github.io/NanosoldierReports/pkgeval_badges/report.html)
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

Julia package to lazily represent matrices filled with a single entry,
Expand Down
6 changes: 4 additions & 2 deletions ext/FillArraysSparseArraysExt.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module FillArraysSparseArraysExt

using SparseArrays
import Base: convert, kron
using FillArrays
using FillArrays: RectDiagonalFill, RectOrDiagonalFill, ZerosVector, ZerosMatrix, getindex_value
using LinearAlgebra
import Base: convert, kron
# Specifying the full namespace is necessary because of https://github.com/JuliaLang/julia/issues/48533
# See https://github.com/JuliaStats/LogExpFunctions.jl/pull/63
using FillArrays.LinearAlgebra

##################
## Sparse arrays
Expand Down
51 changes: 42 additions & 9 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
any, all, axes, isone, iszero, iterate, unique, allunique, permutedims, inv,
copy, vec, setindex!, count, ==, reshape, map, zero,
show, view, in, mapreduce, one, reverse, promote_op, promote_rule, repeat,
parent, similar, issorted
parent, similar, issorted, add_sum, accumulate, OneTo

import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag, transpose, adjoint, fill!,
dot, norm2, norm1, normInf, normMinusInf, normp, lmul!, rmul!, diagzero, AdjointAbsVec, TransposeAbsVec,
Expand All @@ -24,7 +24,8 @@ import Base: oneto
"""
AbstractFill{T, N, Axes} <: AbstractArray{T, N}
Supertype for lazy array types whose entries are all equal to constant.
Supertype for lazy array types whose entries are all equal.
Subtypes of `AbstractFill` should implement [`FillArrays.getindex_value`](@ref) to return the value of the entries.
"""
abstract type AbstractFill{T, N, Axes} <: AbstractArray{T, N} end
const AbstractFillVector{T} = AbstractFill{T,1}
Expand All @@ -33,6 +34,10 @@ const AbstractFillVecOrMat{T} = Union{AbstractFillVector{T},AbstractFillMatrix{T

==(a::AbstractFill, b::AbstractFill) = axes(a) == axes(b) && getindex_value(a) == getindex_value(b)

@inline function Base.isassigned(F::AbstractFill, i::Integer...)
@boundscheck checkbounds(Bool, F, to_indices(F, i)...) || return false
return true
end

@inline function _fill_getindex(F::AbstractFill, kj::Integer...)
@boundscheck checkbounds(F, kj...)
Expand Down Expand Up @@ -142,7 +147,7 @@ Fill{T,0}(x, ::Tuple{}) where T = Fill{T,0,Tuple{}}(convert(T, x)::T, ()) # ambi
@inline size(F::Fill) = map(length, F.axes)

"""
getindex_value(F::AbstractFill)
FillArrays.getindex_value(F::AbstractFill)
Return the value that `F` is filled with.
Expand Down Expand Up @@ -572,14 +577,32 @@ sum(x::AbstractZeros) = getindex_value(x)

# needed to support infinite case
steprangelen(st...) = StepRangeLen(st...)
cumsum(x::AbstractFill{<:Any,1}) = steprangelen(getindex_value(x), getindex_value(x), length(x))
function cumsum(x::AbstractFill{T,1}) where T
V = promote_op(add_sum, T, T)
steprangelen(convert(V,getindex_value(x)), getindex_value(x), length(x))
end

cumsum(x::AbstractZerosVector) = x
cumsum(x::AbstractZerosVector{Bool}) = x
cumsum(x::AbstractOnesVector{II}) where II<:Integer = convert(AbstractVector{II}, oneto(length(x)))
cumsum(x::AbstractZerosVector{T}) where T = _range_convert(AbstractVector{promote_op(add_sum, T, T)}, x)
cumsum(x::AbstractZerosVector{Bool}) = _range_convert(AbstractVector{Int}, x)
cumsum(x::AbstractOnesVector{T}) where T<:Integer = _range_convert(AbstractVector{promote_op(add_sum, T, T)}, oneto(length(x)))
cumsum(x::AbstractOnesVector{Bool}) = oneto(length(x))


for op in (:+, :-)
@eval begin
function accumulate(::typeof($op), x::AbstractFill{T,1}) where T
V = promote_op($op, T, T)
steprangelen(convert(V,getindex_value(x)), $op(getindex_value(x)), length(x))
end

accumulate(::typeof($op), x::AbstractZerosVector{T}) where T = _range_convert(AbstractVector{promote_op($op, T, T)}, x)
accumulate(::typeof($op), x::AbstractZerosVector{Bool}) = _range_convert(AbstractVector{Int}, x)
end
end

accumulate(::typeof(+), x::AbstractOnesVector{T}) where T<:Integer = _range_convert(AbstractVector{promote_op(+, T, T)}, oneto(length(x)))
accumulate(::typeof(+), x::AbstractOnesVector{Bool}) = oneto(length(x))

#########
# Diff
#########
Expand Down Expand Up @@ -644,8 +667,18 @@ end

# In particular, these make iszero(Eye(n)) efficient.
# use any/all on scalar to get Boolean error message
any(f::Function, x::AbstractFill) = !isempty(x) && any(f(getindex_value(x)))
all(f::Function, x::AbstractFill) = isempty(x) || all(f(getindex_value(x)))
function any(f::Function, x::AbstractFill)
isempty(x) && return false
# If the condition is true for one value, then it's true for all
fval = f(getindex_value(x))
any((fval,))
end
function all(f::Function, x::AbstractFill)
isempty(x) && return true
# If the condition is true for one value, then it's true for all
fval = f(getindex_value(x))
return all((fval,))
end
any(x::AbstractFill) = any(identity, x)
all(x::AbstractFill) = all(identity, x)

Expand Down
Loading

0 comments on commit 7771273

Please sign in to comment.