%!PS % A full cycle, split quadrant demo and tester % ==================================================== % by Don Lancaster GG #76 PS8DPRP1.PSL % Copyright c 2006 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % Linking welcome. Reposting expressly forbidden. % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\Documents and Settings\\don\\Desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. % PostScript numeric reporter utility... % An 8 Decimal Point PostScript Real Reporter Utility % ==================================================== % by Don Lancaster PS8DPRPT.PSL % Copyright c 2007 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % Linking welcome. Reposting expressly forbidden. % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % PostScript reals are internally calculated to near 8 decimal point precision % by use of their IEEE 32 bit floating point routines. The real results are % normally only reported to six decimal points. While more than adequate for % the majority of PS users, certain PostScript-as-Language apps may demand % (or at least welcome) more reportable precision. % The utilities presented here provide reporting of up to eight decimal % point precision. There typically will be a count or two of innacuracy % on the eighth decimal point. The reporting accuracy improvement will % approach 100:1. No internal mods to the PostScript interpreter are made. % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is optional for this utility % but recommended for its use. % After obvious location mods, uncomment ONE of the following two lines: % (C:\\Documents and Settings\\don\\Desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. %%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%% % PostScript normally reports real values only to six decimal point precision. % Internally, nearly eight decimal points of precision are available per the % IEEE floating point routines. Certain custom PostScript-as-language apps may % demand ( or at least welcome ) more than six decimal points of precision. % /realto8dstring converts any signed PostScript real in the absolute range % of 0.000000001 to 999,999,999 to a reportable string accurate to nearly eight % decimal points of precision. Larger absolute values create an error while % smaller ones truncate and report as 0.0000000 or -0.0000000. % To use, place a real number or its variable on the stack and call % realto8dstring. The equvalent reportable string returns to the stack top. % Operation is based on converting any real over the allowable range to % an integer in the 10 to 100 million range, converting that integer to % a string, and modifying the string as needed for a decimal point and sign. % This utility presently operates over an absolute value range of 0.0000001 % to 99,999,999. Larger values are reported as errors. Smaller values are % truncated to 0.00000000. % One count or more uncertainties may exist in the eighth decimal place. % /mergestr is a string merger from my gonzo utilities. Complete utilities % are found at http://www.tinaja.com/post01.asp#gonzo ... /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def % /realto8dstring is the high level code for the reporting conversion. It % determines the sign and then tests for values too large or too small. % It then goes to processgoodreal for actual report conversions. % A final deferencing is done to provide a unique output string. /realto8dstring {dup 0 lt % test and flag negatives /isneg exch store abs /val exch store % save real as absolute value val 100000000 ge { % report and error trap values (real is too big! )== % that are too large to process real_is_too_big! } if val 0.00000001 le % truncate small numbers to zero {(0.0000000)} {processgoodreal} ifelse % process numbers versus zeros isneg {(-)}{( )} ifelse % create leading space or minus exch mergestr % add leading space or minus 20 string cvs % dereference string to avoid % any possible rude surprises } store % /processgoodreal continues the realto8string processing after numbers too % large and too small have been dealt with. Subprocs are called for tenmillions, % unitsormore, and fractions. Note that log floor cvi tells you the decade % size and position of any positive number. /processgoodreal { val log floor cvi % evaluate decimal location /posn exch store % posn 7 eq {tenmillions} % treat ten millions special {posn 0 ge {unitsormore} % handle >1 as a class {fractions} % handle fractions as a class ifelse } ifelse } store % /tenmillions handles ten millions as a special case needing no reformatting. /tenmillions { val round cvi % use ten millions val as is. 20 string cvs } store % /unitsormore handles units through millions... /unitsormore { /workstring val % scale val as needed to 10-99 megs 1 7 posn sub {10 mul} % this may give more accuracy repeat mul round cvi 20 string cvs store % and convert to string workstring 0 posn 1 add % stuff decimal point getinterval (.) mergestr workstring % post remainder of string posn 1 add workstring length 1 sub posn sub getinterval mergestr 20 string cvs % dereference } store % /fractions handles fractional values /fractions {/workstring val % scale workstring 1 7 posn sub {10 mul} repeat % this may give more accuracy mul round cvi 20 string cvs store % and convert to string (0.) % prepend leading zero and dp posn neg 1 sub % add intermediate zeros {(0) mergestr} repeat workstring mergestr % postpend value 20 string cvs % dereference } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%% demo - remove or alter before reuse %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % An "Empty job. No PDF file produced." message is normal and expected. % 2 sqrt 10000000 mul realto8dstring == %%%%%%%%%%%%% %%%%%%%%%%%%% FULL CYCLE DATA %%%%%%%%%%%%%%% /regmagsin8.6 [ 5.65029593062 6.29225152936 15.81862798201 17.71453042722 26.26333600962 29.36133313031 36.84108032643 41.04778015351 47.5658943498 52.74756810010 58.4640633843 64.44315460533 69.5556070049 76.10701844505 80.8431647264 87.6958887633 ]store % normal magsin uncontrolled harms record from previous analysis... % h31 = 0.70119349921 % h33 = -0.49857579402 % h35 = -0.21908625461 % h37 = -0.02988268814 /bbemagsin8.6 [ 10.4353438671 11.7077750493 20.9101395432 23.4181541929 31.4636502516 35.1329284465 42.1342741421 46.8514916513 52.9576520410 58.5675969212 63.9624867662 70.2640240671 75.1632563302 81.9072380861 86.5515348716 90.0000000000 ] store % bbe 8.6 magsin uncontrolled harms record from previous analysis... % h31 = -0.71971577316 % h33 = 0.47421202953 % h35 = 0.21303620988 % h37 = 0.03024943268 % /fullfun calculates the full Fourier fundamental given quad1 quad2 quad3 and quad4 data % It is presently hardwired to 8 pulses per quadrant. /fullfun { 0 % marking accumulator quad1 0 get cos quad1 1 get cos sub add quad1 2 get cos quad1 3 get cos sub add quad1 4 get cos quad1 5 get cos sub add quad1 6 get cos quad1 7 get cos sub add quad1 8 get cos quad1 9 get cos sub add quad1 10 get cos quad1 11 get cos sub add quad1 12 get cos quad1 13 get cos sub add quad1 14 get cos quad1 15 get cos sub add (\n\nQuarter amp check is ) print flush dup pi div realto8dstring == 180 quad2 0 get sub cos 180 quad2 1 get sub cos sub neg add 180 quad2 2 get sub cos 180 quad2 3 get sub cos sub neg add 180 quad2 4 get sub cos 180 quad2 5 get sub cos sub neg add 180 quad2 6 get sub cos 180 quad2 7 get sub cos sub neg add 180 quad2 8 get sub cos 180 quad2 9 get sub cos sub neg add 180 quad2 10 get sub cos 180 quad2 11 get sub cos sub neg add 180 quad2 12 get sub cos 180 quad2 13 get sub cos sub neg add 180 quad2 14 get sub cos 180 quad2 15 get sub cos sub neg add (Half amp check is ) print flush dup pi div realto8dstring == 180 quad3 0 get add cos 180 quad3 1 get add cos sub neg add 180 quad3 2 get add cos 180 quad3 3 get add cos sub neg add 180 quad3 4 get add cos 180 quad3 5 get add cos sub neg add 180 quad3 6 get add cos 180 quad3 7 get add cos sub neg add 180 quad3 8 get add cos 180 quad3 9 get add cos sub neg add 180 quad3 10 get add cos 180 quad3 11 get add cos sub neg add 180 quad3 12 get add cos 180 quad3 13 get add cos sub neg add 180 quad3 14 get add cos 180 quad3 15 get add cos sub neg add (Three quarter amp check is ) print flush dup pi div realto8dstring == 360 quad4 0 get add cos 360 quad4 1 get add cos sub add 360 quad4 2 get add cos 360 quad4 3 get add cos sub add 360 quad4 4 get add cos 360 quad4 5 get add cos sub add 360 quad4 6 get add cos 360 quad4 7 get add cos sub add 360 quad4 8 get add cos 360 quad4 9 get add cos sub add 360 quad4 10 get add cos 360 quad4 11 get add cos sub add 360 quad4 12 get add cos 360 quad4 13 get add cos sub add 360 quad4 14 get add cos 360 quad4 15 get add cos sub add pi div /fund1 exch store (Fundamental amplitude per cycle is ) print flush fund1 realto8dstring == } store % /fullharm calculates the full Fourier harmonics given quad1 quad2 quad3 and quad4 data % It is presently hardwired to 8 pulses per quadrant. /fullharm { mark % start harmonic array fund1 % enter fundamental 3 2 73 {/hnum exch store % for each harmonic 0 % marking accumulator quad1 0 get hnum mul cos quad1 1 get hnum mul cos sub add quad1 2 get hnum mul cos quad1 3 get hnum mul cos sub add quad1 4 get hnum mul cos quad1 5 get hnum mul cos sub add quad1 6 get hnum mul cos quad1 7 get hnum mul cos sub add quad1 8 get hnum mul cos quad1 9 get hnum mul cos sub add quad1 10 get hnum mul cos quad1 11 get hnum mul cos sub add quad1 12 get hnum mul cos quad1 13 get hnum mul cos sub add quad1 14 get hnum mul cos quad1 15 get hnum mul cos sub add % (\n\nQuarter amp check is ) print flush dup pi div realto8dstring == 180 quad2 0 get sub hnum mul cos 180 quad2 1 get sub hnum mul cos sub neg add 180 quad2 2 get sub hnum mul cos 180 quad2 3 get sub hnum mul cos sub neg add 180 quad2 4 get sub hnum mul cos 180 quad2 5 get sub hnum mul cos sub neg add 180 quad2 6 get sub hnum mul cos 180 quad2 7 get sub hnum mul cos sub neg add 180 quad2 8 get sub hnum mul cos 180 quad2 9 get sub hnum mul cos sub neg add 180 quad2 10 get sub hnum mul cos 180 quad2 11 get sub hnum mul cos sub neg add 180 quad2 12 get sub hnum mul cos 180 quad2 13 get sub hnum mul cos sub neg add 180 quad2 14 get sub hnum mul cos 180 quad2 15 get sub hnum mul cos sub neg add % (Half amp check is ) print flush dup pi div realto8dstring == 180 quad3 0 get add hnum mul cos 180 quad3 1 get add hnum mul cos sub neg add 180 quad3 2 get add hnum mul cos 180 quad3 3 get add hnum mul cos sub neg add 180 quad3 4 get add hnum mul cos 180 quad3 5 get add hnum mul cos sub neg add 180 quad3 6 get add hnum mul cos 180 quad3 7 get add hnum mul cos sub neg add 180 quad3 8 get add hnum mul cos 180 quad3 9 get add hnum mul cos sub neg add 180 quad3 10 get add hnum mul cos 180 quad3 11 get add hnum mul cos sub neg add 180 quad3 12 get add hnum mul cos 180 quad3 13 get add hnum mul cos sub neg add 180 quad3 14 get add hnum mul cos 180 quad3 15 get add hnum mul cos sub neg add % (Three quarter amp check is ) print flush dup pi div realto8dstring == 360 quad4 0 get add hnum mul cos 360 quad4 1 get add hnum mul cos sub add 360 quad4 2 get add hnum mul cos 360 quad4 3 get add hnum mul cos sub add 360 quad4 4 get add hnum mul cos 360 quad4 5 get add hnum mul cos sub add 360 quad4 6 get add hnum mul cos 360 quad4 7 get add hnum mul cos sub add 360 quad4 8 get add hnum mul cos 360 quad4 9 get add hnum mul cos sub add 360 quad4 10 get add hnum mul cos 360 quad4 11 get add hnum mul cos sub add 360 quad4 12 get add hnum mul cos 360 quad4 13 get add hnum mul cos sub add 360 quad4 14 get add hnum mul cos 360 quad4 15 get add hnum mul cos sub add pi div % find amplitude hnum div % scale by harmonic number fund1 div % scale to fundamental % leave as array entry % (\ndid one harm ) print flush } for % for each harmonic ] % complete harmonic array dup == } store %%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%% Demos - remove or alter before reuse %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%% % Send these to Acrobat Distiller and view the log files. % Use a command line activation of acrodist -F for versions 8.1 and above. % For extreme math accuracy, rewrite in JavaScript. (\n\n\nstarting with regular mag sines... ) print flush /quad1 regmagsin8.6 store % start with identical regular mag sines /quad2 regmagsin8.6 store /quad3 regmagsin8.6 store /quad4 regmagsin8.6 store fullfun fullharm (\n\n\nchanging to bbe mag sines... ) print flush /quad1 bbemagsin8.6 store % start with identical bbe mag sines /quad2 bbemagsin8.6 store /quad3 bbemagsin8.6 store /quad4 bbemagsin8.6 store fullfun fullharm (\n\n\nalternating mag sine typess... ) print flush /quad1 regmagsin8.6 store % start with identical regular mag sines /quad2 bbemagsin8.6 store /quad3 regmagsin8.6 store /quad4 bbemagsin8.6 store fullfun fullharm % This one should be aestetically more pleasing, 6% more efficient... (\n\n\nhalfcycle bef then halfcycle normal ) print flush /quad1 bbemagsin8.6 store % start with identical regular mag sines /quad2 bbemagsin8.6 store /quad3 regmagsin8.6 store /quad4 regmagsin8.6 store fullfun fullharm % EOF