IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
penalty_matrix.m
Go to the documentation of this file.
1 %>@ingroup maths
2 %>@file
3 %>@brief Linear combination of differential operators.
4 %>
5 %> Returns a <code>[nf]x[nf]</code> symmetric matrix. It contains a weighted sum of different matrices <code>D_i'*D_i</code>. the coefficients of the sum are
6 %> given by @c dcoeff. @c D_0 is <code>eye(nf, nf)</code>. @c D_i is the i-th order differential operator such that <code>D_i*x = diff(x, i).</code>
7 %
8 %> @param nf Number of features
9 %> @param dcoeff Coefficient vector for 0th, 2nd, 3rd derivative and so on
10 %> @return See above.
11 function P = penalty_matrix(nf, dcoeff)
12 
13 P = zeros(nf, nf);
14 for i = 1:length(dcoeff)
15  D = diff_operator(nf, i-1);
16  P = P+dcoeff(i)*(D'*D);
17 end;