-
Notifications
You must be signed in to change notification settings - Fork 32
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
Conversation
src/ExponentialMap.jl
Outdated
@@ -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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)...))
.
There was a problem hiding this comment.
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.
src/ExponentialMap.jl
Outdated
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]] |
There was a problem hiding this comment.
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.
src/ExponentialMap.jl
Outdated
@@ -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)...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is E
?
merge? |
Closes #308.