Esempio n. 1
0
/**********************************************************
* form upper triangular part of P
* single block 
**********************************************************/
void smat1(mwSize n, const double ir2, 
           double *A, mwIndex *irA, mwIndex *jcA, mwSize isspA, 
           mwSize mA, mwSize colidx, 
           double *B, mwIndex *irB, mwIndex *jcB, mwSize isspB)

{  mwSize idx, i, j, r, jn, k, kstart, kend, idxj, j2, count;
   double tmp;  
   double hf=0.5; 
   
   if (!isspA & !isspB) { 
      idx = colidx*mA; 
      for (j=0; j<n; j++) { 
          jn = j*n; 
          for (i=0; i<j; i++) { 
              B[i+jn] = ir2*A[idx]; 
              idx++; } 
          B[j+jn] = A[idx];
          idx++; 
      }
   } else if (isspA & !isspB) {      
      j2 = 0; idxj = 0; 
      kstart = jcA[colidx];  kend = jcA[colidx+1]; 
      for (k=kstart; k<kend; k++) { 
          r = irA[k];
          for (j=j2; j<n; j++) {i=r-idxj; if (i>j) {idxj+=j+1;} else {break;}} j2=j; 
          if (i < j) { B[i+j*n] = ir2*A[k]; }
          else       { B[i+j*n] = A[k]; }
      }
   } else if (!isspA & isspB) { 
      idx = colidx*mA; 
      count = 0; 
      for (j=0; j<n; j++) { 
          for (i=0; i<j; i++) {
   	      tmp = A[idx];
              if (tmp != 0) { irB[count] = i; B[count] = ir2*tmp; count++; }
              idx++; 
          }     
          tmp = A[idx];
          if (tmp != 0) { irB[count] = j; B[count] = hf*tmp; count++; }
          idx++; 
          jcB[j+1] = count; 
      }   
   } else if (isspA & isspB) { 
      count = 0; 
      j2 = 0; idxj = 0; 
      kstart = jcA[colidx];  kend = jcA[colidx+1]; 
      for (k=kstart; k<kend; k++) { 
          r = irA[k];
          for (j=j2; j<n; j++) {i=r-idxj; if (i>j) {idxj+=j+1;} else {break;}} j2=j; 
          irB[count] = i;
          if (i<j) {B[count] = ir2*A[k];}  else {B[count] = hf*A[k];}
          ++jcB[j+1]; 
          count++; 
      }   
      for (j=0; j<n; j++) { jcB[j+1] += jcB[j]; }
   }
   if (!isspB) { symmetrize(B,n); }
return; 
}
Esempio n. 2
0
int main()
{
  const int nreps = 100;
  const int n = 5000;
  double *x;
  
  x = gen_runif2(n*n);
  
  TIMER(symmetrize_naive(n, x), nreps);
  TIMER(symmetrize(n, x), nreps);
  
  return COOP_OK;
}
/**
 * \brief Start an exposure on the M26C camera
 *
 * \param exposure	exposure structure for the exposure to perform
 */
void	SxCcdM26C::startExposure0(const Exposure& exposure) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "exposure %s requested",
		exposure.toString().c_str());
	// remember the exposre, we need it for the second field for the
	// case where we do two fields one after the other
	this->exposure = symmetrize(exposure);
	m26c = m26cExposure();

	// compute a better request for the M26C camera
	exposeField(0);
	timer.start();

	// we are now in exposing state
	state = Exposure::exposing;
}
Esempio n. 4
0
void SymForceAligner::alignCorpus() {
    m_alignments.clear();
  
    m_srcTrgAligner.alignCorpus();
    m_trgSrcAligner.alignCorpus();
    
    Alignments::iterator it1 = m_srcTrgAligner.getAlignments().begin();
    Alignments::iterator it2 = m_trgSrcAligner.getAlignments().begin();
    
    while(it1 != m_srcTrgAligner.getAlignments().end() && it2 != m_trgSrcAligner.getAlignments().end()) {
        Alignment a1 = *it1;
        Alignment a2 = *it2;
        
        Alignment a = symmetrize(a1, a2);
        m_alignments.push_back(a);
        it1++; it2++;
    }    
}
Esempio n. 5
0
/** Eigenvalues.
  \param m Input matrix (unchanged on return).
  \return Vector of eigenvalues.
*/
dvector eigenvalues(const dmatrix& m)
{
  if (m.rowsize()!=m.colsize())
  {
    cerr << "error -- non square matrix passed to "
    "dvector eigen(const dmatrix& m)\n";
    ad_exit(1);
  }
  dmatrix m1=symmetrize(m);
  m1.colshift(1);     // set minimum column and row indices to 1
  m1.rowshift(1);
  int n=m1.rowsize();
  dvector diag(1,n);
  dvector off_diag(1,n);

  tri_dag(m1,diag,off_diag);

  get_eigen(diag,off_diag,m1); // eigenvalues are returned in diag
           // eigenvalues are returned in columns of z
  return diag;
}
/**
 * \brief Start an exposure on the M26C camera
 *
 * \param exposure	exposure structure for the exposure to perform
 */
void	SxCcdM26C::startExposure0(const Exposure& exposure) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "exposure %s requested",
		exposure.toString().c_str());
	// remember the exposure, we need it for the second field for the
	// case where we do two fields one after the other
	this->exposure = symmetrize(exposure);

	// compute a better request for the M26C camera
	m26c = m26cExposure();

	// start the exposure
	if (!camera.reserve("exposure M26C", 1000)) {
		std::string	msg("cannot reserve camera");
		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());
		throw std::runtime_error(msg);
	}
	exposeField(0);
	timer.start();

	// we are now in exposing state
	state(CcdState::exposing);
}
Esempio n. 7
0
int main()
{
  int ret;
  const int n = 10;
  double *x, *sym, *truth;
  
  printf("# Symmetrize: ");
  
  x = gen_boring2(n*n);
  
  truth = cpalloc2(n*n, x);
  symmetrize_naive(n, truth);
  
  sym = cpalloc2(n*n, x);
  symmetrize(n, sym);
  
  ret = all_equal(true, n, n, sym, truth);
  
  
  free(x);
  free(sym);
  free(truth);
  return ret;
}
Esempio n. 8
0
void MainWindow::createMenus()
{
   QAction* action;
   QString  name;
   QMenu*   menu;
   QMenu*   subMenu;

   // ----- File Menu -----
   menu = menuBar()->addMenu("File");

      name = "About";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showAbout()));

      name = "New Molecule";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(newMoleculeMenu()));
      action->setShortcut(QKeySequence::New);

      name = "New Viewer";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(newViewer()));

      name = "Open";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(openFile()));
      action->setShortcut(QKeySequence::Open);

      name = "Open Recent";
      m_recentFilesMenu = menu->addMenu(name);
      updateRecentFilesMenu();

      menu->addSeparator();

