-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
663 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,27 @@ uuid = "a07dfc7f-7d04-4eb5-84cc-a97f051f655a" | |
authors = ["ITensor developers <[email protected]> and contributors"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
ExproniconLite = "55351af7-c7e9-48d6-89ff-24e801d99491" | ||
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078" | ||
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138" | ||
|
||
[compat] | ||
Adapt = "4.1.1" | ||
Aqua = "0.8.9" | ||
ExproniconLite = "0.10.13" | ||
MLStyle = "0.4.17" | ||
SafeTestsets = "0.1" | ||
Suppressor = "0.2" | ||
Test = "1.10" | ||
julia = "1.10" | ||
|
||
[extras] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" | ||
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Aqua", "Test", "Suppressor", "SafeTestsets"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Fix this, there is a namespace issue: | ||
# Use `GlobalRef`, use a generalization of `globalref_derive`. | ||
function derive(::Val{:AbstractArrayOps}, type) | ||
return quote | ||
ArrayLayouts.MemoryLayout(::Type{<:$type}) | ||
LinearAlgebra.mul!(::Any, ::$type, ::$type, ::Number, ::Number) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
using Derive: Derive | ||
using Documenter: Documenter, DocMeta, deploydocs, makedocs | ||
|
||
DocMeta.setdocmeta!( | ||
Derive, :DocTestSetup, :(using Derive); recursive=true | ||
) | ||
DocMeta.setdocmeta!(Derive, :DocTestSetup, :(using Derive); recursive=true) | ||
|
||
include("make_index.jl") | ||
|
||
|
@@ -12,13 +10,9 @@ makedocs(; | |
authors="ITensor developers <[email protected]> and contributors", | ||
sitename="Derive.jl", | ||
format=Documenter.HTML(; | ||
canonical="https://ITensor.github.io/Derive.jl", | ||
edit_link="main", | ||
assets=String[], | ||
canonical="https://ITensor.github.io/Derive.jl", edit_link="main", assets=String[] | ||
), | ||
pages=["Home" => "index.md"], | ||
) | ||
|
||
deploydocs(; | ||
repo="github.com/ITensor/Derive.jl", devbranch="main", push_preview=true | ||
) | ||
deploydocs(; repo="github.com/ITensor/Derive.jl", devbranch="main", push_preview=true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
module Derive | ||
|
||
# Write your package code here. | ||
include("interface_function.jl") | ||
include("abstractinterface.jl") | ||
include("derive_macro.jl") | ||
include("interface_macro.jl") | ||
include("wrappedarrays.jl") | ||
include("abstractarrayinterface.jl") | ||
include("defaultarrayinterface.jl") | ||
include("traits.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# TODO: Add `ndims` type parameter. | ||
abstract type AbstractArrayInterface <: AbstractInterface end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Get the interface of an object. | ||
interface(x) = interface(typeof(x)) | ||
# TODO: Define as `DefaultInterface()`. | ||
interface(::Type) = error("Interface unknown.") | ||
|
||
# Adapted from `Base.Broadcast.combine_styles`. | ||
# Get the combined interfaces of the input objects. | ||
function combine_interfaces(x1, x2, x_rest...) | ||
return combine_interfaces(combine_interfaces(x1, x2), x_rest...) | ||
end | ||
combine_interfaces(x1, x2) = comine_interface_rule(interface(x1), interface(x2)) | ||
combine_interfaces(x) = interface(x) | ||
|
||
# Rules for combining interfaces. | ||
function combine_interface_rule( | ||
interface1::Interface, interface2::Interface | ||
) where {Interface} | ||
return interface1 | ||
end | ||
# TODO: Define as `UnknownInterface()`. | ||
combine_interface_rule(interface1, interface2) = error("No rule for combining interfaces.") | ||
|
||
abstract type AbstractInterface end | ||
|
||
(interface::AbstractInterface)(f) = InterfaceFunction(interface, f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# TODO: Add `ndims` type parameter. | ||
struct DefaultArrayInterface <: AbstractArrayInterface end | ||
|
||
using TypeParameterAccessors: parenttype | ||
function interface(a::Type{<:AbstractArray}) | ||
parenttype(a) === a && return DefaultArrayInterface() | ||
return interface(parenttype(a)) | ||
end |
Oops, something went wrong.