void Compare::execute() { if (data.type == 10) R(); else if (data.type == 73) A(); else if (data.type == 11) UR(); else if (data.type == 74) UA(); }
int QR(double* A , int n, double* Q1, double* Q2){ for (int k = 1; k < n; k++){ Xotr(A,n,k,Q1,Q2); UA(A,Q1,Q2,n,k); } for (int k = 1; k < n; k++){ if (AU(A,Q1,Q2,n,k)==-1){ return -1; } } return 1; }
void GrayScott::save_png() { // first send all data to proc 0 -> gather // if (world.rank == 0) { std::vector<double> uAll(N_*N_); // } MPI_Gather(&u_[Ny_loc], Nx_loc*Ny_loc, MPI_DOUBLE, &uAll[0], Nx_loc*Ny_loc, MPI_DOUBLE, 0, MPI_COMM_WORLD); if (world.rank == 0) { char parameters[50]; std::sprintf(parameters, "_k_%1.03f_F_%1.03f_step_%06d", k_, F_, currStep_); std::string fname = "images/" + pngName_ + parameters + ".png"; char filename[1024]; strncpy(filename, fname.c_str(), sizeof(filename)); filename[sizeof(filename) - 1] = 0; // 4 values per pixel: RGBA std::vector<unsigned char> data(4*N_*N_); int idx = 0; for (int i=0; i<N_; ++i) { for (int j=0; j<N_; ++j) { double color = UA(i,j); data[idx] = png::red(color); ++idx; data[idx] = png::green(color); ++idx; data[idx] = png::blue(color); ++idx; data[idx] = 0xFFu; ++idx; } } lodepng::encode(filename, data, N_, N_); } }
bool LatticeCoordinates ( const Matrix<F>& B, const Matrix<F>& y, Matrix<F>& x ) { DEBUG_CSE typedef Base<F> Real; const Int m = B.Height(); const Int n = B.Width(); if( y.Height() != m || y.Width() != 1 ) LogicError("y should have been an ",m," x 1 vector"); if( FrobeniusNorm(y) == Real(0) ) { Zeros( x, n, 1 ); return true; } Matrix<F> BRed( B ); Matrix<F> UB, RB; auto infoB = LLL( BRed, UB, RB ); auto MB = BRed( ALL, IR(0,infoB.rank) ); Matrix<F> A; Zeros( A, m, infoB.rank+1 ); { auto AL = A( ALL, IR(0,infoB.rank) ); auto aR = A( ALL, IR(infoB.rank) ); AL = MB; aR = y; } // Reduce A in-place Matrix<F> UA, RA; auto infoA = LLL( A, UA, RA ); if( infoA.nullity != 1 ) return false; // Solve for x_M such that M_B x_M = y // NOTE: The last column of U_A should hold the coordinates of the single // member of the null-space of (the original) A Matrix<F> xM; xM = UA( IR(0,infoA.rank), IR(infoB.rank) ); const F gamma = UA(infoA.rank,infoB.rank); if( Abs(gamma) != Real(1) ) LogicError("Invalid member of null space"); else xM *= -Conj(gamma); // Map xM back to the original coordinates using the portion of the // unimodular transformation of B (U_B) which produced the image of B auto UBM = UB( ALL, IR(0,infoB.rank) ); Zeros( x, n, 1 ); Gemv( NORMAL, F(1), UBM, xM, F(0), x ); /* if( infoB.nullity != 0 ) { Matrix<F> C; Zeros( C, m, infoB.nullity+1 ); auto cL = C( ALL, IR(infoB.rank-1) ); auto CR = C( ALL, IR(infoB.rank,END) ); // Reduce the kernel of B CR = UB( ALL, IR(infoB.rank,END) ); LLL( CR ); // Attempt to reduce the (reduced) kernel out of the coordinates // TODO: Which column to grab from the result?!? cL = x; LLL( C ); x = cL; } */ return true; }
bool cCardSeca::MatchEMM(const unsigned char *data) { return TID(data)==0x82 && !memcmp(UA(data),ua,sizeof(ua)); }