Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redefine eye, and add Cartesian indexing #313

Merged
merged 4 commits into from
Mar 31, 2018
Merged

redefine eye, and add Cartesian indexing #313

merged 4 commits into from
Mar 31, 2018

Conversation

mforets
Copy link
Member

@mforets mforets commented Mar 31, 2018

Closes #308.

@@ -61,7 +61,10 @@ end
SparseMatrixExp(M::Matrix{N}) where {N} =
error("only sparse matrices can be used to create a `SparseMatrixExp`")

Base.eye(spmexp::SparseMatrixExp) = eye(spmexp.M)
Base.eye(spmexp::SparseMatrixExp) = SparseMatrixExp(zeros(spmexp.M))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spzeros would be more efficient, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spzeros(::SparseMatrixCSC) doesn't exist, but we can change it to Base.eye(spmexp::SparseMatrixExp) = SparseMatrixExp(spzeros(size(E.M)...)).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is what I meant.

Base.eye(spmexp::SparseMatrixExp) = SparseMatrixExp(zeros(spmexp.M))

Base.IndexStyle(::Type{<:SparseMatrixExp}) = IndexCartesian()
Base.getindex(spmexp::SparseMatrixExp{N}, I::Vararg{Int, 2}) where {N} = get_column(spmexp, I[2])[I[1]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can omit the type N if you do not use it on the r.h.s.

@@ -61,10 +61,10 @@ end
SparseMatrixExp(M::Matrix{N}) where {N} =
error("only sparse matrices can be used to create a `SparseMatrixExp`")

Base.eye(spmexp::SparseMatrixExp) = SparseMatrixExp(zeros(spmexp.M))
Base.eye(spmexp::SparseMatrixExp) = SparseMatrixExp(spzeros(size(E.M)...))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is E?

@mforets
Copy link
Member Author

mforets commented Mar 31, 2018

merge?

@schillic schillic merged commit 84e80fb into master Mar 31, 2018
@schillic schillic deleted the mforets/308 branch March 31, 2018 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants