// // The user has moved a scroll bar on the GUI. Process the update. // Typically, this means that the user has changed one of the following // values: % reads, % random, % of size, etc. // void CAccessDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar) { int position = ((CSliderCtrl *) pScrollBar)->GetPos(); // Modifying access specification based on slider controls. if (nSBCode == SB_THUMBTRACK || nSBCode == SB_ENDSCROLL) { if (pScrollBar == (CScrollBar *) & m_SAccess) { SetAccess(position); } else if (pScrollBar == (CScrollBar *) & m_SRead) { SetReads(position); } else if (pScrollBar == (CScrollBar *) & m_SRandom) { SetRandom(position); } } }
// // Calls each of the Set functions. // void CAccessDialog::SetAll(Access_Spec * spec) { SetSize(spec->size); SetAccess(spec->of_size); SetReads(spec->reads); SetRandom(spec->random); SetDelay(spec->delay); SetBurst(spec->burst); SetAlign(spec->align); EnableMKBControls(&align_controls, spec->align); if (!spec->align) { // Set the (disabled) alignment controls to 512 bytes (standard sector size). SetMKBSpinners(&align_controls, 512); } SetReply(spec->reply); EnableMKBControls(&reply_controls, spec->reply); if (!spec->reply) { // Set the (disabled) reply size controls to the current transfer size. SetMKBSpinners(&reply_controls, spec->size); } }
func Initialize() { Can = 0; SetRandom(); return(1); }
int main (int argc, char* argv[]) { char args[30]; long n, m; long i; long seed; long R; long np; long U, u; if (( argc < 2 ) || (argc > 4)) error (1); np = 0; strcpy ( args, argv[1] ); /* first parameter - number of nodes */ if (( n = atoi ( argv[1] ) ) < 3 ) error (2); /* optional parameters */ /* set default values */ seed = 214365; R = 0; for ( np = 2; np < argc; np++ ) { strcpy ( args, argv[np]); if ( args[0] != DASH ) error (1); switch ( args[1] ) { case 'r' : { R = (long) atof ( &args[2] ); break; } case 's' : { seed = (long) atof ( &args[2] ); break; } default: { error (2); break; } } } /* sanity check */ if ((R < 0) || ( R > n - 2)) error(3); SetRandom(seed); m = 2 * (n-1); u = 2; U = (n - 2) - R; printf ("c \"wheelgen\" min-cut problem\n"); printf ("p cut %8ld %8ld\n", n, m ); /* generate cycle arcs */ for ( i = 1; i < n; i++ ) { printf ("a %ld %ld %ld\n", i, ( i % (n-1)) + 1, U + Random ( 0, 2*R )); } /* generate spoke arcs */ for ( i = 1; i < n; i++ ) { printf ("a %ld %ld %ld\n", n, i, u ); } return(0); }
void Arnoldi<SCAL>::Calc (int numval, Array<Complex> & lam, int numev, Array<shared_ptr<BaseVector>> & hevecs, const BaseMatrix * pre) const { static Timer t("arnoldi"); static Timer t2("arnoldi - orthogonalize"); static Timer t3("arnoldi - compute large vectors"); RegionTimer reg(t); auto hv = a.CreateVector(); auto hv2 = a.CreateVector(); auto hva = a.CreateVector(); auto hvm = a.CreateVector(); int n = hv.FV<SCAL>().Size(); int m = min2 (numval, n); Matrix<SCAL> matH(m); Array<shared_ptr<BaseVector>> abv(m); for (int i = 0; i < m; i++) abv[i] = a.CreateVector(); auto mat_shift = a.CreateMatrix(); mat_shift->AsVector() = a.AsVector() - shift*b.AsVector(); shared_ptr<BaseMatrix> inv; if (!pre) inv = mat_shift->InverseMatrix (freedofs); else { auto itso = make_shared<GMRESSolver<double>> (*mat_shift, *pre); itso->SetPrintRates(1); itso->SetMaxSteps(2000); inv = itso; } hv.SetRandom(); hv.SetParallelStatus (CUMULATED); FlatVector<SCAL> fv = hv.FV<SCAL>(); if (freedofs) for (int i = 0; i < hv.Size(); i++) if (! (*freedofs)[i] ) fv(i) = 0; t2.Start(); // matV = SCAL(0.0); why ? matH = SCAL(0.0); *hv2 = *hv; SCAL len = sqrt (S_InnerProduct<SCAL> (*hv, *hv2)); // parallel *hv /= len; for (int i = 0; i < m; i++) { cout << IM(1) << "\ri = " << i << "/" << m << flush; /* for (int j = 0; j < n; j++) matV(i,j) = hv.FV<SCAL>()(j); */ *abv[i] = *hv; *hva = b * *hv; *hvm = *inv * *hva; for (int j = 0; j <= i; j++) { /* SCAL sum = 0.0; for (int k = 0; k < n; k++) sum += hvm.FV<SCAL>()(k) * matV(j,k); matH(j,i) = sum; for (int k = 0; k < n; k++) hvm.FV<SCAL>()(k) -= sum * matV(j,k); */ /* SCAL sum = 0.0; FlatVector<SCAL> abvj = abv[j] -> FV<SCAL>(); FlatVector<SCAL> fv_hvm = hvm.FV<SCAL>(); for (int k = 0; k < n; k++) sum += fv_hvm(k) * abvj(k); matH(j,i) = sum; for (int k = 0; k < n; k++) fv_hvm(k) -= sum * abvj(k); */ matH(j,i) = S_InnerProduct<SCAL> (*hvm, *abv[j]); *hvm -= matH(j,i) * *abv[j]; } *hv = *hvm; *hv2 = *hv; SCAL len = sqrt (S_InnerProduct<SCAL> (*hv, *hv2)); if (i<m-1) matH(i+1,i) = len; *hv /= len; } t2.Stop(); t2.AddFlops (double(n)*m*m); cout << "n = " << n << ", m = " << m << " n*m*m = " << n*m*m << endl; cout << IM(1) << "\ri = " << m << "/" << m << endl; Vector<Complex> lami(m); Matrix<Complex> evecs(m); Matrix<Complex> matHt(m); matHt = Trans (matH); evecs = Complex (0.0); lami = Complex (0.0); cout << "Solve Hessenberg evp with Lapack ... " << flush; LapackHessenbergEP (matH.Height(), &matHt(0,0), &lami(0), &evecs(0,0)); cout << "done" << endl; for (int i = 0; i < m; i++) lami(i) = 1.0 / lami(i) + shift; lam.SetSize (m); for (int i = 0; i < m; i++) lam[i] = lami(i); t3.Start(); if (numev>0) { int nout = min2 (numev, m); hevecs.SetSize(nout); for (int i = 0; i< nout; i++) { hevecs[i] = a.CreateVector(); *hevecs[i] = 0; for (int j = 0; j < m; j++) *hevecs[i] += evecs(i,j) * *abv[j]; // hevecs[i]->FVComplex() = Trans(matV)*evecs.Row(i); } } t3.Stop(); }
int main (int argc, char* argv[]) { char args[30]; long n, m; long i, j, k; long seed; long np; long l, u, L, U; if (( argc < 2 ) || (argc > 8)) error (1); np = 0; strcpy ( args, argv[1] ); /* first parameter - number of nodes */ if (( n = atoi ( argv[1] ) ) < 3 ) error (2); /* optional parameters */ /* set default values */ seed = 214365; m = n; U = 10000; L = 1; u = 10; l = 1; for ( np = 2; np < argc; np++ ) { strcpy ( args, argv[np]); if ( args[0] != DASH ) error (1); switch ( args[1] ) { case 'm' : { m = (long) atof ( &args[2] ); break; } case 's' : { seed = (long) atof ( &args[2] ); break; } case 'l' : { l = (long) atof ( &args[2] ); break; } case 'u' : { u = (long) atof ( &args[2] ); break; } case 'L' : { L = (long) atof ( &args[2] ); break; } case 'U' : { U = (long) atof ( &args[2] ); break; } default: { error (6); break; } } } /* sanity check */ if ( m < n ) error (3); if ( l > u ) error (4); if ( L > U ) error (4); if (( l < 0 ) || ( u < 0 ) || ( L < 0 ) || ( U < 0 )) error (5); SetRandom(seed); printf ("c \"cyclegen\" min-cut problem\n"); printf ("p cut %8ld %8ld\n", n, m ); /* generate cycle arcs */ for ( i = 1; i <= n; i++ ) { printf ("a %ld %ld %ld\n", i, ( i % n ) + 1, Random ( L, U )); } /* generate cross arcs */ for ( k = n+1; k <= m; k++ ) { do { i = Random ( 1, n ); j = Random ( 1, n ); } while ( i == j ); printf ("a %ld %ld %ld\n", i, j, Random ( l, u )); } return(0); }