Trace command
System dynamics program with additional features for economics
Brought to you by:
hpcoder,
profstevekeen
It would be good to be able to extract the Trace from a matrix. One case for it is the attached, where a correlation coefficient has been performed and only the country on country results are required. A Trace command could thus be wired up to the output of the correlation coefficient result and only the country on country results would be returned.
This does raise one issue: how to dimension the output. In this case it would be best to dimension by country, but there may be cases where just the trace is desired. In general I'd go with retaining the relevant dimension.
Well technically what you want is a diagonal operator - sort of like eye, but extracting the diagonal of the tensor. Trace is the sum of the diagonal.
It should be possible to construct this using existing features, but the x-vector makes is difficult. Attached is my solution to the problem.
Nevertheless, this is probably a useful feature to add, but it is too late in the day for this development cycle.
Screenshot of the diagonal extraction solution.