From: Alan W. I. <ir...@be...> - 2017-09-14 17:39:50
|
This general question has come up because plshade1 only differs from plshade in how the z 2D matrix argument is typed and handled inside the routine, but there is no similar plshades1, plcont1, plimage1, and plvect1 equivalents to plshades, plcont, plimage, and plvect. So for consistency with the rest, I would like to deprecate plshade1 and encourage the use of plshade instead. But part of that deprecation is explaining to users how to use plshade, but I need help with that. I could recommend to users to call plshade with a z argument that follows how the z 2D matrix argument of plcont is typed and defined. For example, in example 15 we currently use the statically defined z matrix PLFLT z[35][45]; z[i][j] = ....; plshade1( &z[0][0], ...); And I could replace that logic with logic where z is defined as in example 9 with plcont, i.e., as a 2D Iliffe vector (a vector of pointers to vectors of data, see <https://en.wikipedia.org/wiki/Iliffe_vector>). So in this case examples/c/x15c.c would look like the following: PLFLT **z; plAlloc2dGrid( &z, 35, 45); z[i][j] = ....; plshade( (const PLFLT * const *) z, ...); plFree2dGrid( z, 35, 45); Because of the similarity with how the z argument of plcont is handled, I am positive the above method would work, but I haven't implemented that yet because I think there _might_ be a simpler alternative where we use a combination of PLFLT z[35][45]; z[i][j] = ....; and a call to plshade( (const PLFLT * const *) z, ...); The assumption here is that this statically allocated z is a special case of an Iliffe vector and should "just work". But perhaps that assumption is wrong? The reason I am uncertain about that assumption, is I have already tried the above combination of statically allocated z array and that call to plshade, and it compiles without any warnings which is encouraging. However, the result segfaults at run time. So the question is whether there is something extra I have to do to get the above combination to work (and similarly for plshades, plcont, plimage, and plvect) or do users _always_ have to call those routines with z dynamically allocated with plAlloc2dGrid? Help with this question from the C experts here would be much appreciated. Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); the Time Ephemerides project (timeephem.sf.net); PLplot scientific plotting software package (plplot.sf.net); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ |