//xx, preDerivative, derivative, niter void doIter(double *HH, double *hh, int n, int k, double tolorance, int maxIter, int verbose, double *xx, double *iter, int max_threads) { double **H = convert(HH, k, k); double **h = convert(hh, n, k); double **x = convert(xx, n, k); double *sqrtH = createV(k); double *iSqrtH = createV(k); double e=0, pre=0, der=0; *iter = 0; For(i, k) { sqrtH[i] = (H[i][i] > 0 ? sqrt(H[i][i]) : 1.0); iSqrtH[i] = 1.0/sqrtH[i]; }
void Scrollbar::setLength(float length) { GfxMan.lockFrame(); // Need at least the space for the 2 caps _length = MAX(length, 4.0f); if (_type == kTypeVertical) createV(); else if (_type == kTypeHorizontal) createH(); GfxMan.unlockFrame(); }
void doSNQPIter(double *HH, double *hh, int n, int k, double tolorance, int maxIter, int verbose, double *xx, double *iter, int max_threads) { double **H = convert(HH, k, k); double **h = convert(hh, n, k); double **x = convert(xx, n, k); double *sqrtH = createV(k); double *iSqrtH = createV(k); double e=0, pre=0, der=0; *iter = 0; double *its = createV(max_threads); int start = 0, end; pthread_t threads[MAX_SUPPORTED_THREADS]; thread_data* args[MAX_SUPPORTED_THREADS]; For(t, max_threads){ end = start + (n - start) / (max_threads - t); args[t] = new thread_data(H, h, k, tolorance, maxIter, verbose, x, &its[t], start, end, sqrtH, iSqrtH); if (pthread_create(&threads[t], NULL, thread_iter_SNQP, (void*)args[t])) mexErrMsgTxt("problem with return code from pthread_create()"); start = end; }
void nasolver<nr_type_t>::saveResults (const std::string &volts, const std::string &s, int saveOPs, qucs::vector * f) { int N = countNodes (); int M = countVoltageSources (); // add node voltage variables if (!volts.empty()) { for (int r = 0; r < N; r++) { std::string n = createV (r, volts, saveOPs); if(!n.empty()) { saveVariable (n, x->get (r), f); } } } // add branch current variables if (!amps.empty()) { for (int r = 0; r < M; r++) { std::string n = createI (r, amps, saveOPs); if (!n.empty()) { saveVariable (n, x->get (r + N), f); } } } // add voltage probe data if (!volts.empty()) { circuit * root = subnet->getRoot (); for (circuit * c = root; c != NULL; c = (circuit *) c->getNext ()) { if (!c->isProbe ()) continue; if (!c->getSubcircuit().empty() && !(saveOPs & SAVE_ALL)) continue; if (volts != "vn") c->saveOperatingPoints (); std::string n = createOP (c->getName (), volts); saveVariable (n, nr_complex_t (c->getOperatingPoint ("Vr"), c->getOperatingPoint ("Vi")), f); } } // save operating points of non-linear circuits if requested if (saveOPs & SAVE_OPS) { circuit * root = subnet->getRoot (); for (circuit * c = root; c != NULL; c = (circuit *) c->getNext ()) { if (!c->isNonLinear ()) continue; if (!c->getSubcircuit ().empty() && !(saveOPs & SAVE_ALL)) continue; c->calcOperatingPoints (); for (auto ops: c->getOperatingPoints ()) { operatingpoint &p = ops.second; std::string n = createOP (c->getName (), p.getName ()); saveVariable (n, p.getValue (), f); } } } }
double **H = convert(HH, k, k); double **h = convert(hh, n, k); double **x = convert(xx, n, k); double *sqrtH = createV(k); double *iSqrtH = createV(k); double e=0, pre=0, der=0; *iter = 0; For(i, k) { sqrtH[i] = (H[i][i] > 0 ? sqrt(H[i][i]) : 1.0); iSqrtH[i] = 1.0/sqrtH[i]; } For(i, k) For(j, k) H[i][j] *= iSqrtH[i]*iSqrtH[j]; double *its = createV(max_threads); int start = 0, end; pthread_t threads[MAX_SUPPORTED_THREADS]; thread_data* args[MAX_SUPPORTED_THREADS]; For(t, max_threads){ end = start + (n - start) / (max_threads - t); args[t] = new thread_data(H, h, k, tolorance, maxIter, verbose, x, &its[t], start, end, sqrtH, iSqrtH); if (pthread_create(&threads[t], NULL, thread_iter, (void*)args[t])) mexErrMsgTxt("problem with return code from pthread_create()"); start = end; } For(t, max_threads){ pthread_join(threads[t], NULL); *iter += its[t];