Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Define indexing #8

Closed
ChrisRackauckas opened this issue Jun 7, 2017 · 5 comments
Closed

Define indexing #8

ChrisRackauckas opened this issue Jun 7, 2017 · 5 comments

Comments

@ChrisRackauckas
Copy link
Member

You should define getindex operations so that way indexing works.

@ChrisRackauckas
Copy link
Member Author

Indexing should also automatically give + and -. Though you may want specific fast overloads for standard + and - operations.

@shivin9
Copy link
Contributor

shivin9 commented Jun 8, 2017

Indexing should also automatically give + and -. Though you may want specific fast overloads for standard + and - operations.

Can you explain that comprehensively? Do you mean to add operators to form a sort of composed PDE operator as in LinearMaps?

@ChrisRackauckas
Copy link
Member Author

Lazy composed PDE operators is another thing that's needed, but that should be a separate issue.

Just simple + and - vs AbstractMatrices would be nice, because then you could L + M for any sparse matrix directly without producing a temporary like sparse_full(L) + M. Setting up indexing will make this just work, but you can make it better by setting it up to only loop through the bands. This gives you a way to then compose these even when not every operator can be of this special form.

@shivin9
Copy link
Contributor

shivin9 commented Jun 8, 2017

Some indexing support has also been pushed here.

@shivin9
Copy link
Contributor

shivin9 commented Jun 8, 2017

well there you go

julia> A = LinearOperator{Float64}(2,2,8);
julia> m = ones(8,8);
julia> res = A+m
LinearMaps.LinearCombination{Float64,Tuple{PDEOperators.LinearOperator{Float64,StaticArrays.SVector{3,Float64}},LinearMaps.WrappedMap{Float64,Array{Float64,2}}},Tuple{Float64,Float64}}((PDEOperators.LinearOperator{Float64,StaticArrays.SVector{3,Float64}}(2,2,8,3,[1.0,-2.0,1.0],3,4),LinearMaps.WrappedMap{Float64,Array{Float64,2}}([1.0 1.0  1.0 1.0; 1.0 1.0  1.0 1.0;  ; 1.0 1.0  1.0 1.0; 1.0 1.0  1.0 1.0],true,true,true,false)),(1.0,1.0))

julia> full(res)
8×8 Array{Float64,2}:
 -1.0   2.0   1.0   1.0   1.0   1.0   1.0   1.0
  2.0  -1.0   2.0   1.0   1.0   1.0   1.0   1.0
  1.0   2.0  -1.0   2.0   1.0   1.0   1.0   1.0
  1.0   1.0   2.0  -1.0   2.0   1.0   1.0   1.0
  1.0   1.0   1.0   2.0  -1.0   2.0   1.0   1.0
  1.0   1.0   1.0   1.0   2.0  -1.0   2.0   1.0
  1.0   1.0   1.0   1.0   1.0   2.0  -1.0   2.0
  1.0   1.0   1.0   1.0   1.0   1.0   2.0  -1.0

This "just works" property is too good.

@shivin9 shivin9 closed this as completed Jun 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants