/* Copyright (c) 2013 Daniel Stahlke Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include // This must be included before gnuplot-iostream.h in order to support plotting blitz arrays. #include #include "gnuplot-iostream.h" // Yes, I'm including a *.cc file. It contains main(). #include "examples-framework.cc" void demo_blitz_basic() { // -persist option makes the window not disappear when your program exits Gnuplot gp("gnuplot -persist"); blitz::Array arr(100, 100); { blitz::firstIndex i; blitz::secondIndex j; arr = (i-50) * (j-50); } gp << "set pm3d map; set palette" << std::endl; gp << "splot '-'" << std::endl; gp.send(arr); } void demo_blitz_waves_binary() { Gnuplot gp("gnuplot -persist"); // example from Blitz manual: int N = 64, cycles = 3; double midpoint = (N-1)/2.; double omega = 2.0 * M_PI * cycles / double(N); double tau = - 10.0 / N; blitz::Array F(N, N); blitz::firstIndex i; blitz::secondIndex j; F = cos(omega * sqrt(pow2(i-midpoint) + pow2(j-midpoint))) * exp(tau * sqrt(pow2(i-midpoint) + pow2(j-midpoint))); gp << "splot '-' binary" << gp.binfmt(F) << "dx=10 dy=10 origin=(5,5,0) with pm3d notitle" << std::endl; gp.sendBinary(F); } void demo_blitz_sierpinski_binary() { Gnuplot gp("gnuplot -persist"); int N = 256; blitz::Array, 2> F(N, N); for(int i=0; i F(N, N); blitz::firstIndex i; blitz::secondIndex j; F = cos(omega * sqrt(pow2(i-midpoint) + pow2(j-midpoint))) * exp(tau * sqrt(pow2(i-midpoint) + pow2(j-midpoint))); gp << "splot" << gp.binaryFile(F) << "dx=10 dy=10 origin=(5,5,0) with pm3d notitle" << std::endl; } void demo_blitz_sierpinski_binary_file() { Gnuplot gp("gnuplot -persist"); int N = 256; blitz::Array, 2> F(N, N); for(int i=0; i