Skip to content
Open
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 Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MapBroadcast"
uuid = "ebd9b9da-f48d-417c-9660-449667d60261"
version = "0.1.12"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.1.11"

[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Expand Down
22 changes: 11 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using MapBroadcast: MapBroadcast
using Documenter: Documenter, DocMeta, deploydocs, makedocs

DocMeta.setdocmeta!(MapBroadcast, :DocTestSetup, :(using MapBroadcast); recursive=true)
DocMeta.setdocmeta!(MapBroadcast, :DocTestSetup, :(using MapBroadcast); recursive = true)

include("make_index.jl")

makedocs(;
modules=[MapBroadcast],
authors="ITensor developers <[email protected]> and contributors",
sitename="MapBroadcast.jl",
format=Documenter.HTML(;
canonical="https://itensor.github.io/MapBroadcast.jl",
edit_link="main",
assets=["assets/favicon.ico", "assets/extras.css"],
),
pages=["Home" => "index.md", "Reference" => "reference.md"],
modules = [MapBroadcast],
authors = "ITensor developers <[email protected]> and contributors",
sitename = "MapBroadcast.jl",
format = Documenter.HTML(;
canonical = "https://itensor.github.io/MapBroadcast.jl",
edit_link = "main",
assets = ["assets/favicon.ico", "assets/extras.css"],
),
pages = ["Home" => "index.md", "Reference" => "reference.md"],
)

deploydocs(; repo="github.com/ITensor/MapBroadcast.jl", devbranch="main", push_preview=true)
deploydocs(; repo = "github.com/ITensor/MapBroadcast.jl", devbranch = "main", push_preview = true)
16 changes: 8 additions & 8 deletions docs/make_index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using MapBroadcast: MapBroadcast

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
```@raw html
<img class="display-light-only" src="assets/CCQ.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
<img class="display-dark-only" src="assets/CCQ-dark.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
```
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(MapBroadcast), "examples", "README.jl"),
joinpath(pkgdir(MapBroadcast), "docs", "src");
flavor=Literate.DocumenterFlavor(),
name="index",
postprocess=ccq_logo,
joinpath(pkgdir(MapBroadcast), "examples", "README.jl"),
joinpath(pkgdir(MapBroadcast), "docs", "src");
flavor = Literate.DocumenterFlavor(),
name = "index",
postprocess = ccq_logo,
)
16 changes: 8 additions & 8 deletions docs/make_readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using MapBroadcast: MapBroadcast

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
<picture>
<source media="(prefers-color-scheme: dark)" width="20%" srcset="docs/src/assets/CCQ-dark.png">
<img alt="Flatiron Center for Computational Quantum Physics logo." width="20%" src="docs/src/assets/CCQ.png">
</picture>
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(MapBroadcast), "examples", "README.jl"),
joinpath(pkgdir(MapBroadcast));
flavor=Literate.CommonMarkFlavor(),
name="README",
postprocess=ccq_logo,
joinpath(pkgdir(MapBroadcast), "examples", "README.jl"),
joinpath(pkgdir(MapBroadcast));
flavor = Literate.CommonMarkFlavor(),
name = "README",
postprocess = ccq_logo,
)
2 changes: 1 addition & 1 deletion examples/README.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# # MapBroadcast.jl
#
#
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://itensor.github.io/MapBroadcast.jl/stable/)
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://itensor.github.io/MapBroadcast.jl/dev/)
# [![Build Status](https://github.com/ITensor/MapBroadcast.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/MapBroadcast.jl/actions/workflows/Tests.yml?query=branch%3Amain)
Expand Down
42 changes: 21 additions & 21 deletions src/linearcombination.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using Base.Broadcast: Broadcasted
struct LinearCombination{C} <: Function
coefficients::C
coefficients::C
end
coefficients(a::LinearCombination) = a.coefficients
function (f::LinearCombination)(args...)
return mapreduce(*,+,coefficients(f),args)
return mapreduce(*, +, coefficients(f), args)
end

struct Summed{Style,N,C<:NTuple{N,Any},A<:NTuple{N,Any}}
style::Style
coefficients::C
arguments::A
struct Summed{Style, N, C <: NTuple{N, Any}, A <: NTuple{N, Any}}
style::Style
coefficients::C
arguments::A
end
Summed(a::Summed) = a
coefficients(a::Summed) = a.coefficients
Expand All @@ -20,25 +20,25 @@ LinearCombination(a::Summed) = LinearCombination(coefficients(a))
using Base.Broadcast: combine_axes
Base.axes(a::Summed) = combine_axes(a.arguments...)
function Base.eltype(a::Summed)
cts = typeof.(coefficients(a))
elts = eltype.(arguments(a))
ts = map((ct, elt) -> Base.promote_op(*, ct, elt), cts, elts)
return Base.promote_op(+, ts...)
cts = typeof.(coefficients(a))
elts = eltype.(arguments(a))
ts = map((ct, elt) -> Base.promote_op(*, ct, elt), cts, elts)
return Base.promote_op(+, ts...)
end
function Base.getindex(a::Summed, I...)
return mapreduce(+, coefficients(a), arguments(a)) do c, a
return c * a[I...]
end
return mapreduce(+, coefficients(a), arguments(a)) do c, a
return c * a[I...]
end
end
using Base.Broadcast: combine_styles
function Summed(coefficients::Tuple, arguments::Tuple)
return Summed(combine_styles(arguments...), coefficients, arguments)
return Summed(combine_styles(arguments...), coefficients, arguments)
end
Summed(a) = Summed((one(eltype(a)),), (a,))
function Base.:+(a::Summed, b::Summed)
return Summed(
(coefficients(a)..., coefficients(b)...), (arguments(a)..., arguments(b)...)
)
return Summed(
(coefficients(a)..., coefficients(b)...), (arguments(a)..., arguments(b)...)
)
end
Base.:-(a::Summed, b::Summed) = a + (-b)
Base.:+(a::Summed, b::AbstractArray) = a + Summed(b)
Expand All @@ -54,15 +54,15 @@ Base.similar(a::Summed) = similar(a, eltype(a))
Base.similar(a::Summed, elt::Type) = similar(a, elt, axes(a))
Base.similar(a::Summed, ax::Tuple) = similar(a, eltype(a), ax)
function Base.similar(a::Summed, elt::Type, ax::Tuple)
return similar(Broadcasted(a), elt, ax)
return similar(Broadcasted(a), elt, ax)
end
Base.copy(a::Summed) = copyto!(similar(a), a)
function Base.copyto!(dest::AbstractArray, a::Summed)
return copyto!(dest, Broadcasted(a))
return copyto!(dest, Broadcasted(a))
end
function Broadcast.Broadcasted(a::Summed)
f = LinearCombination(a)
return Broadcasted(style(a), f, arguments(a), axes(a))
f = LinearCombination(a)
return Broadcasted(style(a), f, arguments(a), axes(a))
end

using Base.Broadcast: Broadcast
Expand Down
Loading