AngouriMath.Convenience
Classes within the AngouriMath.Convenience namespace
ISettingState
Summary
A setting, without its value's type — enough to ask what it currently reads as.Setting`1
Summary
This class for configuring some internal mechanisms from outside
Type parameter "T"
Those configurations can be of different types
Remarks
A setting is one object for the whole process, and what it holds is per *flow*, not
per thread: the stacks of values of every setting live in one
AsyncLocal`1, as a State. A scope
opened before anawait is therefore still in force after it, and a
scope opened inside a task is invisible to that task's siblings and to whatever
started it. Backing the field with[ThreadStatic] gave neither: a continuation
resumed on a pool thread saw the defaults, and a thread returned to the pool carried
whatever scope was left on it into the next caller.
The states are immutable, which is what makes the reference safe to share. An
AsyncLocal`1 copies on assignment to Value and on nothing else, so if a state could be mutated in place, two flows holding it
would write over each other. Opening and closing a scope therefore assign another
state, rather than editing one.
SettingsDependent`1
Summary
A cached value that depends on the settings it was computed under -- an evaluation, whose
numbers are rounded by the precision and the zero range, and anything computed from one.
Answered only under the settings it was computed under: Current is the stamp, and a value computed with every setting at its default is held as it is, so
that the common case costs no more than LazyPropertyA`1.
Equal to every other, as a cache on a record has to be, so that it takes no part in the
record's equality.
https://github.com/asc-community/AngouriMath/issues/2479
SettingsStamped
Summary
A value of a SettingsDependent`1 with the state it was computed under,
null for the defaults, and the one value before it computed under another
state, if any. Two are kept because the library's own scopes ask a node under two states in
turn --Solve 's, and its analytical solver's inside it, with the zero range at 1e-7 --
and one slot recomputed the value at every turn: 46% more allocation on solving a quadratic.
Not generic, so that the type test on every read needs no lookup of the type in the code
shared between the instantiations over reference types.
SettingsState
Summary
What every setting reads as, taken together, as one object, so that something holding a
result computed under the settings of a moment can tell whether those settings still hold
with one async-local read and one reference comparison.
Remarks
A state and not a change count. Counting changes looks equivalent and is not: a
scope opened and closed leaves every setting exactly as it found it while moving a
counter twice, and the library opens such scopes constantly — a single
Simplify of one unevaluated integral opened 3520 of them, all four from
numeric downcasting inNumber/Operators.cs . A counter therefore reports
"everything has changed" continuously and is useless to a cache. Measured, not assumed:
the counter was built first and threw away the whole benefit.
A State is reached from the defaults by the scopes opened to reach it,
setting by setting and value by value, and is made once for each path: opening a scope of
a setting at a value from a state gives the state it gave before. So the scopes the
library opens on every call —Solve opens two — reach the same state on every
call, and a value cached under them is found again. A scope closed in order puts back
the very state it replaced, so a balanced open and close compares equal, and one closed out
of order reaches the state the scopes left open reach. Values compare by
Equals(System.Object), so a value compared by reference only is conservative:
it reaches a state of its own, and a value cached under it is not found again.
https://github.com/asc-community/AngouriMath/issues/2479
Angouri © 2019-2026 · Project's repo · Site's repo · Octicons · Transparency · 6091 pages online