/*
      name = "Parse Test File";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(parseFile()));

      menu->addSeparator();
*/

      name = "Close Viewer";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(close()));
      action->setShortcut(QKeySequence::Close);

      name = "Save";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAll()));
      action->setShortcut(QKeySequence::Save);

      name = "Save As";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(saveAs()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_S);

      menu->addSeparator();

      name = "Save Picture";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewer, SLOT(saveSnapshot()));
      action->setShortcut(Qt::CTRL + Qt::Key_P);

      name = "Record Animation";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), this, SLOT(toggleRecordingActive()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_P);
      m_recordAnimationAction = action;

      name = "Show Message Log";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showLogMessages()));
      action->setShortcut(Qt::CTRL + Qt::Key_L);

      name = "Quit";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(quit()));
      action->setShortcut(Qt::CTRL + Qt::Key_Q);


   // ----- Edit Menu -----
   menu = menuBar()->addMenu("Edit");
  
      name = "Undo";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(undo()));
      action->setShortcut(QKeySequence::Undo);
      connect(&m_undoStack, SIGNAL(canUndoChanged(bool)), action, SLOT(setEnabled(bool)));

      name = "Redo";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_undoStack, SLOT(redo()));
      action->setShortcut(QKeySequence::Redo);
      connect(&m_undoStack, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool)));

      menu->addSeparator();

      name = "Cut";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(cutSelection()));
      action->setShortcut(Qt::CTRL + Qt::Key_X);

      name = "Copy";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(copySelectionToClipboard()));
      action->setShortcut(Qt::CTRL + Qt::Key_C);

      name = "Paste";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(pasteSelectionFromClipboard()));
      action->setShortcut(Qt::CTRL + Qt::Key_V);

      menu->addSeparator();

      name = "Select All";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(selectAll()));
      action->setShortcut(Qt::CTRL + Qt::Key_A);

      name = "Select None";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SIGNAL(clearSelection()));
      action->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_A);

      name = "Invert Selection";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(invertSelection()));
      action->setShortcut(Qt::CTRL + Qt::Key_I);

      menu->addSeparator();

      name = "Reindex Atoms";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(reindexAtoms()));


      menu->addSeparator();

      name = "Preferences";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showPreferences()));


   // ----- Display Menu -----
   menu = menuBar()->addMenu("Display");

      name = "Full Screen";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), this, SLOT(fullScreen()));
      action->setShortcut(Qt::CTRL + Qt::Key_0);
      m_fullScreenAction = action;

      name = "Reset View";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewer, SLOT(resetView()));
      action->setShortcut(Qt::CTRL + Qt::Key_R);

      name = "Show Axes";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAxes()));
      connect(&m_viewerModel, SIGNAL(axesOn(bool)), action, SLOT(setChecked(bool)));
      action->setShortcut(Qt::Key_A);


      menu->addSeparator();

      name = "Atom Labels";
      subMenu = menu->addMenu(name);

         name = "Element";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Element);
         action->setShortcut(Qt::Key_E);
         action->setCheckable(true);
         m_labelActions << action;

         name = "Index";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Index);
         action->setShortcut(Qt::Key_I);
         action->setCheckable(true);
         m_labelActions << action;
   
         name = "Mass";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Mass);
         action->setShortcut(Qt::Key_M);
         action->setCheckable(true);
         m_labelActions << action;

/*
         name = "NMR Shifts";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::NmrShifts);
         action->setShortcut(Qt::Key_N);
         action->setCheckable(true);
         m_labelActions << action;
*/

         name = "Partial Charge";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Charge);
         action->setShortcut(Qt::Key_Q);
         action->setCheckable(true);
         m_labelActions << action;

         name = "Spin Densities";
         action = subMenu->addAction(name);
         connect(action, SIGNAL(triggered()), this, SLOT(setLabel()));
         action->setData(Layer::Atom::Spin);
         action->setShortcut(Qt::Key_S);
         action->setCheckable(true);
         m_labelActions << action;

   menu->addSeparator();

   name = "Configure Appearance";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(configureAppearance()));


      // These are not working correctly at the moment.
