Skip to content

Added new implementation to Identity tensor#4

Merged
jmartfrut merged 4 commits into
mainfrom
mmaso/identity
Sep 9, 2025
Merged

Added new implementation to Identity tensor#4
jmartfrut merged 4 commits into
mainfrom
mmaso/identity

Conversation

@miguelmaso
Copy link
Copy Markdown
Collaborator

Description
Changes in TensorAlgebra. Identity tensors are exported as variables I2, I3..., instead of functions I2(), I3()...

A private function to construct the identity without hardcoded values has been added:

const I_(N) = TensorValue{N,N,Float64}(ntuple-> begin
  i,j = _full_idx2(α,N)
  i==j ? 1.0 : 0.0
end,N*N))

This function is compile-time thanks to ntuple. It can be checked with @benchamrk that both implementations are equivalent, see the TensorAlgebra tests.

All the required replacements in PhysicalModels have been done.

Its better to wait #3 to be merged and use the CI.

@miguelmaso miguelmaso requested a review from jmartfrut September 9, 2025 08:58
@miguelmaso miguelmaso self-assigned this Sep 9, 2025
@jmartfrut jmartfrut merged commit 56dfc7b into main Sep 9, 2025
3 checks passed
@miguelmaso miguelmaso deleted the mmaso/identity branch September 10, 2025 21:19
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

Successfully merging this pull request may close these issues.

2 participants