Comments (2)
ComponentArray
s used to be able to hold any type of internal array, including Diagonal
with its internal storage of a single vector, but I had to change this to get sane linear algebra method handling.
Since the LinearAlgebra
methods only dispatch on whether something is a subtype of StridedArray
/DenseArray
, you have to either restrict array wrapper types like ComponentArray
s to only wrap StridedArray
/DenseArray
s so they can be passed to BLAS routines by pointer or manually overload all of the LinearAlgebra methods. I used to have it set up where I wrote all of the linear algebra methods by hand, but this led to a method ambiguity hell. Every new type of AbstractArray
that someone wanted to multiply/divide/whatever with ComponentArray
s needed a special method overload. After a few issues were filed, I decided to give up on that method and just force the inner arrays to be strided/dense.
Another approach I tried was making ComponentArray
be a union of StridedComponentArray
and NonStridedComponentArray
concrete realizations. This way it would just dispatch to the correct one based on what the underlying array type was. Unfortunately, this made getproperty
/getindex
unable to be inferred and performance dropped off a cliff. I basically have no idea what makes constant propagation work or not and a lot of the new features I've tried to implement have failed because of this. I still think there might be a way to handle the Strided
/NonStridedComponentArray
thing, by writing separate methods for getindex
/getproperty
for each type and not trying to dispatch in the return of the @generated
function.
As far as features I'd like to implement, this is at the top of my list since it would allow for StaticArray
s and CuArray
s, which I've wanted to have back for a while now. I would still have to write manual LinearAlgebra methods for the NonStridedComponentArray
s, but I'm okay with that because at least the "normal" version wouldn't need them and I'd probably get fewer issues coming in.
But the bigger issue is that we need a version of LinearAlgebra
that dispatches on traits rather than supertypes. If you look through all of the other array wrapper type libraries, they all tend to have the same issues filed for method ambiguities. There are a few issues filed in the std repo about it, but they seemed to have lost traction. Maybe I'll try to revive that discussion.
from componentarrays.jl.
Thanks for your detailed explanation. I recognize the issues you're describing with method ambiguities, they appear all too often when implementing a type that behaves like another, standard type.
Thanks for this package, it makes replacing simulink/modelica a breeze while keeping the model as code rather than a bunch of boxes and lines in a gui.
from componentarrays.jl.
Related Issues (20)
- Typeerror when computing the Hessian HOT 2
- `map` returns a plain array when iterating multiple inputs HOT 6
- Scalar indexing of a GPU array error HOT 5
- Add GPU testing HOT 5
- cannot broadcast on gpu(x) HOT 3
- `DiffEqBase.UNITLESS_ABS2` failing on GPU componentarrays HOT 10
- Make `map` output consistent with the rest of broadcasting
- Fix constructor for GPU arrays HOT 4
- ComponentArray with scalars on GPU HOT 2
- Unnecessary allocation when not unpacking? HOT 2
- Overlapping labels HOT 1
- How to efficiently access first element of all subarrays, i.e. [:,1] or explicitly [(:SWATI, :GWAT),:amt] HOT 3
- hcat: type unstable based on the number of arguments HOT 3
- Cannot create zero-length ComponentArray HOT 4
- Indexing over zero-length lists or arrays fails HOT 1
- Indexing over length-1 vector of symbols fails HOT 1
- Construction of ComponentArray inside of AD/Zygote HOT 2
- Compatibility with BlockArrays? HOT 4
- Compatibility with OffsetArrays HOT 2
- `similar` for GPU ComponentArrays
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 componentarrays.jl.