Skip to content

The scatter operation for AutoDiff seems to be incomplete: is it somewhere in subsasgn()? #21

Description

@uoa1184615

Here demonstrate the scatter error swaps and column swaps.
More generally need subsasgn(), if that is the function, to work
with permutations (including sub-sampled).

u=AutoDiff(reshape(1:3,3,[]))
f=u.^2
fv=getvalue(f), fD=full(getderivs(f))
% test rows swaps
swap=[1 3 2]
g=f(swap,:) % gather works for vals and derivs
gv=getvalue(g), gD=full(getderivs(g))
g(swap,:)=f % scatter  DNW  for derivs,  xxxxxxxxxxxxxx
gv=getvalue(g), gD=full(getderivs(g))

if size(u,2)>1 %optionally test column swaps
    swap=[2 1]
    g=f(:,swap) % gather works for vals and derivs
    gv=getvalue(g), gD=full(getderivs(g))
    g(:,swap)=f % scatter  DNW  for derivs,  xxxxxxxxxxxxx
    gv=getvalue(g), gD=full(getderivs(g))
end

Checking row case: just try simple swap of rows 2 and 3.
The first case where LHS = RHS-gather works fine with the
rows of the derivs swapping correctly. The 2nd case where
LHS-gather=RHS does not transform the derivs correctly.
Same for the column swap example.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions