From: W. Trevor King Date: Thu, 29 Apr 2010 04:22:09 +0000 (-0400) Subject: Adjustments to graphMatrixFile for much smaller output. X-Git-Tag: v1.0~397 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e71aec0976f6acedc747dd63ed358be361d283b0;p=thesis.git Adjustments to graphMatrixFile for much smaller output. New implementation converts input x/y/z arrays to x and y sets specifying coordinates for a z matrix, which asymptote handles more cleanly than nominally non-gridded data. Also fixed palette positioning, which was broken in the previous implementation. --- diff --git a/tex/src/figures/asy/wtk_graph.asy b/tex/src/figures/asy/wtk_graph.asy index 1e8b172..87c3ab9 100644 --- a/tex/src/figures/asy/wtk_graph.asy +++ b/tex/src/figures/asy/wtk_graph.asy @@ -40,10 +40,46 @@ real[] identity_zfn(real[] z) { return z; } +/* Return a sorted list of unique entries in an array x */ +real[] set(real[] x) { + int i=1; + x = sort(x); + while (i < x.length){ + if (x[i] == x[i-1]) + x.delete(i); + else + i += 1; + } + return x; +} + +/* Convert x,y,z arrays to a z matrix */ +real[][] extract_matrix(real[] xs, real[] ys, real[] zs) { + int i, j, k; + real[] x_set = set(xs); + real[] y_set = set(ys); + real[] z_col = array(y_set.length, 0); + real[][] z_matrix = array(n=x_set.length, z_col); + //assert zs.length == x_set.length*y_set.length; + for (i=0; i