-
Notifications
You must be signed in to change notification settings - Fork 190
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
Tensor value insertion APIs #85
Comments
I really think we should rethink these semantics. Matlab, Eigen don't have these semantics and I think more generally, this violates the principle of least surprise. Instead, can we use some form of |
From the user's perspective, I think it's important to have a way to add elements into the tensor without having to care if that element was 0 previously. So,
|
@sueda I see that |
Thanks for reopening this and I agree with all the above concerns. The current thinking is that we have a concept of a stash. When you insert values they go into the stash and the values in the stash are not a part of the tensor until you pack them. This design was intended to match the Eigen triplet insertion that @sueda mentions, but I'm not very comfortable that it's hidden inside I propose the following design to make the stash concept explicit (and to get closer to the Eigen triplet insertion). We add a new class called // What to do with duplicates
enum DuplicatePolicy {Sum, Last};
// Method to pack a ValueList into a tensor
void TensorBase::pack(const ValueList&, DuplicatePolicy);
// Factory function to construct tensors from ValueLists?
TensorBase pack(const ValueList&, DuplicatePolicy); |
I agree with @shoaibkamil that we should provide semantics to actually read and insert into a tensor. For this maybe we should try to make it work with integers to index into A(0,1) = 1;
A(0,1) += 1; We have to be pretty clear about the unpredictable performance semantics of these operations in the documentation if we provide them. For dense storage it's not a problem ( Maybe we can provide both this and the |
@sueda Do you generally avoid direct indexing into sparse matrices in a Matlab codes in favor of constructing them from some triplet list-like form? |
@fredrikbk I use direct indexing in Matlab because I usually start with dense matrices and switch to sparse later. With direct indexing, I don't have to change the code. I am sure it is slower than creating a triplet list and then creating a matrix from it. |
@sueda that makes sense. Perhaps you'd be able to use |
@fredrikbk I use direct indexing in Matlab for portability between dense/sparse, but I am equally happy with triplet insertion. I am wondering if adding such an interface to |
To ease matrix assembly in finite element codes we should support duplicate entry insertions into tensors. These entries should be summed before packing. This feature was asked for by @sueda.
The text was updated successfully, but these errors were encountered: