Mm ex() { begin_scope #line 1 "d:/matcom45/ex.m" call_stack_begin; #line 1 "d:/matcom45/ex.m" // nargin, nargout entry code double old_nargin=nargin_val; if (!nargin_set) nargin_val=0.0; nargin_set=0; double old_nargout=nargout_val; if (!nargout_set) nargout_val=0.0; nargout_set=0; // translated code #line 2 "d:/matcom45/ex.m" _ subplot(121.0); #line 3 "d:/matcom45/ex.m" _ surf((CL(peaks(25.0)))); #line 4 "d:/matcom45/ex.m" _ subplot(122.0); #line 5 "d:/matcom45/ex.m" _ pcolor((CL(peaks(25.0)))); call_stack_end; // nargin, nargout exit code nargin_val=old_nargin; nargout_val=old_nargout; // function exit code return x_M; end_scope }
void DisplayProblem1D::DISPLAY() { if (status != NOT_READY) { size_t nruns = bopt_model->getParameters()->n_iterations; if ((status != STOP) && (state_ii < nruns)) { // We are moving. Next iteration ++state_ii; bopt_model->stepOptimization(); const double res = bopt_model->getData()->getLastSampleY(); const vectord last = bopt_model->getData()->getLastSampleX(); ly.push_back(res); lx.push_back(last(0)); if (status == STEP) { status = STOP; } } // We compute the prediction, true value and criteria at 1000 points int n=1000; std::vector<double> x,y,z,su,sl,c; x = linspace(0,1,n); y = x; z = x; su = x; sl = x; c = x; // Query functions at the 1000 points vectord q(1); for(size_t i=0; i<n; ++i) { q(0) = x[i]; // Query ProbabilityDistribution* pd = bopt_model->getPrediction(q); y[i] = pd->getMean(); //Expected value su[i] = y[i] + 2*pd->getStd(); //Upper bound (95 %) sl[i] = y[i] - 2*pd->getStd(); //Lower bound (95 %) c[i] = -bopt_model->evaluateCriteria(q); //Criteria value z[i] = bopt_model->evaluateSample(q); //Target function true value } //GP subplot subplot(2,1,1); title("Press r to run and stop, s to run a step and q to quit."); plot(x,y); set(3); // Expected value in default color (blue) plot(lx,ly);set("k");set("o");set(4); // Data points as black star plot(x,su);set("g"); set(2); // Uncertainty as green lines plot(x,sl);set("g"); set(2); plot(x,z);set("r"); set(3); // True function as red line //Criterion subplot subplot(2,1,2); plot(x,c); set(3); } };
std::string MatlabPlotter::buildComplexCommand(std::string title, int id) { std::stringstream ss; if(id==0) ss << "figure;"; else ss << "figure(" << id << ");"; ss << "subplot(4,1,1);plot(real(data));title('" << title << " - Real'); \ subplot(4,1,2);plot(imag(data));title('" << title << " - Imag'); \ subplot(4,1,3);plot(abs(data));title('" << title << " - Magnitude'); \ subplot(4,1,4);plot(angle(data));title('" << title << " - Phase');"; return ss.str(); }
void PowerPlotter::DISPLAY(void) { for (uint32_t i = 0; i < mDevices.size(); ++i) { subplot(mDevices.size(), 1, i + 1); this->ylabel(mDevices[i]->mName); plotDevice(mDevices[i], i); if (i == 0) ticklabel(1); else ticklabel(0); } }
//--------------------------------------------------------- void TestPoissonIPDG3D::Run() //--------------------------------------------------------- { umLOG(1, "TestPoissonIPDG3D::Run()\n"); double wt1=timer.read(); // Initialize solver and construct grid and metric StartUp3D(); #if (0) //------------------------------------- // check the mesh //------------------------------------- Output_Mesh(); umLOG(1, "\n*** Exiting after writing mesh\n\n"); return; #endif // sparse operators CSd A("OP"), M("MM"); // build 3D IPDG Poisson matrix (assuming all Dirichlet) PoissonIPDG3D(A, M); if (0) { // NBN: experiment with diagonal strength int Nz=0; for (int j=0; j<A.n; ++j) { for (int p = A.P[j]; p<A.P[j+1]; ++p) { if (A.I[p] == j) { A.X[p] += A.X[p]; // augment A(i,j) } } } } if (0) { umLOG(1, "Dumping file Afull.dat for Matlab\n"); umLOG(1, "A(%d,%d), nnz = %d\n", A.m,A.n, A.P[A.n]); FILE* fp=fopen("Afull.dat", "w"); A.write_ML(fp); fclose(fp); umLOG(1, "exiting.\n"); return; } // iterative solver CS_PCG it_sol; try { // Note: operator A is symmetric, with only its // lower triangule stored. We use this symmetry // to accelerate operator A*x int flag=sp_SYMMETRIC; flag|=sp_LOWER; flag|=sp_TRIANGULAR; A.set_shape(flag); // drop tolerance for cholinc double droptol=1e-4; // Note: ownership of A is transfered to solver object it_sol.cholinc(A, droptol); } catch(...) { umLOG(1, "\nCaught exception from symbolic chol.\n"); } DVec exact("exact"), f("f"), rhs("rhs"), u("u"); double t1=0.0,t2=0.0; //------------------------------------------------------- // set up boundary condition //------------------------------------------------------- DVec xbc = Fx(mapB), ybc = Fy(mapB), zbc = Fz(mapB); DVec ubc(Nfp*Nfaces*K); ubc(mapB) = sin(pi*xbc) * sin(pi*ybc) * sin(pi*zbc); //------------------------------------------------------- // form right hand side contribution from boundary condition //------------------------------------------------------- DMat Abc = PoissonIPDGbc3D(ubc); //------------------------------------------------------- // evaluate forcing function //------------------------------------------------------- exact = sin(pi*x).dm(sin(pi*y).dm(sin(pi*z))); f = (-3.0*SQ(pi)) * exact; //------------------------------------------------------- // set up right hand side for variational Poisson equation //------------------------------------------------------- rhs = M*(-f) + (DVec&)(Abc); //------------------------------------------------------- // solve using pcg iterative solver //------------------------------------------------------- t1 = timer.read(); u = it_sol.solve(rhs, 1e-9, 30); t2 = timer.read(); //------------------------------------------------------- // compute nodal error //------------------------------------------------------- r = (u-exact); m_maxAbsError = r.max_val_abs(); umLOG(1, " solve -- done. (%0.4lf sec)\n\n", t2-t1); umLOG(1, " max error = %g\n\n", m_maxAbsError); #if (0) //####################################################### // plot solution and error figure(2); subplot(1,3,2); PlotContour3D(2*N, u, linspace(-1, 1, 10)); title('numerical solution'); subplot(1,3,3); PlotContour3D(2*N, log10(eps+abs(u-exact)), linspace(-4, 0, 10)); title('numerical error'); //####################################################### #endif double wt2=timer.read(); umLOG(1, "TestPoissonIPDG3D::Run() complete\n"); umLOG(1, "total time = %0.4lf sec\n\n", wt2-wt1); }