Closed opeltre closed 3 years ago
Creation of normalisation matrix fixed by #9 : local_masses = from_scalar @ from_scalar.T
Domain instance creation now *10 faster
Problem: from_scalar
and to_scalar
have different source/target domains - operator degree is not enough
Functional.__init__
to have source and target domainsN.B: Only nerve creation is costly in System.__init__
when close=sort=False.
The nerve could be passed as argument as well. Probably use another class method not to multiply __init__
's arguments.
Maybe System.closure(...)
or System.nerve(...)
for the one in use now
And System(Nerve)
for the standard initializer
This works:
from topos.core.operators import to_scalar, from_scalar
A = System(("i:j", "j:k"), shape=3) # local algebra functor
K = System(("i:j", "j:k"), shape=1) # local scalar functor
J, S = from_scalar(A[0]), to_scalar(A[0])
u = A[0].ones()
s = K[0].field(S @ u.data)
v = A[0].field(J @ s.data)
Create linear operators with something like:
M = Matrix((tgt, src), mat)
That way it stays close to
M = sparse.matrix((n, m), indices, values)
It would be useful to have a scalar-valued field class with maps to/from the tensor valued fields, i.e.
Right now, one of the most costly operations upon system creation seems to be the following list comprehension: (core/operators.py)
Basically we create block diagonal matrices of 1s (sum then extend) when we could reduce this to a scalar valued field (useful for visualisation too). Later composing with an extension matrix would essentially yield the same blocks of 1s but
__matmul__
is probably more efficient than this nested list comprehension... :thinking:N.B:
local_masses = S* . S
if S denotes the sum fromR^E
toR
.Useful for operators as well: implement
K.zeta
,K.delta
, ... with scalar values then extend them (allows for concise +-1 representation).