-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I'm currently having a hard time understanding the adjoint of the cumsum operator and while trying to understand it, I've encountered something. In line 281 - 283 in tvregdiff.py, the adjoint of the cumsum operator is defined as
def AT(w): return (sum(w) * np.ones(len(w)) -
np.transpose(np.concatenate(([0.0], np.cumsum(w[:-1])))))I'm wondering if the effect of
np.transpose(...)is intended in this context? Since
np.concatenate(([0.0], np.cumsum(w[:-1])))returns a 1D-vector and NumPy's transpose(...) has no effect on 1D-vectors, nothing will happen here (see also the docs). As example one can call
a = np.arange(0, 10)
np.allclose(a, np.transpose(a)) # evaluates to True because a is 1D
a = a.reshape((-1, 1))
np.allclose(a, np.transpose(a)) # evaluates to False because a is a 2D-column-vector, same applies to row vectorsAs I said, I don't quite understand the adjoint of the cumsum, so I would like to ask if this behaviour (nothing happening) is intended or not?
Btw, instead of
sum(w) * np.ones(len(w))one can use
np.full((len(w), ), fill_value = np.sum(w))but this is just a very small detail.
Thanks and best regards!
Metadata
Metadata
Assignees
Labels
No labels