Dear Sebastien
Thanks for M_.NNZDerivatives,
1) However, M_.NNZDerivatives(2) ans = 119 should result in a Hessian matrix of 3*119, total 357 elements, however, as can be seen below, it finishes sparse at element 138 instead 357-1=356.Alternatively, if 119 it a total number of elements (including indices) then it should be divisible by 3. Can you explain me where is this discrepancy occurring form?
2) Also, in a related issue, if you, or anyone else, has no objections Re my previous email, would it be then possible to change the behaviour of the preprocessor and have the indices and values of the sparse Hessian from the mex file returned grouped together either 3 by 3 as per my example below (which would then also constitute a 3 column matrix by number of non-zero elements rows as per your email) or, if it is supposed to be a "3 row" matrix, then apart by the total number of non-zero Hessian values, that is,. rather than being apart by no-of-vars/equations as it seems to be the case now?
Best regards George
----- Original Message ----- From: "G. Perendia" george@perendia.orangehome.co.uk To: "List for Dynare developers" dev@dynare.org Sent: Friday, June 26, 2009 3:26 PM Subject: Re: [DynareDev] 2nd and 3rd model derivatives + k-order
Dear Sebastien
Am I right to assume from the enclosed sample from the new <mod>_dynamic.c sparse hessian that row and column indices and values are 10 position
apart
with other values in between ( i.e. apart by Number of variables which happens to be 10 in this case). That seems to me a bit confusing and I am wandering what to do when the number of non-zero values is not a multiply
of
or no of vars - i.e we are going to have zero values to pad the matrices
(as
in the example below, positions 119 and 129 are not populated and in model with 20 or more vars there will be a lot of padding).
v2[0]=1; v2[10]=78;
v2[20]=(-(T21*T16*params[4]*T94));
v2[1]=1;
v2[11]=158;
v2[21]=v2[20];
v2[2]=1;
v2[12]=73;
v2[22]=(-(T21*T16*y[9]*params[4]*T172));
.....
v2[118]=10;
v2[128]=109;
v2[138]=(1+params[6])*(1+params[6]-1)*pow(y[6],1+params[6]-1-1)/(1+params[6]
);
}
What is the advantage in grouping by no-of vars?
What would be disadvantage if we had indices and values grouped together
in
3 by 3 values? e.g.
v2[0]=1; v2[1]=78;
v2[2]=(-(T21*T16*params[4]*T94));
...
Best regards
George
----- Original Message ----- From: "Sébastien Villemot" sebastien.villemot@ens.fr To: dev@dynare.org Cc: "Pablo Winant" pablo.winant@gmail.com Sent: Thursday, June 25, 2009 11:09 AM Subject: [DynareDev] 2nd and 3rd model derivatives + k-order
Hi everyone,
In the preprocessor, I have applied (in r2787) a change suggested by Pablo Winant: it consists in optimizing the way that the sparse matrices for 2nd and 3rd derivatives (g2 and g3) are constructed in dynamic (and sometimes static) model files. Thanks to Pablo for his very helpful patch.
First, note that this breaks the USE_DLL option at order 2. Since we are going to drop this option in the future, I'm not planning to fix this.
Second, a change needs to be made in the k-order library: the matrix for 2nd order derivatives of the dynamic model, as returned by the MEX file, has changed. It is now a 3 columns matrix, which contain only the non-null derivatives of the Hessian. Each line represents a non-zero element: column 1 is the row index of the non-zero element in the Hessian, column 2 is its column index, and column 3 is its value. Note that this is the format required by Matlab sparse() function.
Best,
-- Sébastien Villemot
Dev mailing list Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev