From e71aec0976f6acedc747dd63ed358be361d283b0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 29 Apr 2010 00:22:09 -0400 Subject: [PATCH] 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. --- tex/src/figures/asy/wtk_graph.asy | 71 ++++++++++++++++++++---- tex/src/figures/fit-space/fit-valley.asy | 15 ++--- tex/src/sawsim/discussion.tex | 5 +- 3 files changed, 68 insertions(+), 23 deletions(-) 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