亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gnnlslib.c

?? support vector machine的一個matlab工具箱
?? C
字號:
/*-----------------------------------------------------------------------
gnnlslib.c: Library for solving Generalized Non-negative Least Squares problem.
 
 Generalized Non-negative Least Squares Problem to solve is
  
  min 0.5*x'*H*x + f'*x

  subject to  x(i) >= 0 for all i
  
 H [dim x dim] is symmetric positive semi-definite matrix.
 f [dim x 1] is an arbitrary vector.

 The precision of the found solution is given by
 the parameters tmax, tolabs, tolrel and tolKKT which
 define the stopping conditions:

    t >= tmax                   ->  exit_flag = 0  Number of iterations.
    UB-LB <= tolabs             ->  exit_flag = 1  Abs. tolerance.
    UB-LB <= UB*tolrel          ->  exit_flag = 2  Relative tolerance.
    Relaxed KKT cond. satisfied ->  exit_flag = 3  It means that
       mu(i) >= -tolKKT  for all i &&  
       mu(i) <= tolKKT   for i such that x(i) > 0
       where mu = H*x + f                        

 UB ... Upper bound on the optimal solution.
 LB ... Lower bound on the optimal solution.
 t  ... Number of iterations.
 History ... Value of LB and UB wrt. number of iterations.


 The following algorithms are implemented:
 ..............................................

 - Sequential Coordinate-wise Algorithm 
  (Franc, Hlavac: Sequential Coordinate-wise Algorithm
   for Non-negative Least Squares Problem. Research report. 
   CTU-CMP-2005-06. CTU FEL Prague. )
   exitflag = gnnls_sca( &get_col, diag_H, f, dim, tmax, 
               tolabs, tolrel, tolKKT, x, &t, &History, verb );

 - Sequential Coordinate-wise Algorithm with search for the 
   coordinate which gives the highest improvement.
   exitflag = gnnls_scas( &get_col, diag_H, f, dim, tmax, 
               tolabs, tolrel, tolKKT, x, &t, &History, verb );

 Modifications:
 09-seg-2005, VF
 28-aug-2005, VF
-------------------------------------------------------------------- */

#include "mex.h"
#include "matrix.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define HISTORY_BUF 1000000

#define MINUS_INF INT_MIN
#define PLUS_INF  INT_MAX

#define ABS(A) ((A >= 0) ? A : -(A))
#define MIN(A,B) ((A < B) ? (A) : (B))
#define MAX(A,B) ((A >= B) ? (A) : (B))
#define INDEX(ROW,COL,DIM) ((COL*DIM)+ROW)

