Article View: adobe.postscript.programming
Article #22Re: postscript & sparse matrices: howto?
From: Jeffrey H. Coffield
Date: Sat, 31 Jan 2009 19:24
Date: Sat, 31 Jan 2009 19:24
52 lines
2973 bytes
2973 bytes
Nico_Schl๏ฟฝmer@adobeforums.com wrote:
> hi!
>
> i'm dealing with matrices here and want to plot its value into postscript. in fact, i just need a black spot where a matrix entry is not zero, white everywhere else. easy, isn't it?
>
> particulary, my matrices have very few non-zero entries, so the ps file would only have a few black spots here and there.
>
> now, what's the best way to write this in postscript? the first thing i tried was the image environment: works well as soon as you got used to the syntax, but the big disadvantage for me was that i have to explicitly code all the white pixels, so the eps file gets a lot bigger than needed (it feels).
>
> the second thing i tried was defining a small "draw tiny box" command, then "move to" the non-zero spots, and evoke the function.
> that's better then the image way (the files are a lot smaller), but it still feels like a hack somehow.
>
> do you have any hints or suggestions for the issue? are there any commands or environment that would be better suited?
>
> all hints appreciated!
>
> cheers,
> nico
Would something like this work for you?
%! Adobe-PS
/inch {72 mul} def
<</PageSize [8.5 inch 11 inch]>> setpagedevice
/MaxValue 10 def % The max x or y value plotted
/GraphSize 8 inch def % The width of the graph
/Scale GraphSize MaxValue div def
.25 inch .5 inch translate
gsave .5 setgray 0 0 GraphSize GraphSize rectstroke grestore
Scale Scale scale
/Box {gsave translate 0 0 1 1 rectfill grestore} def
0 0 Box
1 1 Box
2 2 Box
3 3 Box
4 4 Box
5 5 Box
6 6 Box
7 7 Box
9 9 Box
showpage
Jeff Coffield
www.digitalsynergyinc.com
Technical Details
Message-ID:
<Cz1hl.6097$jZ1.4764@flpi144.ffdc.sbc.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!flph200.ffdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!flpi144.ffdc.sbc.com.POSTED!cbb6f965!not-for-mailReferences:
<59b7be49.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: 10c61a,527ad8c75b709cef X-Google-Attributes: gid10c61a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!flph200.ffdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!flpi144.ffdc.sbc.com.POSTED!cbb6f965!not-for-mail From: "Jeffrey H. Coffield" <jeffrey@digitalsynergyinc.com> User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 Newsgroups: adobe.postscript.programming Subject: Re: postscript & sparse matrices: howto? References: <59b7be49.-1@webcrossing.la2eafNXanI> In-Reply-To: <59b7be49.-1@webcrossing.la2eafNXanI> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Lines: 52 Message-ID: <Cz1hl.6097$jZ1.4764@flpi144.ffdc.sbc.com> NNTP-Posting-Host: 216.103.32.162 X-Complaints-To: abuse@prodigy.net X-Trace: flpi144.ffdc.sbc.com 1233429858 ST000 216.103.32.162 (Sat, 31 Jan 2009 14:24:18 EST) NNTP-Posting-Date: Sat, 31 Jan 2009 14:24:18 EST Organization: at&t http://my.att.net/ X-UserInfo1: [[PGW_[DSRWARTXXJBCD^VX@WB]^PCPDLXUNNHLHQAVTUZ]CLNTCPFK[WDXDHV[K^FCGJCJLPF_D_NCC@FUG^Q\DINVAXSLIFXYJSSCCALP@PB@\OS@BITWAH\CQZKJMMD^SJA^NXA\GVLSRBD^M_NW_F[YLVTWIGAXAQBOATKBBQRXECDFDMQ\DZFUE@\JM Date: Sat, 31 Jan 2009 11:24:17 -0800