To Jeffrey Steward:
The documentation says that adiff has restrictions on transpose. (See page 4 where it says that your example _won't_ work). However, you can get a quadratic form to work if you bracket things just right. Writing
f = x'*(A*x)
does work.
Doesn't seem to be able to handle a really simple function like this:
x'*A*x
where A is a matrix. Try this
x = adiff([1,2]);
A = eye(2);
f = x'*A*x;
and there is an error in mtimes.m
Error using *
Inner matrix dimensions must agree.
To Edward: For simplicity, the package was coded to work solely on functions that take a column vector and return a scalar argument. I can't see reshape helping much because of that restriction. After you've got the derivative though, you can extract it from the adiff object as an ordinary matlab vector (using adiffget) and reshape that.
How hard would it be to have the function reshape supported? Currently it throws errors. I think because numel(a) = 1, where a is an adiff object.
I am just beginning to learn about auto differentiation and am pretty excited about something that seems to be a very powerful tool. Thanks for helping me get started.
@Geoffrey,
Not a good idea. Using EVAL has the same poofing hazards as ASSIGNIN, hazards which the tool expressly tries to avoid. Using a script also forces you to gamble that variables named 'assign_field', etc... don't already exist in your workspace.
Comment only