/* --------------------------------------------------------------

Usage: exitflag = gnnls_sca( &get_col, diag_H, f, dim, tmax, 
               tolabs, tolrel, tolKKT, x, &t, &History, verb )
-------------------------------------------------------------- */
int gnnls_sca(const void* (*get_col)(long,long),
            double *diag_H,
            double *f,
            long dim, 
            long tmax,
            double tolabs,
            double tolrel,
            double tolKKT,
            double *x,
            long  *ptr_t,
            double **ptr_History,
            long verb)
{
  double *Nabla;
  double *History;
  double *col_H;
  double *tmp_ptr;
  double sumx;
  double x_old;
  double delta_x;
  double xHx;
  double UB;
  double LB;
  double xf;
  double min_Nabla;
  double max_Nabla;
  long History_size;
  long t;
  long i;
  long j;
  int exitflag;

  /* ------------------------------------------------------------ */
  /* Initialization                                               */
  /* ------------------------------------------------------------ */

  Nabla = mxCalloc(dim, sizeof(double));
  if( Nabla == NULL ) mexErrMsgTxt("Not enough memory.");

  History_size = (tmax < HISTORY_BUF ) ? tmax+1 : HISTORY_BUF;
  History = mxCalloc(History_size*2,sizeof(double));
  if( History == NULL ) mexErrMsgTxt("Not enough memory.");

  sumx = 0;
  for( i = 0; i < dim; i++ ) {
    if( diag_H[i] > 0 && f[i]*diag_H[i] < 0) {
      sumx += -f[i]/diag_H[i];
    }

    x[i] = 0;
    Nabla[i] = f[i];
  }

  t = 0;
  exitflag = -1;
  while( exitflag == -1 ) 
  {
    t++;     
 
    for(i = 0; i < dim; i++ ) {
      if( diag_H[i] > 0 ) {
        /* variable update */
        x_old = x[i];
        x[i] = MAX(0, x[i] - Nabla[i]/diag_H[i]);
        
        /* update Nabla */
        delta_x = x[i] - x_old;
        if( delta_x != 0 ) {
          col_H = (double*)get_col(i,-1);
          for(j = 0; j < dim; j++ ) {
            Nabla[j] += col_H[j]*delta_x;
          }
        }
      }
    }

    /* compute upper and lower bounds */
    xHx = 0;
    xf = 0;
    min_Nabla = PLUS_INF;
    max_Nabla = MINUS_INF;
    for(j = 0; j < dim; j++ ) {
      xHx += x[j]*(Nabla[j] - f[j]);
      xf += x[j]*f[j];
      if( min_Nabla > Nabla[j]) min_Nabla = Nabla[j];
      if( x[j] > 0 && max_Nabla < Nabla[j]) max_Nabla = Nabla[j];
    }

    UB = 0.5*xHx + xf;
    LB = -sumx*ABS(min_Nabla) - 0.5*xHx;

    /* stopping conditions */
    if(t >= tmax) exitflag = 0;
    else if(UB-LB <= tolabs) exitflag = 1;
    else if(UB-LB <= ABS(UB)*tolrel) exitflag = 2;
    else if(min_Nabla >= -tolKKT && max_Nabla <= tolKKT) exitflag = 3;

    if( verb > 0 && (t % verb == 0 || t==1)) {
      mexPrintf("%d: UB=%f, LB=%f, UB-LB=%f, (UB-LB)/|UB|=%f \n",
        t, UB, LB, UB-LB,(UB-LB)/ABS(UB));
    }

    /* Store selected values */
    if( t < History_size ) {
      History[INDEX(0,t,2)] = LB;
      History[INDEX(1,t,2)] = UB;
    }
    else {
      tmp_ptr = mxCalloc((History_size+HISTORY_BUF)*2,sizeof(double));
      if( tmp_ptr == NULL ) mexErrMsgTxt("Not enough memory.");
      for( i = 0; i < History_size; i++ ) {
        tmp_ptr[INDEX(0,i,2)] = History[INDEX(0,i,2)];
        tmp_ptr[INDEX(1,i,2)] = History[INDEX(1,i,2)];
      }
      tmp_ptr[INDEX(0,t,2)] = LB;
      tmp_ptr[INDEX(1,t,2)] = UB;
      
      History_size += HISTORY_BUF;
      mxFree( History );
      History = tmp_ptr;
    }

  }


  (*ptr_t) = t;
  (*ptr_History) = History;

  mxFree( Nabla );

  return( exitflag ); 
}

