Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
interval: "weekly"
2 changes: 0 additions & 2 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: CompatHelper

on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:

jobs:
CompatHelper:
runs-on: ubuntu-latest
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
name: TagBot

on:
issue_comment:
types:
- created
workflow_dispatch:

inputs:
lookback:
default: "3"
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand Down
32 changes: 19 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
actions: write
contents: read
strategy:
fail-fast: false
matrix:
version:
- '1.6' # LTS version
- '1.8' # lowest TensorOperations version
- 'lts' # LTS version
- '1' # automatically expands to the latest stable 1.x release of Julia
os:
- ubuntu-latest
Expand All @@ -31,42 +36,43 @@ jobs:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
# env:
# JULIA_NUM_THREADS: 4
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
test-nightly:
needs: test
name: Julia nightly - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
actions: write
contents: read
strategy:
fail-fast: false
fail-fast: true
matrix:
version:
- 'pre' # automatically expands to the latest pre-release of Julia
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
# env:
# JULIA_NUM_THREADS: 4
18 changes: 11 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SparseArrayKit"
uuid = "a9a3c162-d163-4c15-8926-b8794fbefed2"
authors = ["Lukas Devos <lukas.devos@ugent.be>", "Maarten Van Damme <maartenvd1994@gmail.com>", "Jutho Haegeman <jutho.haegeman@ugent.be>"]
version = "0.3.1"
version = "0.4"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -12,28 +12,32 @@ VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"

[weakdeps]
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"

[extensions]
SparseArrayKitSparseArrays = "SparseArrays"
SparseArrayKitTensorOperations = "TensorOperations"

[compat]
Aqua = "0.8"
LinearAlgebra = "1"
PackageExtensionCompat = "1"
TensorOperations = "4"
Random = "1"
SparseArrays = "1"
Strided = "2"
Test = "1"
TestExtras = "0.3"
TensorOperations = "5"
TupleTools = "1.1"
VectorInterface = "0.4.1"
julia = "1.6"
julia = "1.8"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"

[targets]
test = ["Test", "TestExtras", "TensorOperations", "Strided", "Random", "LinearAlgebra", "SparseArrays", "Aqua"]
test = ["Test", "TestExtras", "Strided", "Random", "LinearAlgebra", "SparseArrays", "Aqua"]
36 changes: 0 additions & 36 deletions ext/SparseArrayKitTensorOperations.jl

This file was deleted.

3 changes: 1 addition & 2 deletions src/SparseArrayKit.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module SparseArrayKit

using VectorInterface
using TensorOperations
using LinearAlgebra
using TupleTools

const IndexTuple{N} = NTuple{N,Int}

export SparseArray
export nonzero_pairs, nonzero_keys, nonzero_values, nonzero_length

Expand Down
2 changes: 1 addition & 1 deletion src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end

# array manipulation
function Base.permutedims!(dst::SparseArray, src::SparseArray, p)
return tensoradd!(dst, tuple(p...), src, :N, true, false)
return tensoradd!(dst, src, (tuple(p...), ()), false)
end

function Base.reshape(parent::SparseArray{T}, dims::Dims) where {T}
Expand Down
14 changes: 9 additions & 5 deletions src/linearalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ const ASM{T} = Union{SparseArray{T,2},

LinearAlgebra.mul!(C::SM, A::ASM, B::ASM) = mul!(C, A, B, one(eltype(C)), zero(eltype(C)))
function LinearAlgebra.mul!(C::SM, A::ASM, B::ASM, α::Number, β::Number)
CA = A isa Adjoint ? :C : :N
CB = B isa Adjoint ? :C : :N
conjA = A isa Adjoint
conjB = B isa Adjoint
oindA = A isa Union{Adjoint,Transpose} ? (2,) : (1,)
cindA = A isa Union{Adjoint,Transpose} ? (1,) : (2,)
oindB = B isa Union{Adjoint,Transpose} ? (1,) : (2,)
Expand All @@ -87,8 +87,12 @@ function LinearAlgebra.mul!(C::SM, A::ASM, B::ASM, α::Number, β::Number)
AA = A isa Union{Adjoint,Transpose} ? parent(A) : A
BB = B isa Union{Adjoint,Transpose} ? parent(B) : B

return tensorcontract!(C, (1, 2), AA, CA, oindA, cindA, BB, CB, oindB, cindB, α, β)
return tensorcontract!(C, AA, (oindA, cindA), conjA, BB, (cindB, oindB), conjB,
((1, 2), ()), α,
β)
end

LinearAlgebra.adjoint!(C::SM, A::SM) = tensoradd!(C, (2, 1), A, :C, One(), Zero())
LinearAlgebra.transpose!(C::SM, A::SM) = tensoradd!(C, (2, 1), A, :N, One(), Zero())
LinearAlgebra.adjoint!(C::SM, A::SM) = tensoradd!(C, A, ((2, 1), ()), true, One(), Zero())
function LinearAlgebra.transpose!(C::SM, A::SM)
return tensoradd!(C, A, ((2, 1), ()), false, One(), Zero())
end
9 changes: 9 additions & 0 deletions src/sparsearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ function SparseArray{T}(::UndefInitializer, dims::Dims{N}) where {T,N}
return SparseArray{T,N}(undef, dims)
end
SparseArray{T}(::UndefInitializer, dims...) where {T} = SparseArray{T}(undef, dims)
function SparseArray{T}(a::UniformScaling, dims::Dims{2}) where {T}
A = SparseArray{T}(undef, dims)
for i in 1:min(dims...)
A[i, i] = a[1, 1]
end
return A
end
SparseArray(a::UniformScaling, dims::Dims{2}) = SparseArray{eltype(a)}(a, dims)
SparseArray(a::UniformScaling, d1::Int, d2::Int) = SparseArray{eltype(a)}(a, (d1, d2))

nonzero_pairs(a::SparseArray) = pairs(a.data)
nonzero_keys(a::SparseArray) = keys(a.data)
Expand Down
Loading