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

Third order tensors and mutable tensors #192

Open
DRollin opened this issue Jan 25, 2023 · 3 comments
Open

Third order tensors and mutable tensors #192

DRollin opened this issue Jan 25, 2023 · 3 comments

Comments

@DRollin
Copy link

DRollin commented Jan 25, 2023

Hello,

I am currently working with sensitivities in multi-scale modelling.
In one case I am considering, third order tensors are used.
However, third order tensors are apparently not full supported e.g. zero(Tensor{3,dim}) errors.
I created a quick solution for my code, but probably it would be nice to have that in general.

Furthermore, the sensitivities are computed part by part, so they are tensors that need to be adapted.
This adaption is like inserting a tensor into another tensor of higher order.
In my case I do the operation using arrays, but maybe it would also be nice to have a general solution for that like mutable tensors or functions doing the insertion.

Just two suggestions. What do you think?
I am also willing to contribute, I am just still a bit unexperienced.

@termi-official
Copy link
Member

Regarding mixed tensors, Knut was so nice and started putting something together in this PR: #188 .

@KnutAM
Copy link
Member

KnutAM commented Aug 12, 2023

Perhaps a @setindex macro could be used for the mutable part, something like

@setindex a[1,:] = a[1,:] + v[:]
# Generates the expression
a = typeof(a)((i,j) -> (i == 1) ? a[i,j] + v[j] : a[i,j]

@KnutAM
Copy link
Member

KnutAM commented Dec 11, 2023

3rd order (partially) supported by #205
Regarding mutability, perhaps a similar strategy to StaticArrays could be useful, overloading the non-exported Base.setindex?
https://juliaarrays.github.io/StaticArrays.jl/stable/pages/api/#Base.setindex-Tuple{StaticArray,%20Any,%20Int64}

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

No branches or pull requests

3 participants