FLOTANTE * MetodoQR::getAutovalores(CONTADOR iteraciones, MatrizFullFull & matriz, FLOTANTE presicion) { convertirSimetrica(matriz); factorizarQR(matriz); FLOTANTE ultimo = -matriz.get(0,0); for(CONTADOR i = 0; i < iteraciones; i++) { MatrizFullFull & res = multiplicarTridiagonales(getR(),getQ()); factorizarQR(res); if(-(ultimo + res.get(0,0)) < presicion) { break; } else { ultimo = -res.get(0,0); } res.~MatrizFullFull(); } MatrizFullFull & res = multiplicar(getR(),getQ()); autovalores = new FLOTANTE[res.getFilas()]; for(CONTADOR i = 0; i < res.getFilas(); i++) { autovalores[i] = res.get(i,i); } _nAutovalores = res.getFilas(); _autovaloresCalculados = true; res.~MatrizFullFull(); return autovalores; }
void CSetDlgColors::ColorSetEdit(HWND hWnd2, WORD c) { _ASSERTE(hWnd2!=NULL); // Hook ctrl procedure if (!gColorBoxMap.Initialized()) gColorBoxMap.Init(128); HWND hBox = GetDlgItem(hWnd2, c); if (!gColorBoxMap.Get(hBox, NULL)) { WNDPROC pfnOld = (WNDPROC)SetWindowLongPtr(hBox, GWLP_WNDPROC, (LONG_PTR)ColorBoxProc); gColorBoxMap.Set(hBox, pfnOld); } // text box ID WORD tc = (tc0-c0) + c; // Well, 11 chars are enough for "255 255 255" // But sometimes it is interesting to copy/paste/cut when editing palettes, so x2 SendDlgItemMessage(hWnd2, tc, EM_SETLIMITTEXT, 23, 0); COLORREF cr = 0; GetColorById(c, &cr); wchar_t temp[16]; switch (gpSetCls->m_ColorFormat) { case CSettings::eRgbHex: _wsprintf(temp, SKIPLEN(countof(temp)) L"#%02x%02x%02x", getR(cr), getG(cr), getB(cr)); break; case CSettings::eBgrHex: _wsprintf(temp, SKIPLEN(countof(temp)) L"0x%02x%02x%02x", getB(cr), getG(cr), getR(cr)); break; default: _wsprintf(temp, SKIPLEN(countof(temp)) L"%i %i %i", getR(cr), getG(cr), getB(cr)); } SetDlgItemText(hWnd2, tc, temp); }
/* ************************************************************** * Prototype: ZOLTAN_EDGE_LIST_MULTI_FN * For every vertex in the ID list, return a list of all its * adjacent vertices, and the processes on which they reside. * Also include the edge weights if any. * For graph methods. ************************************************************** */ static void get_edge_list(void *data, int sizeGID, int sizeLID, int num_obj, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, int *num_edges, ZOLTAN_ID_PTR nborGID, int *nborProc, int wgt_dim, float *ewgts, int *ierr) { UZData *uz = (UZData *) data; int i, id, r, c, r2, c2, e; ZOLTAN_ID_PTR nextID; int *nextProc; if ( (sizeGID != 1) || (sizeLID != 1) || (wgt_dim != 0)){ /* we are not using edge weights */ *ierr = ZOLTAN_FATAL; return; } nextID = nborGID; nextProc = nborProc; /* printf("querying %d vertices\n", num_obj); */ for (i=0; i < num_obj ; ++i) { id = globalID[i]; r = getR(id); c = getC(id); /* printf(" %d (%d,%d) : ", id, r, c); */ for (e=0; e<uz->stencil; ++e) { r2 = r+neig[e].r; c2 = c+neig[e].c; if (r2>=0 && r2<uz->meshR && c2>=0 && c2<uz->meshC) { *nextID++ = gID(r2, c2); *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC)); /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */ } } if (uz->redgeto && (uz->redgeto[i]>=0)) { r2 = getR(uz->redgeto[i]); c2 = getC(uz->redgeto[i]); *nextID++ = gID(r2, c2); *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC)); /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */ } /* printf("\n"); */ *ierr = ZOLTAN_OK; } }
//Méthode toString QString Complexe::toString() const{ QString im = getI()->toString(); if(getI()>0){ if(im=="1") im=""; return getR()->toString() + " + " + im + "i"; } else{ im.remove('-'); if(im=="1") im=""; return getR()->toString() + " - " + im + "i"; } }
bool WindowBitmap::rgbEqual(int x1, int y1, int x2, int y2) { int r1 = getR(x1, y1); int g1 = getG(x1, y1); int b1 = getB(x1, y1); int r2 = getR(x2, y2); int g2 = getG(x2, y2); int b2 = getB(x2, y2); return (r1 == r2) && (g1 == g2) && (b1 == b2); }
int superPow(int a, vector<int>& b) { int k = a%m; int ret = 1; for(int i = b.size()-1; i>=0; i--) { ret *= getR(k, b[i]); ret %= m; // cout << "superPow:" << ret << endl; k = getR(k, 10); } return ret; }
int main() { double const e = 0.5; double xs[4] = { 1 - e, 0, 0, sqrt((1+e)/(1-e)) }; double r = getR(xs); double t = 0; int const N = 62834; for(int i = 0; i < N; ++i) { double E = (xs[2] * xs[2] + xs[3] * xs[3]) / 2.0 - 1.0 / getR(xs); printf("%e %e %e %e %e %e \n",t, xs[0], xs[1], xs[2], xs[3], E); update(xs); t += h; } }
static int filledges(int lid, int *adjID, int *adjProc, UZData *uz) { int *nextID = adjID, *ptr; int *nextProc = adjProc; int gid = gIDfLID(lid); int r = getR(gid), r2; int c = getC(gid), c2, e, j; /* printf(" %d (%d,%d) : ", id, r, c); */ for (e=0; e<uz->stencil; ++e) { r2 = r+neig[e].r; c2 = c+neig[e].c; if (r2>=0 && r2<uz->meshR && c2>=0 && c2<uz->meshC) { *nextID++ = gID(r2, c2); if (adjProc) *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC)); /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */ } } if (uz->redgeto && (uz->redgeto[lid]>=0)) { for (ptr=adjID; ptr<nextID && *ptr!=uz->redgeto[lid]; ++ptr); if (ptr>=nextID) { r2 = getR(uz->redgeto[lid]); c2 = getC(uz->redgeto[lid]); *nextID++ = uz->redgeto[lid]; if (adjProc) *nextProc++ = pID(r2/(uz->meshR/uz->procR), c2/(uz->meshC/uz->procC)); /* printf(" %d (%d, %d) [%d] ", *(nextID-1), r2, c2, *(nextProc-1)); */ } } if (xadj) { for (j=xadj[lid]; j<xadj[lid+1]; ++j) { for (ptr=adjID; ptr<nextID && *ptr!=uz->redgeto[lid]; ++ptr); if (ptr>=nextID) { *nextID++ = adj[j]; if (adjProc) *nextProc++ = pIDfGID(adj[j]); } } } /* printf("\n"); */ return nextID-adjID; }
//============================================================================== void BallJoint::integratePositions(double _dt) { Eigen::Matrix3d Rnext = getR().linear() * convertToRotation(getVelocitiesStatic() * _dt); setPositionsStatic(convertToPositions(Rnext)); }
JNIEXPORT void JNICALL Java_jp_dego_sample_ipcv_MainActivity_getGrayScale(JNIEnv *env, jobject obj, jintArray pix, jint w, jint h) { unsigned char r, g, b, gray; jint* pixels = (*env)->GetIntArrayElements(env, pix, 0); int i; for (i = 0; i < w * h; i++) { // rgb 抽出 // r = (pixels[i] & 0x00FF0000) >> 16; // g = (pixels[i] & 0x0000FF00) >> 8; // b = (pixels[i] & 0x000000FF); r = getR(pixels[i]); g = getG(pixels[i]); b = getB(pixels[i]); // グレイスケールの輝度値を計算 gray = (r + g + b) / 3; if (gray > 255) gray = 255; // 色データ組み換え pixels[i] = 0xFF000000 | (gray << 16) | (gray << 8) | gray; // pixels[i] = gray; } // 確保したメモリを開放 (*env)->ReleaseIntArrayElements(env, pix, pixels, 0); }
void TranslationRotation3D::createGLModelMatrix(float *M_out) const { double TGL[3], RGL[3]; getT(TGL); getR(RGL); TGL[2] = -TGL[2]; RGL[2] = -RGL[2]; TranslationRotation3D TR(TGL, RGL); double R_matGL[9]; TR.getR_mat(R_matGL); M_out[0] = R_matGL[0]; M_out[1] = R_matGL[1]; M_out[2] = R_matGL[2]; M_out[3] = 0.0; M_out[4] = R_matGL[3]; M_out[5] = R_matGL[4]; M_out[6] = R_matGL[5]; M_out[7] = 0.0; M_out[8] = R_matGL[6]; M_out[9] = R_matGL[7]; M_out[10] = R_matGL[8]; M_out[11] = 0.0; M_out[12] = TGL[0]; M_out[13] = TGL[1]; M_out[14] = TGL[2]; M_out[15] = 1.0; }
void Orbit::getPos(double theta, FGDoubleVector &outPos) { // get the R for that theta double r = getR(theta); // make the vector outPos.setRTheta(r, theta); }
bool WindowBitmap::rgbNear(int x1, int y1, BYTE r, BYTE g, BYTE b) { int r1 = getR(x1, y1); int g1 = getG(x1, y1); int b1 = getB(x1, y1); return (abs(r1-r)<=10) && (abs(g1-g)<=10) && (abs(b1-b)<=10); }
bool WindowBitmap::rgbEqual(int x1, int y1, BYTE r, BYTE g, BYTE b) { int r1 = getR(x1, y1); int g1 = getG(x1, y1); int b1 = getB(x1, y1); return (r1 == r) && (g1 == g) && (b1 == b); }
bool WindowBitmap::rgbLess(int x1, int y1, BYTE r, BYTE g, BYTE b) { int r1 = getR(x1, y1); int g1 = getG(x1, y1); int b1 = getB(x1, y1); return (r1 < r) && (g1 < g) && (b1 < b); }
bool WindowBitmap::rgbLarger(int x1, int y1, BYTE r, BYTE g, BYTE b) { int r1 = getR(x1, y1); int g1 = getG(x1, y1); int b1 = getB(x1, y1); return (r1 > r) && (g1 > g) && (b1 > b); }
Vertex getSpecularComp(Vertex _3DPoint, Vector V) { Vertex specularComp; Vector R = getR(_3DPoint); specularComp.x = pow(scalarProduct(V, R), n) * Ks * Il.R; specularComp.y = pow(scalarProduct(V, R), n) * Ks * Il.G; specularComp.z = pow(scalarProduct(V, R), n) * Ks * Il.B; return specularComp; }
double solve (double b, double h) { double sum, r, old_h; sum = 0.0; while ( (r=getR(b, h)) >= LIMIT) { sum += 2*PI*r; old_h = h; h -= 2*r; b = b*h/old_h; } return sum; }
void QxrdCenterFinder::normalizePowderRings() { QxrdPowderPointVector pts = get_MarkedPoints(); double maxR = 0; foreach(QxrdPowderPoint pt, pts) { double r = getR(pt.x(), pt.y()); if (r > maxR) { maxR = r; } }
void Texture::lock(std::string filename, std::string maskFile, long maskColor, bool mipmap, DEXGL_TEXGEN funcTexGen) { if (filename != "") { int width, height; long *data = FileBmp::loadBmp(filename, width, height); for (int i = 1; i < width; i *= 2); for (int j = 1; j < height; j *= 2); int newWidth = i; int newHeight = j; long *newData = FileBmp::resizeBmp( data, width, height, newWidth, newHeight ); if (newData) delete []data; else newData = data; if (maskFile == "") for (long k = 0; k < (long) newWidth * newHeight; k++) newData[k] = newData[k] | 0xFF000000; else { long *mask = FileBmp::loadBmp(maskFile, width, height); long *newMask = FileBmp::resizeBmp( mask, width, height, newWidth, newHeight ); if (newMask) delete []mask; else newMask = mask; float r = (float) 1 / (255 * 3); for (long k = 0; k < (long) newWidth * newHeight; k++) if (maskColor == -1) { float alpha = (float) ( getR(newData[k]) + getG(newData[k]) + getB(newData[k]) ) * r; newData[k] = newData[k] | (((long) (alpha * 255)) << 24); } else newData[k] = (newMask[k] == maskColor) ? (newData[k] | 0xFF000000) : newData[k]; delete []newMask; } mNumID = funcTexGen(newData, newWidth, newHeight, mipmap); delete []newData; mGlow = (maskColor < 0); } }
ReturnMatrix KinematicsSolver::getTMatrix(ColumnVector &p) { Matrix result(4, 4); result = 0.0; result.submatrix(1, 3, 1, 3) = getR(p(4), p(5), p(6)); result(1, 4)= p(1); result(2, 4)= p(2); result(3, 4)= p(3); result(4, 4)= 1.0; result.Release(); return result; }
//---------------------------------------------------------------------------------- void FunctionsSingleton::coutAll() const { std::cout << getD() << std::endl; std::cout << getF() << std::endl; std::cout << getG() << std::endl; std::cout << getM() << std::endl; std::cout << getN() << std::endl; std::cout << getP() << std::endl; std::cout << getQ() << std::endl; std::cout << getR() << std::endl; std::cout << getW() << std::endl; std::cout << "Alpha: " << mAlpha << std::endl; std::cout << "Beta: " << mBeta << std::endl; std::cout << "Gamma: " << mGamma << std::endl; }
void Texture::setHgtMap(IMesh *mesh, std::string filename, float height) { int mapWidth, mapHeight; long *data = FileBmp::loadBmp(filename, mapWidth, mapHeight); float r = (float) 1 / 255; Vector *v = mesh->getVertices(); for (int i = 0; i < mesh->mVertCnt; i++) { int x = map_linear(v[i].x, mesh->mMin.x, mesh->mMax.x, mapWidth - 1, 0); int y = map_linear(v[i].z, mesh->mMin.z, mesh->mMax.z, 0, mapHeight - 1); long c = data[y * mapWidth + x]; v[i].y = getR(c) * r * height; mesh->setVertex(i, v[i].x, v[i].y, v[i].z); } delete []data; }
//-------------------------------------------------------- void Pixelgroup::paint(PixelWriterInterface& writer) { // safeties if (!isDirty() && !m_isFlickering) return; if (getPixels() == 0 || getSize() == 0) return; bool strobeState = !Strobe::isStrobing() || Strobe::getStrobeState(); bool flickeringDone = false; // mark as clean setDirty(false); for (uint8_t i=0; i<getSize(); i++) { uint8_t pixelIndex = getPixels()[i]; if (m_isFlickering > 0 && !flickeringDone) { #ifdef ESP8266 if ((rand() % 100) > 80) { #else if ((random() % 100) > 80) { #endif strobeState &= 0; flickeringDone = true; m_isFlickering--; // mark as dirty to redraw on next cycle setDirty(true); } } // set pixel color (or black) // sets color in pixelWriter // sets pixelwriter to dirty if (!strobeState || flickeringDone) { writer.setPixelColor(pixelIndex, 0, 0, 0); } else { writer.setPixelColor((uint8_t)pixelIndex, getR(), getG(), getB()); } } }
void Double() { memset(c, 0, sizeof(int) * (n + 1)); int i; for (i = 1; i <= n; i++) c[getR(i + L)]++; a[0] = 1; for (i = 1; i <= n; i++) a[i] = a[i - 1] + c[i - 1]; for (i = 1; i <= n; i++) _SA[a[getR(i + L)]++] = i; memset(c, 0, sizeof(int) * (n + 1)); for (i = 1; i <= n; i++) c[getR(i)]++; a[0] = 1; for (i = 1; i <= n; i++) a[i] = a[i - 1] + c[i - 1]; for (i = 1; i <= n; i++) SA[a[getR(_SA[i])]++] = _SA[i]; _rnk[SA[1]] = 1; for (i = 2; i <= n; i++) if (getR(SA[i]) == getR(SA[i - 1]) && getR(SA[i] + L) == getR(SA[i - 1] + L)) _rnk[SA[i]] = _rnk[SA[i - 1]]; else _rnk[SA[i]] = _rnk[SA[i - 1]] + 1; memcpy(rnk, _rnk, sizeof(int) * (n + 1)); L <<= 1; }
bool KinematicsSolver::solve(ColumnVector targetPose, ColumnVector currentQ) { this->currentQ4 = currentQ(4); selector = new SolutionSelector(currentQ); solutions.clear(); //TODO: combine following next 3 lines into a single function //getTMatrix(ColumnVector jointAngles); targetPose(3) = targetPose(3) - DH_d1; R = getR(targetPose(4), targetPose(5), targetPose(6)); target = getTargetT(targetPose(1), targetPose(2), targetPose(3), R); pos = getP_wr(targetPose(1), targetPose(2), targetPose(3), R); solveThetas(); return solutions.size() > 0; }
/* ************************************************************** * Prototype: ZOLTAN_NUM_EDGES_MULTI_FN * Return the number of edges for each vertex in the ID lists. * For graph methods. ************************************************************** */ static void get_num_edges_list(void *data, int sizeGID, int sizeLID, int num_obj, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, int *numEdges, int *ierr) { UZData *uz = (UZData *) data; int i, id, r, c, r2, c2, edgecnt, e; if ( (sizeGID != 1) || (sizeLID != 1)){ *ierr = ZOLTAN_FATAL; return; } for (i=0; i < num_obj ; ++i){ id = globalID[i]; r = getR(id); c = getC(id); if (r==0 || c==0 || r==(uz->meshR-1) || c==(uz->meshC-1)) { /* we can probably do much smarter thing bu since we're not going to time graph generation time, simply run through over edges and see how many edges it will have. */ edgecnt = 0; for (e=0; e<uz->stencil; ++e) { r2 = r+neig[e].r; c2 = c+neig[e].c; if (r2>=0 && r2<uz->meshR && c2>=0 && c2<uz->meshC) ++edgecnt; } numEdges[i] = edgecnt; } else /* internal vertices always have all the edges */ numEdges[i] = uz->stencil; if (uz->redgeto && (uz->redgeto[i]>=0)) ++numEdges[i]; } *ierr = ZOLTAN_OK; }
Complexe* Complexe::conjugue(){ StrategieMultiplication m; Numerique* i= getI(); Entier* neg= new Entier(-1); Numerique* pr= dynamic_cast<Numerique*>(getR()->clone()); if (isEntier(i)){ Entier* e= dynamic_cast<Entier*>(i); return new Complexe(pr,m.Calcul(neg,e)); } else if (isReel(i)){ Reel* r= dynamic_cast<Reel*>(i); return new Complexe(pr,m.Calcul(neg,r)); } else{ Rationnel* ra= dynamic_cast<Rationnel*>(i); return new Complexe(pr,m.Calcul(neg,ra)); } }
void glButton::draw() { if (!m_bShow) return; if (m_state != BTN_NORMAL) { crrtFrame++; if (crrtFrame >= animateFrames) { m_state = BTN_NORMAL; m_x += m_dx; m_y += m_dy; } if (m_state == BTN_MOVEING) { float t = (float)crrtFrame / animateFrames - 1.0; m_rate = 1.0 - t*t*t*t; } } glBindTexture(GL_TEXTURE_2D, m_tex); drawSquare(getX(), getY(), getR()); }
JNIEXPORT void JNICALL Java_jp_dego_sample_ipcv_MainActivity_toGrayScale(JNIEnv *env, jobject obj, jobject bmp) { AndroidBitmapInfo info; void* pixels; int ret, i, j; // Bitmapの情報を取得 if ((ret = AndroidBitmap_getInfo(env, bmp, &info)) < 0) { return; } // Bitmapのフォーマットをチェック if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) { return; } // Bitmapをロック if ((ret = AndroidBitmap_lockPixels(env, bmp, &pixels)) < 0) { } unsigned int *p = pixels; int h = info.height; int w = info.width; unsigned int r, g, b; unsigned char gray; for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { // r = (p[j*w + i] & 0x000000FF); // g = (p[j*w + i] & 0x0000FF00) >> 8; // b = (p[j*w + i] & 0x00FF0000) >> 16; r = getR(p[j * w + i]); g = getG(p[j * w + i]); b = getB(p[j * w + i]); gray = (unsigned char)((float)r * 0.287f + (float)g * 0.599f + (float)b * 0.114); *(p + j * w + i) = 0xFF000000 | (gray << 16) | (gray << 8) | gray; } } // Bitmapのロックを解除 AndroidBitmap_unlockPixels(env, bmp); }