PSPlot works on Windows Vista


MPD78
08-03-2009, 06:09 AM
Edit:

I was incorrect about the pointsymbol() function. All works like a charm.

Matt 8/3/09 2:48 PM EST


To save everyone the trouble of reading the PSPlot thread (which can be found at the link below) I thought I would tell you all that GSView and PSPlot function correctly in Windows Vista. The only exception (or error) that I encountered was with the pointsymbol function. Vista doesn't seem to let this function operate correctly for some reason. Forgive me for the lack of detail on this however, I am a mechanical engineer and on a good day a C++ programmer and I lack the ability to give any substantial reason why Vista has a conflict with the pointsymbol function. So if you comment out the calls to the pointsymbol function used in the example program in the book you will obtain the graph minus the symbols.

http://www.nr.com/forum/showthread.php?t=1797

Thanks
Matt

davekw7x
08-03-2009, 09:40 AM
...the pointsymbol function...

The pointsymbol function has exactly one line of code. I have no way of testing with Vista (and no desire to).

I have great difficulty in believing that your Microsoft compiler works on Vista with everything else but somehow doesn't handle that line correctly.

My guess: Typographical error in psplot.h

My suggestion: Try the following. It won't give a plot to look at with gsview32, but you can compare the resulting "test.ps" output file with the lines that I show inside the comment at the end.


//
// Edit the "include" lines (if necessary) to specify the path to your header files
//
// davekw7x
//
#include "../code/nr3.h"
#include "../code/psplot.h"

int main()
{
char *filename = "test.ps";
PSpage pg(filename);
PSplot plot1(pg,100.,500.,100.,500.);
plot1.pointsymbol(1.,exp(-0.5),72,16.);

return 0;
}
/* Contents of test.ps should be the following
%!
/mt{moveto}def /lt{lineto}def /np{newpath}def
/st{stroke}def /cp{closepath}def /fi{fill}def
/zp {gsave /ZapfDingbats findfont exch scalefont setfont moveto show grestore} def
/Times-Roman findfont 12 scalefont setfont
0.5 setlinewidth
(\110) -5.304 -4.88147 16 zp
showpage
*/


The penultimate line comes from the pointsymbol function:


(\110) -5.304 -4.88147 16 zp


Regards,

Dave

MPD78
08-03-2009, 10:04 AM
Ahh ... didn't really think I would get a reply to this thread but thanks for the additional input.

I am confident that you can rule out typos because if I load the same project onto my Windows XP machine and uncomment the pointsymbol() function, all works fine.

Now that I see there is some interest in this thread I will look deeper into it. I don't have access to the Vista machine at this moment but I will try your program this afternoon.

Thanks for all your patience and persistence with this matter.

Matt

MPD78
08-03-2009, 01:27 PM
All, please ignore the post about the pointsymbol() function not working on Vista. Once I rebooted my machine all works like a charm.

????

Sorry all for the bad information.

Matt

amirvahid
08-10-2009, 03:53 PM
I wonder if you could enclose your "correct" source code to this thread so that everybody can understand your discussion.

davekw7x
08-10-2009, 05:03 PM
I wonder if you could enclose your "correct" source code to this thread so that everybody can understand your discussion.

The Original Poster was referring to this thread: http://www.nr.com/forum/showthread.php?t=1797


I used the source program from the Original Poster and I used distribution files from the NR3 CD on my Windows xp workstation with Visual C++ Express version 8. The only change that I needed was in the NR3 psplotexample.h file.

Since I don't have a d:\nr3\newchap20 directory, I changed the following line:

PSpage pg("d:\\nr3\\newchap20\\myplot.ps");


to this:

PSpage pg("myplot.ps");



The listings of the psplot.h and psplotexample.h function files are in Webnote number 26, and the Original Poster had numerous typographical errors that (I believe) caused all of the other problems that were encountered. See Footnote.


Bottom line: If people want to type in the code themselves, they should allocate extra debugging time for the tools before they get to the "Good Stuff" of whatever problem they want to solve.

Sometimes strangers on the web can help them and sometimes---not so much. I mean, I usually like to try, but...


Regards,



Dave

Footnote: Even though the Webnotes files are available without charge, I perceive that they are still copyrighted, so I can't post the actual code for those particular functions.

Note to copyright owner: I hope that I didn't violate the copyright (too much) by posting line 12 of psplotexample.h here to show how I changed it. My intentions are honorable (and not-for-profit). Does that count for anything?

MPD78
08-10-2009, 08:26 PM
Dave,

Thanks for providing clarity to this thread.

My intent when I post questions is to provided to myself and other amateurs some insight into how to properly use the algorithms in this book. However the quote below troubles me.

Bottom line: If people want to type in the code themselves, they should allocate extra debugging time for the tools before they get to the "Good Stuff" of whatever problem they want to solve.

I intentionally type in my own code. That is how I learn and it has paid off temendously for me. Yes, typos do find their way through my fingers and into my code. Because of typing in my own code I was able to gain a much better foot hold on templates, structs, and functors. So I encourage the typing in of these algorithms if you are an amateur or simply if you are new to them.

I do apologize for the wasting of your time with chasing down nothing more than typos in the PSplot thread that you provided a link to above.

I also have to address this quote as well.

Sometimes strangers on the web can help them and sometimes---not so much. I mean, I usually like to try, but...

Pleas don't think that you haven't helped me. Your answers to my posts have been tremendous help and are much appreciated. I am sure others enjoy the rewards of reading my questions and your answers.

Sigh.... Maybe I have taken this personally when that was not your intention. If so I apologize.

Thanks
Matt

davekw7x
08-10-2009, 10:48 PM
...However the quote below troubles me...
I did not intend to convey disrespect or any other negative feelings. I am extremely sorry if it came out that way.



I intentionally type in my own code....So I encourage the typing in ...My comment was intended to suggest that the "easy way" is to buy the CD. I didn't mean that the "easy" way is necessarily the "best" way. See Footnote.

I was responding to the poster who asked for "correct" source. I was just trying to point out that, except for changing the path name of the temporary PostScript file used by gsview32, the code in the Webnote is the correct code and works just fine for me on Windows xp with Version 8 of the Microsoft Visual C++ Express. That's all.

...wasting of your time

People have different ways of trying to learn and people have different ways of trying to help. If I felt I was wasting my time I wouldn't reply. I have no connection with the owners of the web site (or the book or the code in the book). I come here to learn and to try to learn to help.


I also have to address this quote as well...That was intended to be a general disclaimer. Sometimes I think I am helping; sometimes, well...

Sometimes I just don't "get it," and sometimes I run out of inspiration and/or stamina before we arrive at a successful conclusion. You have been polite enough to take the time to give me feedback when the stuff works. Thanks.

If people need a specific example of the use of a particular function (to see how to implement the test program or to get specific outputs for comparison purposes) I will try to help if I can.

In other words: When asking for help and getting help from strangers on the web: Your Mileage May Vary.

...not your intention

It certainly was not my intention.

Regards,

Dave

Footnote: Some time not long after the middle of the last century, I was taking Plane Geometry (in the tenth grade). The teacher was just about the best I ever had (and I have had a lot of them over the years---a lot). A little old white-haired almost stereotypical school teacher (not a spinster, however; she had been married for something like forty years), bless her heart.

With a twinkle in her eyes, she told us (horny teenagers and newly licensed drivers that we were) that although a straight line is the shortest distance between two points in a plane, "the shortest way home is not always the sweetest way home."

Bottom line: Code off of a disk may get us to the "good stuff" of solving certain problems quickly, but it's not necessarily the best way to learn the underlying principles of the algorithms or of the code that implements them.