Comments (4)
There's a bigger problem with this premise: eltype(S)
is wrong. It should be Union{Tv, typeof(zero(Tv))}
. Worse: I don't think we can express that in the subtype relationship to AbstractArray
.
from sparsearrays.jl.
So the element type should be promote_type(Tv, typeof(zero(Tv)))
?
From a brief look, the current code tries to avoid calling zero
if the matrix is, in fact, dense. If we want to preserve that, we would need to preserve the element type Tv
in the dense case, i.e.
A = length(S) == nnz(S) ? Matrix{Tv}(undef, S.m, S.n) : zeros(promote_type(Tv, typeof(zero(Tv))), S.m, S.n)
This would lead to a type-instability in the rare case that Tv != typeof(zero(Tv))
. Not sure whether that's a problem.
from sparsearrays.jl.
So the element type should be
promote_type(Tv, typeof(zero(Tv)))
?
Yes, that would work.
This would lead to a type-instability in the rare case that Tv != typeof(zero(Tv)). Not sure whether that's a problem.
In which case does one need to convert a full SparseMatrixCSC
that has an eltype
that does not implement zero
into a Matrix
? Maybe we should just use zeros
in all case.
from sparsearrays.jl.
from the doc of zero
Get the additive identity element for the type of x
this is just wrong.
from sparsearrays.jl.
Related Issues (20)
- Using `@view` leads to 100x performance loss HOT 7
- Loads of warnings about method redefinitions HOT 2
- Wrapper generator needs updating to pick SuiteSparse headers from new location HOT 1
- Single precision support in CHOLMOD HOT 3
- Cholesky F.PtL \ Av where Av is a view does not work HOT 1
- Base.stack is underperforming for SparseArrays HOT 3
- Regression in invalidations caused by SparseArrays HOT 3
- Elementwise multiplication by a view of a dense matrix gives a dense matrix
- `findmin(A; dims=1)` is much slower than manually looping over. HOT 1
- Sparse array of string types HOT 17
- Memory Mapped SparseArrays HOT 3
- Extra allocations when using generalized `mul!` operation
- Attempting to run sparse `qr` produces StackOverflow when run on a sparse matrix of `ForwardDiff.Dual`. HOT 6
- Inconsistent addition between sparse and dense HOT 1
- `ldiv` of `LUFactorization` can throw `SingluarException` HOT 1
- Thread-safe dropstored! HOT 1
- Merge SparseMatricesCSR.jl in HOT 2
- Support zero-based indices HOT 3
- Windows threading tests fail in GitHub Actions CI but pass in Buildkite CI
- Problem when running old benchmarks in Oceananigans HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sparsearrays.jl.