Opened 2 years ago

Last modified 2 years ago

#28562 closed enhancement

Tensor Fields: Better Zero Treatment — at Version 14

Reported by: gh-DeRhamSource Owned by:
Priority: major Milestone: sage-9.0
Component: geometry Keywords: manifolds, tensor fields, scalar fields, mixed forms
Cc: tscrim, egourgoulhon Merged in:
Authors: Michael Jung Reviewers:
Report Upstream: N/A Work issues:
Branch: u/gh-DeRhamSource/better_zero_treatment (Commits, GitHub, GitLab) Commit: 5d30100a5f1e4f809867dc5b564000cd2eddc9db
Dependencies: Stopgaps:

Status badges

Description (last modified by gh-DeRhamSource)

The zero element is always a special element. Therefore it should be treated as such. It should shorten computations and certainly be immutable. This ticket is devoted to that topic. (Similarly for the one element in the scalar field and mixed form algebra).

This ticket is part of the metaticket #28519.

Features

  • an assertion error arises when altering the fixed elements zero or one
  • a new attribute _is_zero is added to tensor fields and mixed form (similar to scalar fields)
  • computations with involved zero or one are shortened by using a simple check
  • due to immutability of algebra elements, no copies are returned anymore for scalar field operations with zero or one
  • _is_zero attribute is applied for copies

Change History (14)

comment:1 Changed 2 years ago by gh-DeRhamSource

  • Branch set to u/gh-DeRhamSource/better_zero_treatment

comment:2 Changed 2 years ago by gh-DeRhamSource

  • Commit set to 9f91503dce5cbe14f52a6a77a34ae5a18f722f7d
  • Description modified (diff)

New commits:

9f91503'_is_zero' attribute added and modified

comment:3 Changed 2 years ago by git

  • Commit changed from 9f91503dce5cbe14f52a6a77a34ae5a18f722f7d to 5094a3e802034be5916879a0225e5db2ccf9f0f8

Branch pushed to git repo; I updated commit sha1. New commits:

5094a3eReturn no copies for scalar field operations

comment:4 Changed 2 years ago by gh-DeRhamSource

  • Description modified (diff)

comment:5 Changed 2 years ago by gh-DeRhamSource

  • Description modified (diff)

comment:6 Changed 2 years ago by git

  • Commit changed from 5094a3e802034be5916879a0225e5db2ccf9f0f8 to 94cf06ab1ab5d87fbc8efc73d2688ea1c8c91267

Branch pushed to git repo; I updated commit sha1. New commits:

ca8dd88Modules modified
892050eFreeModuleLinearGroup: one treatment
1b96587Zero treatment for FreeModules
b9c8287AutomorphismField: zero treatment + MixedForm: set_restriction and add_comp_by_continuation
94cf06aMixed forms adapted to zero treatment + zero treatment for scalar fields

comment:7 Changed 2 years ago by gh-DeRhamSource

  • Component changed from PLEASE CHANGE to geometry
  • Status changed from new to needs_review

comment:8 Changed 2 years ago by gh-DeRhamSource

In MixedForm, the zero (and one element for scalar fields) is treated separately. The code in there is not very beautiful, but it works for now. However, I plan to reorganize the code of mixed forms anyway (see #28519).

Last edited 2 years ago by gh-DeRhamSource (previous) (diff)

comment:9 Changed 2 years ago by gh-DeRhamSource

Also, I removed the _zero_element attribute in the free modules and replaced it by a cached zero() method. This is a better solution, I guess.

comment:10 Changed 2 years ago by git

  • Commit changed from 94cf06ab1ab5d87fbc8efc73d2688ea1c8c91267 to d949a13db29334e193ec9ff05fd7fe53deb65422

Branch pushed to git repo; I updated commit sha1. New commits:

d949a13Minor code reduction

comment:11 Changed 2 years ago by git

  • Commit changed from d949a13db29334e193ec9ff05fd7fe53deb65422 to 5d30100a5f1e4f809867dc5b564000cd2eddc9db

Branch pushed to git repo; I updated commit sha1. New commits:

5d30100More code reduction

comment:12 Changed 2 years ago by gh-DeRhamSource

The code snippet (see commits 5d30100 and ​d949a13) was quite messy. Well, it still is. At least it is readable and works for now. It gets a little bit better after merging (see #28519).

I will think about a better solution. But I guess, this requires a complete reorganization of the mixed form code.

Last edited 2 years ago by gh-DeRhamSource (previous) (diff)

comment:13 Changed 2 years ago by gh-DeRhamSource

  • Status changed from needs_review to needs_info

After a bit of thinking, I came to the conclusion that the code snippet should be obsolete. (As a mathematician, I feel the urge to solve or fix a problem/error as soon as it occurs. Here: Doctest errors.) The thing is, due to our little discussion in #28519, the doctest must be flawed since mixed forms defined via preconstructed forms get altered.

So, I 'm going to delete this snippet again and modify the affected doctests.

Do you agree with my conclusion and procedure?

A further doctest change is devoted to #28578.

Last edited 2 years ago by gh-DeRhamSource (previous) (diff)

comment:14 Changed 2 years ago by gh-DeRhamSource

  • Description modified (diff)
Note: See TracTickets for help on using tickets.