/* --------------------------------------------------------------

Usage: exitflag = gnnls_scas( &get_col, diag_H, f, dim, tmax, 
               tolabs, tolrel, tolKKT, x, &t, &History, verb )
-------------------------------------------------------------- */
int gnnls_scas(const void* (*get_col)(long,long),
            double *diag_H,
            double *f,
            long dim, 
            long tmax,
            double tolabs,
            double tolrel,
            double tolKKT,
            double *x,
            long  *ptr_t,
            double **ptr_History,
            long verb)
{
  double *Nabla;
  double *History;
  double *col_H;
  double *tmp_ptr;
  double sumx;
  double x_old;
  double x_new;
  double max_up;
  double max_x;
  double delta_x;
  double xHx;
  double UB;
  double LB;
  double up;
  double xf;
  double min_Nabla;
  double max_Nabla;
  long History_size;
  long t;
  long i;
  long j;
  long max_i;
  int exitflag;

  /* ------------------------------------------------------------ */
  /* Initialization                                               */
  /* ------------------------------------------------------------ */

  Nabla = mxCalloc(dim, sizeof(double));
  if( Nabla == NULL ) mexErrMsgTxt("Not enough memory.");

  History_size = (tmax < HISTORY_BUF ) ? tmax+1 : HISTORY_BUF;
  History = mxCalloc(History_size*2,sizeof(double));
  if( History == NULL ) mexErrMsgTxt("Not enough memory.");

  sumx = 0;
  for( i = 0; i < dim; i++ ) {
    if( diag_H[i] > 0 && f[i]*diag_H[i] < 0) {
      sumx += -f[i]/diag_H[i];
    }

    x[i] = 0;
    Nabla[i] = f[i];
  }

  t = 0;
  exitflag = -1;
  while( exitflag == -1 ) 
  {
    t++;     
 
    max_up = MINUS_INF;
    for(i = 0; i < dim; i++ ) {
      if( diag_H[i] > 0 ) {
        /* variable update */
        x_old = x[i];
        x_new = MAX(0, x[i] - Nabla[i]/diag_H[i]);
        
        up = -0.5*diag_H[i]*(x_new*x_new-x_old*x_old) -
          (Nabla[i] - diag_H[i]*x_old)*(x_new - x_old);

        if( up > max_up ) {
          max_i = i;
          max_up = up;
          max_x = x_new;
        }
      }
    }

    x_old = x[max_i];
    x[max_i] = max_x;

    /* update Nabla */
    delta_x = max_x - x_old;
    if( delta_x != 0 ) {
      col_H = (double*)get_col(max_i,-1);
      for(j = 0; j < dim; j++ ) {
        Nabla[j] += col_H[j]*delta_x;
      }
    }

    /* compute upper and lower bounds */
    xHx = 0;
    xf = 0;
    min_Nabla = PLUS_INF;
    max_Nabla = MINUS_INF;
    for(j = 0; j < dim; j++ ) {
      xHx += x[j]*(Nabla[j] - f[j]);
      xf += x[j]*f[j];
      if( min_Nabla > Nabla[j]) min_Nabla = Nabla[j];
      if( x[j] > 0 && max_Nabla < Nabla[j]) max_Nabla = Nabla[j];
    }

    UB = 0.5*xHx + xf;
    LB = -sumx*ABS(min_Nabla) - 0.5*xHx;

    /* stopping conditions */
    if(t >= tmax) exitflag = 0;
    else if(UB-LB <= tolabs) exitflag = 1;
    else if(UB-LB <= ABS(UB)*tolrel) exitflag = 2;
    else if(min_Nabla >= -tolKKT && max_Nabla <= tolKKT) exitflag = 3;

    if( verb > 0 && ((t % verb) == 0 || t==1)) {
      mexPrintf("%d: UB=%f, LB=%f, UB-LB=%f, (UB-LB)/|UB|=%f \n",
        t, UB, LB, UB-LB,(UB-LB)/ABS(UB));
    }

    /* Store selected values */
    if( t < History_size ) {
      History[INDEX(0,t,2)] = LB;
      History[INDEX(1,t,2)] = UB;
    }
    else {
      tmp_ptr = mxCalloc((History_size+HISTORY_BUF)*2,sizeof(double));
      if( tmp_ptr == NULL ) mexErrMsgTxt("Not enough memory.");
      for( i = 0; i < History_size; i++ ) {
        tmp_ptr[INDEX(0,i,2)] = History[INDEX(0,i,2)];
        tmp_ptr[INDEX(1,i,2)] = History[INDEX(1,i,2)];
      }
      tmp_ptr[INDEX(0,t,2)] = LB;
      tmp_ptr[INDEX(1,t,2)] = UB;
      
      History_size += HISTORY_BUF;
      mxFree( History );
      History = tmp_ptr;
    }

  }


  (*ptr_t) = t;
  (*ptr_History) = History;

  mxFree( Nabla );

  return( exitflag ); 
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久9999吃药| 久久69国产一区二区蜜臀| 婷婷综合五月天| 国产精品99精品久久免费| 精品视频免费看| 中文字幕一区二区三区精华液 | 精品一区二区三区的国产在线播放| 成人激情电影免费在线观看| 69久久99精品久久久久婷婷| 亚洲欧美日韩中文播放| 国产成人aaa| 欧美成人艳星乳罩| 日韩精品成人一区二区在线| 在线免费观看成人短视频| 日本一区二区动态图| 麻豆91精品91久久久的内涵| 欧美日韩在线播放三区四区| 亚洲人成7777| 91在线观看免费视频| 国产精品乱码一区二三区小蝌蚪| 激情六月婷婷久久| 欧美成人猛片aaaaaaa| 免费看欧美美女黄的网站| 欧美日韩不卡一区| 无码av免费一区二区三区试看| 欧美羞羞免费网站| 五月综合激情日本mⅴ| 欧美日韩一级片网站| 亚洲自拍偷拍麻豆| 欧美日韩精品一区视频| 亚洲电影视频在线| 69p69国产精品| 日韩高清在线电影| 欧美一区二区女人| 精品夜夜嗨av一区二区三区| 久久综合久久综合亚洲| 国产成人在线视频免费播放| 国产欧美一区二区精品性色超碰| 国产剧情一区二区| 国产精品久久久久久久久免费樱桃| 成人综合激情网| 亚洲天堂久久久久久久| 欧美伊人久久久久久久久影院| 午夜欧美视频在线观看| 9191国产精品| 久久福利资源站| 国产日韩亚洲欧美综合| 99精品视频在线免费观看| 亚洲一区二区黄色| 日韩欧美综合在线| 成人黄页毛片网站| 亚洲精品免费播放| 91精品国产综合久久国产大片| 国产一区中文字幕| **性色生活片久久毛片| 欧美日韩成人综合| 国产剧情一区在线| 亚洲综合色噜噜狠狠| 精品日韩一区二区三区| 高清国产一区二区| 午夜欧美一区二区三区在线播放| 欧美mv日韩mv| 91麻豆成人久久精品二区三区| 丝袜亚洲另类丝袜在线| 国产视频一区二区在线观看| 一本色道久久综合精品竹菊| 日韩av高清在线观看| 国产精品私房写真福利视频| 欧美日韩激情一区二区三区| 国产精品一区二区x88av| 亚洲美女屁股眼交3| www亚洲一区| 欧美日韩中文字幕精品| 成人午夜视频在线| 日本欧美加勒比视频| 国产精品嫩草影院av蜜臀| 欧美日韩国产乱码电影| 国产盗摄精品一区二区三区在线 | 秋霞av亚洲一区二区三| 亚洲国产成人午夜在线一区| 91精品国产美女浴室洗澡无遮挡| 国产成人三级在线观看| 强制捆绑调教一区二区| 一区二区三区在线免费| 国产欧美一区二区三区网站| 欧美一区二区三区小说| 色综合色综合色综合 | 日本成人在线不卡视频| 亚洲欧美另类小说| 国产欧美在线观看一区| 欧美mv日韩mv| 日韩一区二区电影| 91国偷自产一区二区开放时间| 国产精品一区二区三区99| 日本伊人色综合网| 亚洲国产精品精华液网站| 国产精品久久久一本精品| 欧美精品一区二区不卡| 欧美一区二区三区四区久久 | 成人精品视频一区| 麻豆成人av在线| 丝袜美腿亚洲一区| 亚洲午夜激情av| 一区二区三区不卡视频| 一区二区三区在线观看视频| 亚洲女与黑人做爰| 亚洲激情第一区| 亚洲激情图片qvod| 亚洲激情图片qvod| 一区二区三区不卡视频| 依依成人精品视频| 亚洲一区二区高清| 亚洲成人黄色影院| 日韩国产欧美在线观看| 天天亚洲美女在线视频| 日韩中文字幕区一区有砖一区| 首页国产欧美日韩丝袜| 男女视频一区二区| 美腿丝袜一区二区三区| 久草中文综合在线| 国产精品香蕉一区二区三区| 国产精品一区二区x88av| 粉嫩aⅴ一区二区三区四区| 9i在线看片成人免费| 色综合天天综合给合国产| 色视频一区二区| 欧美性感一区二区三区| 欧美一级片在线| 精品久久99ma| 国产精品欧美久久久久一区二区| 亚洲日本丝袜连裤袜办公室| 一卡二卡欧美日韩| 免费成人美女在线观看.| 精品亚洲国产成人av制服丝袜| 国产成都精品91一区二区三| 色综合久久综合网欧美综合网| 在线观看一区日韩| 欧美一区二区三区人| 日本一区二区三区在线观看| 亚洲人成网站在线| 毛片一区二区三区| 成人国产精品免费观看动漫| 欧美在线色视频| 精品国产青草久久久久福利| 国产精品国产自产拍在线| 一区二区三区在线视频观看| 免费观看成人鲁鲁鲁鲁鲁视频| 国产iv一区二区三区| 欧美三级中文字幕在线观看| 日韩三级视频中文字幕| 1024成人网| 男人的天堂久久精品| 91一区二区三区在线播放| 欧美电影在哪看比较好| 国产精品视频免费看| 三级一区在线视频先锋 | 国产成人精品免费视频网站| 欧美午夜寂寞影院| 久久综合久久综合久久| 亚洲综合另类小说| 福利电影一区二区| 欧美精品三级在线观看| 亚洲欧洲日产国产综合网| 日韩高清国产一区在线| 99re亚洲国产精品| 国产三级一区二区三区| 亚洲成av人片一区二区三区| gogo大胆日本视频一区| 精品国产一区二区三区不卡| 亚洲国产成人porn| 91免费视频大全| 久久久亚洲午夜电影| 美女精品自拍一二三四| 欧美视频一区二区在线观看| 亚洲欧美一区二区视频| 国产91丝袜在线18| 日韩欧美国产综合在线一区二区三区| 亚洲视频综合在线| 国产成人精品免费一区二区| 日韩欧美一二区| 日产国产欧美视频一区精品| 欧美三级蜜桃2在线观看| 1000精品久久久久久久久| 国产成人在线视频网址| 久久午夜羞羞影院免费观看| 免费高清视频精品| 在线播放国产精品二区一二区四区| 亚洲激情在线激情| 色综合天天综合| 亚洲视频1区2区| 色综合久久88色综合天天| 久久久美女艺术照精彩视频福利播放| 日韩av一级电影| 日韩女优电影在线观看| 免费成人av在线| 日韩久久免费av| 国产真实乱子伦精品视频| 精品国产成人系列| 国产激情精品久久久第一区二区| 久久午夜色播影院免费高清|