Accord.Math.Optimization.BoundedBroydenFletcherGoldfarbShanno.matupd C# (CSharp) Method

matupd() static private method

static private matupd ( int n, int m, double ws, int _ws_offset, double wy, int _wy_offset, double sy, int _sy_offset, double ss, int _ss_offset, double d, int _d_offset, double r, int _r_offset, int &itail, int iupdat, int &col, int &head, double &theta, double rr, double dr, double stp, double dtd ) : void
n int
m int
ws double
_ws_offset int
wy double
_wy_offset int
sy double
_sy_offset int
ss double
_ss_offset int
d double
_d_offset int
r double
_r_offset int
itail int
iupdat int
col int
head int
theta double
rr double
dr double
stp double
dtd double
return void
        internal static void matupd(int n,
            int m, double[] ws, int _ws_offset, double[] wy, int _wy_offset,
            double[] sy, int _sy_offset, double[] ss, int _ss_offset, double[] d, int _d_offset,
            double[] r, int _r_offset, ref int itail, int iupdat, ref int col,
            ref int head, ref double theta, double rr, double dr, double stp, double dtd)
        {

            int j = 0;
            int pointr = 0;

            if ((iupdat <= m))
            {
                col = iupdat;
                itail = ((((head + iupdat) - 2)) % (m) + 1);
            }
            else
            {
                itail = ((itail) % (m) + 1);
                head = ((head) % (m) + 1);
            }

            // 
            // c     Update matrices WS and WY.
            // 
            dcopy(n, d, _d_offset, 1, ws, (1 - (1)) + (itail - (1)) * (n) + _ws_offset, 1);
            dcopy(n, r, _r_offset, 1, wy, (1 - (1)) + (itail - (1)) * (n) + _wy_offset, 1);

            // 
            // c     Set theta=yy/ys.
            // 
            theta = (rr / dr);
            // 
            // c     Form the middle matrix in B.
            // 
            // c        update the upper triangle of SS,
            // c                                         and the lower triangle of SY:

            if ((iupdat > m))
            {
                // c                              move old information
                {
                    for (j = 1; j <= (col - 1); j++)
                    {
                        dcopy(j, ss, (2 - (1)) + ((j + 1) - (1)) * (m)
                            + _ss_offset, 1, ss, (1 - (1)) + (j - (1)) * (m) + _ss_offset, 1);
                        dcopy((col - j), sy, ((j + 1) - (1)) + ((j + 1)
                            - (1)) * (m) + _sy_offset, 1, sy, (j - (1)) + (j - (1)) * (m) + _sy_offset, 1);
                    }
                }
            }
            // c        add new information: the last row of SY
            // c                                             and the last column of SS:
            pointr = head;
            {
                for (j = 1; j <= (col - 1); j++)
                {
                    sy[(col - (1)) + (j - (1)) * (m) + _sy_offset] =
                        ddot(n,
                          d, _d_offset, 1,
                        wy, (1 - (1)) + (pointr - (1)) * (n) + _wy_offset, 1);

                    ss[(j - (1)) + (col - (1)) * (m) + _ss_offset] =
                        ddot(n,
                          ws, (1 - (1)) + (pointr - (1)) * (n) + _ws_offset, 1,
                          d, _d_offset, 1);

                    pointr = ((pointr) % (m) + 1);
                }
            }
            if ((stp == 1.0))
            {
                ss[(col - (1)) + (col - (1)) * (m) + _ss_offset] = dtd;
            }
            else
            {
                ss[(col - (1)) + (col - (1)) * (m) + _ss_offset] = ((stp * stp) * dtd);
            }

            sy[(col - (1)) + (col - (1)) * (m) + _sy_offset] = dr;

            return;
        }