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,
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,