/*
      name = "Partial Charge Type";
      QActionGroup* partialChargeGroup = new QActionGroup(this);
      subMenu = menu->addMenu(name);

         QString pc("Gasteiger");
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setChecked(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));

         pc = "Sanderson";
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));

         pc = "Mulliken";
         action = subMenu->addAction(pc);
         action->setCheckable(true);
         action->setData(pc);
         partialChargeGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setPartialChargeType()));
*/



   // ----- Build Menu -----
   menu = menuBar()->addMenu("Build");

      name = "Fill Valencies With Hydrogens";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(addHydrogens()));
      action->setShortcut(Qt::CTRL + Qt::Key_F);

      name = "Reperceive Bonds";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(reperceiveBonds()));

      menu->addSeparator();

      name = "Set Constraint";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(setConstraint()));
      action->setShortcut(Qt::CTRL + Qt::Key_K);

      name = "Minimize Structure";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(minimizeEnergy()));
      action->setShortcut(Qt::CTRL + Qt::Key_M);

      name = "Select Force Field";

      QActionGroup* forceFieldGroup = new QActionGroup(this);
      subMenu = menu->addMenu(name);

         QString ff("MMFF94");
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "MMFF94s";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "UFF";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "Ghemical";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

         ff = "Gaff";
         action = subMenu->addAction(ff);
         action->setCheckable(true);
         action->setData(ff);
         forceFieldGroup->addAction(action);
         connect(action, SIGNAL(triggered()), this, SLOT(setForceField()));
         if (Preferences::DefaultForceField() == ff) action->setChecked(true);

      menu->addSeparator();

      name = "Translate To Center";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(translateToCenter()));
      action->setShortcut(Qt::CTRL + Qt::Key_T );

      name = "Symmetrize Molecule";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(symmetrize()));
      action->setShortcut(Qt::CTRL + Qt::Key_Y );

      name = "Set Symmetry Tolerance";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(adjustSymmetryTolerance()));

      name = "Auto-detect Symmetry";
      action = menu->addAction(name);
      action->setCheckable(true);
      action->setChecked(false);
      connect(action, SIGNAL(triggered()), &m_viewerModel, SLOT(toggleAutoDetectSymmetry()));



   // ----- Calculation Menu -----
   menu = menuBar()->addMenu("Calculation");

      name = "Q-Chem Setup";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(openQChemUI()));
      action->setShortcut(Qt::CTRL + Qt::Key_U );
      m_qchemSetupAction = action;

      name = "Job Monitor";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showProcessMonitor()));
      action->setShortcut(Qt::CTRL + Qt::Key_J );

      menu->addSeparator();

      name = "Edit Servers";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(editServers()));

      name = "Remove All Processes";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), 
         &(ProcessMonitor::instance()), SLOT(clearProcessList()));

      name = "Reset Password Vault Key";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(setVaultPassword()));



   // ----- Help Menu -----
   menu = menuBar()->addMenu("Help");

      name = "Show Help";
      action = menu->addAction(name);
      connect(action, SIGNAL(triggered()), this, SLOT(showHelp()));
}
Esempio n. 9
0
int 
main(int argc, char *argv[])
{
  int prompt;
  complex **qin;
  Real *q;
  double starttime, endtime;
  
  int jflav, k;
  int key[4] = {1,1,1,1};  /* 4D Fourier transform */
  

  initialize_machine(&argc,&argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);

  g_sync();

  starttime=dclock();

  /* set up */
  prompt = setup();

  /* Set up for Fourier transform in all directions */
  if(prompt != 2)setup_restrict_fourier(key, NULL);

  /* loop over input sets */

  while( readin(prompt) == 0){
    
    if(prompt == 2)continue;   /* For testing */
  
    /* Create qin array */
    qin = (complex **)malloc(sizeof(complex *)*param.nrand);
    if(qin == NULL){
      node0_printf("main: No room for qin\n");
      terminate(1);
    }
    for(k = 0; k < param.nrand; k++){
      qin[k] = create_c_array_field(NMU);
      if(qin[k] == NULL){
	node0_printf("main: No room for qin[%d]\n",k);
	terminate(1);
      }
    }

    for(jflav = 0; jflav < param.nflav; jflav++){

      /* Allocate space and read all the data for flavor "jflav" */
      /* Accumulate the result in qin, weighted by the charge  */

      accumulate_current_density(param.fname[jflav], qin, param.charges[jflav], 
				 &param.mass[jflav], param.nrand);
    }
    
    /* Calculate the density-density correlator q */
    q = rcorr(qin, param.nrand);

    /* Destroy qin array */
    for(k = 0; k < param.nrand; k++)
      destroy_c_array_field(qin[k], NMU);
    free(qin);

    /* Symmetrize over hypercubic group transformations */
    symmetrize(q);

    /* Write the results to the specified file */
    print_result(q, param.nrand);

    destroy_r_field(q);
  
  } /* readin(prompt) */

  node0_printf("RUNNING COMPLETED\n");
  endtime=dclock();
    
  node0_printf("Time = %e seconds\n",(double)(endtime-starttime));

  normal_exit(0);
  return 0;
}
Esempio n. 10
0
double coordDescent(double *adSigmat, double *adUmat, double dRho,double dscalart, double dTol, int *adIndexList, int iIndexLength, int n, double *adXmat, double dOrigGap, int ibcdOuterIter)
{
	int i,j, k,row1, col1, row2, col2, iTemp, row, iCol, iVal, incx = 1, iCounter;
 	double one = 1, zero = 0, *buffmat, *adevec, *adhvec, sNegOne = -1, dTemp, dTemp2, *adbvec, dscalarc, *aduo, *adwo, *aduvec, *adw, *adVinmat, *buffveca, *adfvec, *buffvecb, *adTempVec,dCurrGap, dRelGap; 

	adTempVec = calloc(n, sizeof(double));
	adevec = calloc(n, sizeof(double));
	adhvec = calloc(n, sizeof(double));
	adfvec = calloc(n, sizeof(double));
	adVinmat = calloc( (n-1)*(n-1) , sizeof(double));
	aduo = calloc((n-1), sizeof(double));
	adwo = calloc(1, sizeof(double));
	aduvec = calloc((n-1), sizeof(double));
	adw = calloc(1, sizeof(double));
	adbvec = calloc((n-1), sizeof(double));
	buffveca = calloc(n, sizeof(double));
	buffvecb = calloc(n, sizeof(double));
	buffmat = calloc (n*n, sizeof(double));
	k =0;
	/* DualityGap =  -n + trace(Sigma*Xk) + rho*(sum(sum(abs(Xk))));*/
		
	dCurrGap = - n + cblasR_ddot((n*n), adSigmat,incx, adXmat, incx) + dRho*(cblasR_dasum((n*n), adXmat,incx));
	dRelGap = dCurrGap/dOrigGap;
	
	/* Main loop: Iterate until converge or till a maximum bcdOuterIter iterations */
	iCounter = 0; 
	while ( (dRelGap > dTol) && (iCounter < ibcdOuterIter )){
		iCounter++;
		/* 
		 Choose Important Columns to Update.
		 ind = indfind(Uk,Xk,Sigma, rhonew,colFraction );
		 */
		for (i=0;i<n;i++){	
			adTempVec[i]= (dRho + adSigmat[i + (n*i)] - adUmat[i + (n*i)])*adXmat[i+(n*i)]; 
			adIndexList[i]=i;
		}  
		modsort(adTempVec,adIndexList,n);
		/* Update choosen columns */  
		i = 0; 
		while  (i < iIndexLength){	
			iCol = adIndexList[i]; 
			/* 
			 1. Form Vin
			 First Rank 1 update ; 
			 e(i) = 1 ; e(j) = 0 (j != i) 
			 f = -U(:,i); f(i) = 1 - U(i,i)
			 Vin=Xk-((Xk*f*e'*Xk)/(1+e'*Xk*'f);
			 */
			adevec[iCol] = 1;
			cblasR_daxpy( n , sNegOne, (adUmat + (n*iCol)) ,incx,adfvec,incx);
			cblasR_daxpy( n , sNegOne, (adUmat + (n*iCol)) ,incx,adhvec,incx);
			adfvec[iCol] = 1 - adUmat[iCol + n*iCol];
			adhvec[iCol] = 0.0;
			for(iVal = 0 ; iVal < n; iVal++)
			{
				buffveca[iVal] = adXmat[iCol + n*iVal];
			}
			dTemp = 1 +  cblasR_ddot(n, adfvec,incx, buffveca, incx);
			cblasR_dscal(n,(1/dTemp),adfvec,incx);
			row1 = n; col1 = n; row2= n; col2=1;
			cblasR_dgemv( CblasColMajor,CblasNoTrans, n, n, one, adXmat, n, adfvec ,incx, zero, buffveca, incx); // buffveca contains Xk*f
			for(j = 0 ; j < n ; j++){
				if ( j != iCol){
					if ( j < iCol)
						k = j;
					else if ( j > iCol)
						k = j-1;
					cblasR_dcopy( iCol , (adXmat + (n*j)) ,incx,(adVinmat + ((n-1)*(k))),incx);
					cblasR_dcopy( n-iCol-1 , (adXmat + (n*j + iCol+1)) ,incx,(adVinmat + (n-1)*k + iCol),incx);
					dTemp = (adXmat[iCol + n*j]);
					cblasR_daxpy( iCol , -dTemp, buffveca   ,incx,(adVinmat + ((n-1)*(k))),incx);
					cblasR_daxpy( n-iCol-1 , -dTemp, (buffveca + (iCol+1)) ,incx,(adVinmat + (n-1)*k + iCol),incx);
				}
				buffvecb[j] = adXmat[iCol + n*j] *(1 - buffveca[iCol]);
			}
			/*
			 Second Rank1 update 
			 ;h = -U(:,i); h(i) = 0;
			 Vin=Vin-((Vin*e*h'*Vin)/(1+e'*Vin*'h));Vin(i,:)=[];Vin(:,i)=[];
			 */
			dTemp2 = 1 +  cblasR_ddot(n, adhvec,incx, buffvecb, incx);
			cblasR_dscal(n,(1/dTemp2),adhvec,incx);
			cblasR_dscal( n ,-adXmat[iCol + n*iCol] ,buffveca,incx);
			cblasR_daxpy( n , one, (adXmat + (n*iCol)) ,incx,buffveca,incx);
			for ( j = 0 ; j < n ; j++){
				if ( j != iCol){
					if ( j < iCol)
						k = j;
					else if ( j > iCol)
						k = j-1;
					dTemp = cblasR_ddot(iCol, adhvec,incx,(adVinmat + ((n-1)*(k))),incx);
					dTemp = dTemp + cblasR_ddot(n-iCol-1, (adhvec + iCol +1),incx,(adVinmat + (n-1)*k + iCol),incx);
					cblasR_daxpy( iCol , -dTemp, buffveca   ,incx,(adVinmat + ((n-1)*(k))),incx);
					cblasR_daxpy( n-iCol-1 , -dTemp, (buffveca + (iCol+1)) ,incx,(adVinmat + (n-1)*k + iCol),incx);
				}
			}
			/*
			 2. Form b, c, uo, wo - inputs to problem of updating choosen column, 
			 then call cdIndexUpdate
			 b = Sigma(:,i); c = b(i); b(i) = [];
			 uo = Uk(indi,i);wo = Uk(i,i);
			 [u,w] = indexCD_mex(Vin,b,c,t,rho,uo,wo,tolForInitGap);
			 FOR LATER IF SPEED IS AN ISSUE- Code heuristic to choose rows within the chosen col -. Also change 4 accordingly 
			 */
			//AA: can elimate dcopy calls by using pointer arthmetic 
			// KV - I definitely need copies. 
			cblasR_dcopy( iCol , (adUmat + (n*iCol))   ,incx, aduo,incx);
			cblasR_dcopy( n-iCol-1 , (adUmat + (n*iCol) + (iCol+1)) ,incx,(aduo + iCol),incx);
			cblasR_dcopy( iCol , (adSigmat + (n*iCol))   ,incx, adbvec,incx);
			cblasR_dcopy( n-iCol-1 , (adSigmat + (n*iCol) + (iCol+1)) ,incx,(adbvec + iCol),incx);
			dscalarc = *((adSigmat + (n*iCol) + iCol));
			*adwo =  *((adUmat + (n*iCol) + iCol));
			cdIndexUpdate(adVinmat, adbvec,dscalarc, dscalart, dRho, aduo, (*adwo), aduvec, adw,(n-1),dTol);
			/*
			 3. Update X = inv(U) by application of SMW - Doing it before update U 
			 First Rank one update 
			 indi = 1:n;indi(indi==i)=[];
			 f= zeros(n,1); h = zeros(n,1);f(indi)=u-U(indi,i);f(i)= (w - U(i,i); h(indi)=u-U(indi,i);h(i)= 0;	
			 Xk = Xk - ((Xk*f*e'*Xk)/(e'*X*f));
			 */
			for ( j = 0 ; j <iCol ; j++){
				adhvec[j] = aduvec[j] - adUmat[(n*iCol) + j];
				adfvec[j] = aduvec[j] - adUmat[(n*iCol) + j];
			}
			for(j = iCol+1 ; j < n ; j++){
				adhvec[j] = aduvec[(j-1)] -  adUmat[(n*iCol) + j];
				adfvec[j] = aduvec[(j-1)] -  adUmat[(n*iCol) + j];
			}
			adfvec[iCol]  = *adw - adUmat[(n*iCol) + iCol];
			adhvec[iCol] = 0.0;
			for(iVal = 0 ; iVal < n; iVal++){
				buffveca[iVal] = adXmat[iCol + n*iVal];
			}
			dTemp = 1 +  cblasR_ddot(n, adfvec,incx, buffveca, incx);
			cblasR_dscal(n,(1/dTemp),adfvec,incx);
			row1 = n; col1 = n; row2= n; col2=1;
			cblasR_dgemv( CblasColMajor,CblasNoTrans, n, n, one, adXmat, n, adfvec ,incx, zero, buffveca, incx); // buffveca contains Xk*f
			
			for(j = 0 ; j < n ; j++){
				dTemp = adXmat[iCol + n*j];
				cblasR_daxpy( n , -dTemp, buffveca   ,incx,(adXmat + n*j) ,incx);
			}
			
			/*
			 Second Rank 1 Update 
			 Xk=Xk-((Xk*e*h'*Xk)/(1+h'*Xk*e);
			 */
			cblasR_dcopy( n , (adXmat + (n*iCol)) ,incx,buffveca,incx);
			dTemp = 1 +  cblasR_ddot(n, adhvec,incx, buffveca, incx);
			cblasR_dscal(n,(1/dTemp),adhvec,incx);
			cblasR_dcopy( n , (adXmat + n*iCol),incx,buffveca,incx);
			for(j = 0 ; j <n ; j++){
				dTemp =  cblasR_ddot(n, adhvec,incx, (adXmat + (n*j)), incx);
				cblasR_daxpy( n , -dTemp, buffveca  ,incx,(adXmat + n*j) ,incx);
			}
			symmetrize(adXmat,buffmat, n);
			cblasR_dcopy( n*n , buffmat,incx,adXmat,incx);
			
			/*
			 3. Update U 
			 Uk(i,i) = w;Uk(indi,i) = u;Uk(i,indi) = u';
			 */
			iTemp = 0;
			for(row = 0;row < n;row++){ 
				if ( row != iCol )
				{
					adUmat[row + n*iCol ] = aduvec[iTemp];
					adUmat[iCol + n*row ] = aduvec[iTemp];
					iTemp++;
				}
				else 
					adUmat[row + n*iCol ] = *adw;
			}
			adevec[iCol] = 0;
			i++ ; 
		}
		
		/*
		 4. Recompute Gap
		 DualityGap =  -n + trace(Sigma*Xk) + rho*(sum(sum(abs(Xk))));
		 */
		dCurrGap = - n + cblasR_ddot((n*n), adSigmat,incx, adXmat, incx) + dRho*(cblasR_dasum((n*n), adXmat,incx));
		dRelGap = dCurrGap/dOrigGap;
		
	}
	free(adTempVec);
	free(adevec); 
	free(adhvec);
	free(adfvec);
	free(adVinmat);
	free(aduo); 
	free(adwo); 
	free(aduvec);
	free(adw); 
	free(adbvec);
	free(buffveca); 
	free(buffvecb);
	free(buffmat); 	
	
	return dRelGap;
}