Re: [Help-gsl] Keeping fixed memory allocation for an interpolating object
On 14 October 2013 10:52, Ruben Farinelli farine...@fe.infn.it wrote: However allocating at each call in the function the dimension of the object and then freeing it via the commands spline=gsl_spline_alloc(gsl_interp_cspline, BIN); gsl_spline_init(spline, array_x, array_y, BIN); /* commands */ gsl_spline_free(spline); is very time consuming. If you could post the whole of your loop it would help, i.e. what are you doing in commands? Why don't you do something like the manual example? http://www.gnu.org/software/gsl/manual/html_node/Interpolation-Example-programs.html Hope that helps! Sam
Re: [Help-gsl] gsl performance
Hi, On 7 October 2013 18:22, onefire onefire.mys...@gmail.com wrote: One, which I like, is that the routines give the user low-level control over their progress in the sense that you can create an object, manually iterate and observe their progress. I prefer this over having a single function that does the work until convergence (but see below). Yes, everybody wants to terminate at different places—flat gradient, max number of steps, some combination or other condition... Having this outside of the GSL makes sense. You could let this be evaluated by another callback, but then this would be three callbacks now? Reading your earlier messages, implies that you want to perform many minimizations (or other algorithms?). Could you not just allocate one minimizer (or one per thread) and reset it as needed? That way you don't need to be free()ing/malloc()ing same same memory all the time. I guess it depends on whether the number of variables changes. I tried this technique with the ODE solvers in the GSL and it gave me about 5% overall performance improvement so I dropped it from my code, it was a fiddle to maintain and the user would barely notice the difference. I was doing quite a lot of other things, so maybe if your overall time is dominated by malloc/free it may help. Not sure whether it would be worth trying a different memory allocator. There used to be faster ones available, but they could well be folded into the standard libraries now. Hope some of that is useful for you! Sam
Re: [Help-gsl] Computation of gsl_sf_hyperg_1F1 fails for some values
On 10 May 2013 10:43, Daniel Schury daniel.sch...@physik.uni-giessen.de wrote: double part22 = gsl_sf_hyperg_1F1(-p/2.0, 1.0/2.0, - -1.0/2.0*((E1-x)/dE)^2.0); In this case; in C the ^ operator is a bitwise xor and doesn't raise things to a power. Is that double negation really needed? Seems redundant, or am I missing something? This works for most values, but fails for some. With p = 2.09, E1 = 8, x = 26.8 and dE = 0.5 my program crashes. You be better off reporting the actual values of a, b and x that caused the program to crash. When you printed these out you may notice that something strange is happening. Can somebody confirm this problem maybe on a different platform or has an idea how to trace the problem? Fixing the code to actually square things works for me in Linux with GSL v1.15, but gives back a *very* large number: 3.2e301. Mathematica gives the same value, so at least they're both consistent. I'd break things down to debug it. I.e. create some more variables to save the values of a, b, x, then use printf to display them—or use a debugger. You should then be able to see you're getting strange things going on before calling the hypergeometric function. It seems strange that your compiler isn't complaining about the xor! GCC does. Hope that helps! Sam
Re: [Help-gsl] Computation of gsl_sf_hyperg_1F1 fails for some values
On 10 May 2013 12:20, Daniel Schury daniel.sch...@physik.uni-giessen.de wrote: Is that double negation really needed? Seems redundant, or am I missing something? I don't know where the double minus came from, but the third parameter is in fact -1.0/2.0*pow((E1-x)/dE,2.0)). Then The value should be something around 457. If I evaluate the above in Mathematica (v8) with the values you gave before I get 1895.95 back; not sure why we're getting different answers. Then again I don't have any experience of these hypergeometric functions so can't suggest much to help here—sorry! In this case; in C the ^ operator is a bitwise xor and doesn't raise things to a power. As you can see, I changed the ^ to pow(), but that doesn't help. The Origin C compiler understands the ^, so that's not the problem. OK, but that's strange; if it's really a C++ compiler underneath that's overloading this for doubles then that seems sort of reasonable. You really need to isolate the bit of code and run it in a plain C compiler to figure out where the problem is coming from. You be better off reporting the actual values of a, b and x that caused the program to crash. When you printed these out you may notice that something strange is happening. The given values _are_ values I got problems with. No, you're doing some calculations. If you reported: gsl_sf_hyperg_1F1(-1.045, 0.5, -706.88) then things would be clearer. Interestingely, the last time I got a new error message: R6025 - pure virtual function call But the description given by microsoft (http://support.microsoft.com/kb/125749/en-us) doesn't help me. This is a C++ error message; something has gone wrong with your class hierarchy; you need to look at your C++ code as this isn't anything to do with the GSL. Maybe the wrappers from Origin are breaking something? Sam
Re: [Help-gsl] Computation of gsl_sf_hyperg_1F1 fails for some values
On 10 May 2013 13:07, Daniel Schury daniel.sch...@physik.uni-giessen.de wrote: Am 10.05.2013 13:58, schrieb Sam Mason: gsl_sf_hyperg_1F1(-1.045, 0.5, -706.88) Ok, now I know what you mean. Does not change anything, program crashes. Huh, I should have tried that! I get: gsl: exp.c:254: ERROR: overflow not sure if I can help much more as I don't know about the Hypergeometric functions. Sorry, Sam
Re: [Help-gsl] multidim interpolation
On 9 May 2013 02:35, jeremy theler jer...@talador.com.ar wrote: what I want to do is to interpolate arbritarily-scattered data, not only points located in a rectangular grid. Depending on how statistical you want to be, gaussian processes/fields can be very useful for this sort of thing. GSL helps a bit, but is missing the multivariate normal distribution, but there is code here to extend it: http://www.mail-archive.com/help-gsl@gnu.org/msg00631.html The computationally intensive part is generating the covariance matrix, which is O(n^2) so only really usable when you have less than a few thousand points. Hope that helps! Sam
[Help-gsl] gamma distribution
Hi, I've been using the GSL for a while and have just realised that I'm working around bugs in the Gamma distribution's RNG and PDF. Some parameters (i.e. small alpha and beta) cause the RNG to return zero. As far as I understand this is incorrect mathematically and is infact due to rounding errors. I'm OK with this feature, but when you feed this zero back to gsl_ran_gamma_pdf() (with the same parameters) you get zero probability–which feels wrong. The implementation in R returns +Inf when alpha 1, which seems more useful. I'm currently working around this by adding DBL_MIN onto the value I get back from gsl_ran_gamma(), but this doesn't seem very nice. Would a patch that adjusts the behaviour of gsl_ran_gamma_pdf(), i.e. changing the second if statement to: else if (x == 0) { if (a == 1) return 1/b ; else if (a 1) return GSL_POSINF ; else return 0 ; } do the right thing in everybody's eyes? Thanks, Sam
Re: [Help-gsl] Problem with gsl_linalg_cholesky_invert
On 23 Mar 2013 16:30, gianluca mastrantonio gianluca.mastranto...@yahoo.it wrote: I compile the code with the following command: gcc-mp-4.7 wrapnorm.c -o wrapnorm -lgsl -l gslcblas -lm I'd recommend compiling with warnings so that GCC can suggest what's going wrong. The -Wall flag is what I normally use. I'd imagine it telling you that Patrick is right... Sam
Re: [Help-gsl] email from changes in doc directory
Hi, If there isn't something built into Savannah; it would seem possible (in probably 10-20 lines of shell script) to have your computer have its own copy of the code and set up a cron job to check for changes against the official repository. If there are any it can then easily send you an email saying there's work to do. Sam
Re: [Help-gsl] solution of 3d quadratic algebraic system
On 31 Oct 2012 05:25, FARKAS, Illes f...@elte.hu wrote: Thanks! How about multiple solutions? Biochemical systems often have more than one stable solution. Monte-carlo algorithms tend to be good for this sort of thing. You can get quite a good idea of the energy landscape this way, although presenting more than two gets awkward quickly... What tools would you or other readers of this list recommend? Python, R, Matlab/Octave and finally C for performance tends to be my personal tools of choice here. I tend to use most of them most weeks. Scala could be a fun one to look at though: http://darrenjw.wordpress.com/2011/07/16/gibbs-sampler-in-various-languages-revisited/ Sam
Re: [Help-gsl] solution of 3d quadratic algebraic system
Could you put each variable through a logit transform? That's the normal way I'd tend to get appropriate answers. Either that or use a delta function to give +inf outside your range. Sam On 30 Oct 2012 05:41, FARKAS, Illes f...@elte.hu wrote: 2012/10/29 FARKAS, Illes f...@elte.hu 2012/10/28 Rhys Ulerich rhys.uler...@gmail.com Can you please suggest a fast GSL method / algorithm to find the solutions of a quadratic 3d system of algebraic equations? In the reduced form all 3 equations have zero on the l.h.s., and on the r.h.s. there are constant, linear and quadratic terms composed of x1, x2, x3 (the three variables). Newton iteration, especially if you provide analytic Jacobian, should do well here. There may be faster things that can return multiple solutions, however. - Rhys Thanks, I've chosen the hybrid algorithm http://www.gnu.org/software/gsl/manual/html_node/Example-programs-for-Multidimensional-Root-finding.html . Hello, The 3 variables represent biochemical concentrations normalized to the interval [0,1]. Can I tell the solver (or another solver) that it should stay inside this interval? I keep receiving solutions outside this interval, which are mathematically OK, but biochemically really nonsense. Also, with some help I'm ready to read/write the source code. Many thanks! Illes
Re: [Help-gsl] using histogram fuctions - not getting expected result.
On 29 June 2012 03:27, Calvin Morrison mutanttur...@gmail.com wrote: I want to return the value of the higest frequency. Am I doing this correctly? // Add red, green, and blue, values to their respective histogram for (i = 0; i nImages; i++) { gsl_histogram_increment (r, array[i][j][k][0]); gsl_histogram_increment (g, array[i][j][k][1]); gsl_histogram_increment (b, array[i][j][k][2]); } size_t red = gsl_histogram_max_bin(r); size_t green = gsl_histogram_max_bin(g); size_t blue = gsl_histogram_max_bin(b); Not sure how you're creating the histogram; but I'd expect you to have the answer here. Why do you go back into the histogram again? Would be interesting to know what you're doing; getting the mode of each channel separately seems like a strange thing to be doing. Sam
Re: [Help-gsl] using histogram fuctions - not getting expected result.
On 29 June 2012 16:16, Calvin Morrison mutanttur...@gmail.com wrote: https://github.com/mutantturkey/FlyTracking/blob/master/fly-tools/derive-background/pixel.c You really don't need the GSL histogram routines for that; just something like: int findmax (uint8_t *p, int n) { int mx = 0, v = p[0]; for (int i = 1; i n; i++) { if (p[i] v) { v = p[i]; mx = i; } } return mx; } uint8_t histr[256] = { 0 }, histg[256] = { 0 }, histb[256] = { 0 }; for (int i = 0; i nImages; i++) { histr[array[i][j][k][0]] += 1; histg[array[i][j][k][1]] += 1; histb[array[i][j][k][2]] += 1; } output[j][k][0] = findmax(histr, 256); output[j][k][1] = findmax(histg, 256); output[j][k][2] = findmax(histb, 256); I'd also recommend against storing the array as you are. Traversing lots of pointers is particularly inefficient (probably important if you're in CS; chasing down four pointers is going to kill performance as this is in the inner loop). It's much easier to allocate a big block of memory; i.e: uint8_t * array = calloc(nImages * width * height * 3); and use the following to access an arbitrary pixel: // return a pointer rgb pixel triplet static inline uint8_t *getpixel(int image, int x, int y) { return array[((image * width + x) * height + y) * 3]; } But for cases like where you're running along going over the same pixel for many images, you can do something like: uint8_t *px = (j * height + k) * 3; const size_t step = width * height * 3; for (int i = 0; i nImages; i++) { histr[px[0]] += 1; histg[px[1]] += 1; histb[px[2]] += 1; px += step; } Also, just thought that if you've got more than about 500 images you're better off (i.e. your working set will be smaller) storing all the histograms (i.e. width*height*3 histograms) in memory and streaming through the images. A Hope that helps! Sam
Re: [Help-gsl] problems with BFGS
On 17 June 2012 17:58, Claudio Tablada cjtabl...@yahoo.com.ar wrote: Thank you for his response. I attach the program in c for details. As I suspected; you're not checking your domains... The optimiser doesn't know that your functions are only defined for positive values and is naively passing it negative values. You need to put a couple of lines into your code when this isn't the case; i.e. return GSL_NAN from the likelihood function and an appropriate error code for derivatives (NaN also works for me, but not sure what this is supposed to be and the manual doesn't make it clear what appropriate is!). Hope that helps, Sam
Re: [Help-gsl] Doubt (bug?) in gsl_fit_linear function
On 9 June 2012 20:34, Ruchin Kansal ruchin.kan...@yahoo.com wrote: Yes, it shd be infinity. But at my end everything is printed as nan. Could you please post your outut in case it is different? As a single data point; Juan's code prints out NaN with GSL 1.15 (installed through macports). If you want any more details, let me know. Sam
Re: [Help-gsl] GSL in a microcontroller
Hi Jorge, Writing code for a microcontroller is very different from writing code for a personal computer; finding a microcontroller with a floating point unit is going to be a struggle, maybe your problem is better suited to a DSP? I'd have a look through one of the many tutorials on programming microcontrollers before going too far. You need to know quite a bit about the performance characteristics of your code, both space and time, before investing too much. Also power requirements and production volume should come into it; microcontrollers are efficient, but bigger batteries may be cheaper in the long run rather than investing a lot of time in developing something that you're only making a few of. Then again, if you're doing it for fun, it's a good challenge and will teach you a lot! Sam On 10 April 2012 11:12, Miguel Gallo, Jorge jmigu...@indra.es wrote: Hello, I have an algorithm running on my Linux personal computer using GSL library. I would like to implement the same algorithm in a microcontroller and I would like to ask your for tips about how to do that. Is there any microcontroller which can run any Linux OS in which I can include the GSL library? What can be the usage of program and data memory? Maybe it is necessary to use a microprocessor instead like ARM7? Many thanks, Jorge. Este correo electr?nico y, en su caso, cualquier fichero anexo al mismo, contiene informaci?n de car?cter confidencial exclusivamente dirigida a su destinatario o destinatarios. Si no es vd. el destinatario indicado, queda notificado que la lectura, utilizaci?n, divulgaci?n y/o copia sin autorizaci?n est? prohibida en virtud de la legislaci?n vigente. En el caso de haber recibido este correo electr?nico por error, se ruega notificar inmediatamente esta circunstancia mediante reenv?o a la direcci?n electr?nica del remitente. Evite imprimir este mensaje si no es estrictamente necesario. This email and any file attached to it (when applicable) contain(s) confidential information that is exclusively addressed to its recipient(s). If you are not the indicated recipient, you are informed that reading, using, disseminating and/or copying it without authorisation is forbidden in accordance with the legislation in effect. If you have received this email by mistake, please immediately notify the sender of the situation by resending it to their email address. Avoid printing this message if it is not absolutely necessary.
Re: [Help-gsl] GSL in a microcontroller
Hi Jorge, I've only played around with very small 8-bit Microchip PIC microcontrollers; very different from the sort of things you're interested in, sorry! Google suggests there are various ARM based development boards that use the GNU tool chain, a few seconds on google points to the following: http://www.openembedded.org/ It says it includes the GSL and has some hardware recommendations for getting started. Sam On 10 April 2012 12:20, Miguel Gallo, Jorge jmigu...@indra.es wrote: Hi, Many thanks for your answer. It doesn't matter the time and relatively money it can take up. However it does matter to me the space and power consumption. I know for instance microcontrollers of Kinetis based on ARM CortexM4 with floating point unit (K10 and K20 family). However my concern is how to implement a Linux in it. Are there any soft Linux versions specially for microcontrollers? If yes, how are they implemented? Thanks for your support, Jorge -Mensaje original- De: sammasonwarwick...@gmail.com [mailto:sammasonwarwick...@gmail.com] En nombre de Sam Mason Enviado el: martes, 10 de abril de 2012 12:57 Para: Miguel Gallo, Jorge CC: help-gsl@gnu.org Asunto: Re: [Help-gsl] GSL in a microcontroller Hi Jorge, Writing code for a microcontroller is very different from writing code for a personal computer; finding a microcontroller with a floating point unit is going to be a struggle, maybe your problem is better suited to a DSP? I'd have a look through one of the many tutorials on programming microcontrollers before going too far. You need to know quite a bit about the performance characteristics of your code, both space and time, before investing too much. Also power requirements and production volume should come into it; microcontrollers are efficient, but bigger batteries may be cheaper in the long run rather than investing a lot of time in developing something that you're only making a few of. Then again, if you're doing it for fun, it's a good challenge and will teach you a lot! Sam On 10 April 2012 11:12, Miguel Gallo, Jorge jmigu...@indra.es wrote: Hello, I have an algorithm running on my Linux personal computer using GSL library. I would like to implement the same algorithm in a microcontroller and I would like to ask your for tips about how to do that. Is there any microcontroller which can run any Linux OS in which I can include the GSL library? What can be the usage of program and data memory? Maybe it is necessary to use a microprocessor instead like ARM7? Many thanks, Jorge. Este correo electr?nico y, en su caso, cualquier fichero anexo al mismo, contiene informaci?n de car?cter confidencial exclusivamente dirigida a su destinatario o destinatarios. Si no es vd. el destinatario indicado, queda notificado que la lectura, utilizaci?n, divulgaci?n y/o copia sin autorizaci?n est? prohibida en virtud de la legislaci?n vigente. En el caso de haber recibido este correo electr?nico por error, se ruega notificar inmediatamente esta circunstancia mediante reenv?o a la direcci?n electr?nica del remitente. Evite imprimir este mensaje si no es estrictamente necesario. This email and any file attached to it (when applicable) contain(s) confidential information that is exclusively addressed to its recipient(s). If you are not the indicated recipient, you are informed that reading, using, disseminating and/or copying it without authorisation is forbidden in accordance with the legislation in effect. If you have received this email by mistake, please immediately notify the sender of the situation by resending it to their email address. Avoid printing this message if it is not absolutely necessary. Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene información de carácter confidencial exclusivamente dirigida a su destinatario o destinatarios. Si no es vd. el destinatario indicado, queda notificado que la lectura, utilización, divulgación y/o copia sin autorización está prohibida en virtud de la legislación vigente. En el caso de haber recibido este correo electrónico por error, se ruega notificar inmediatamente esta circunstancia mediante reenvío a la dirección electrónica del remitente. Evite imprimir este mensaje si no es estrictamente necesario. This email and any file attached to it (when applicable) contain(s) confidential information that is exclusively addressed to its recipient(s). If you are not the indicated recipient, you are informed that reading, using, disseminating and/or copying it without authorisation is forbidden in accordance with the legislation in effect. If you have received this email by mistake, please immediately notify the sender of the situation by resending it to their email address. Avoid printing this message if it is not absolutely necessary.
Re: [Help-gsl] GSL-1.15 installation issue on OSX 10.7.3
Hi, If you just want a copy of GSL installed and don't mind about it being too up to date, you could try MacPorts. Initial install from here: http://www.macports.org/ and then type sudo port install gsl-devel I can't help with building it from source, sorry! I'd be tempted to suggest that it's your C compiler's optimiser breaking something, but that's very wild speculation. Sam On 4 April 2012 21:24, Pierre-Henry Frohring frohring.pierrehe...@gmail.com wrote: Hello, I tried to install the GSLibrary following the INSTALL directives: $ ./configure $ make $ make check log 21 It gave me some errors on the svd module. The log file is 6mb, so i just cat the useful lines: Log - Making check in blas make[1]: Nothing to be done for `check'. Making check in linalg make test make[2]: `test' is up to date. make check-TESTS (caught [svd.c:149: SVD decomposition failed to converge (11)]) returned error code 11 = exceeded max number of iterations singular value 0 = -1 0 singular value 1 = 0 vs previous -1 singular value 2 = 17.3205080756888137 vs previous 0 ( 3, 3)[0,2]: 15.2508026013158453 0 ( 3, 3)[1,2]: 8.21054322293596961 1 ( 3, 3)[2,1]: 0 1 FAIL: SV_decomp (3x3) A=[ 0, 0, 0; 0, 0, 1; 1, 1, 0] [852] (caught [svd.c:149: SVD decomposition failed to converge (11)]) returned error code 11 = exceeded max number of iterations singular value 0 = -1 0 singular value 1 = 0 vs previous -1 singular value 2 = 17.3205080756888137 vs previous 0 ( 3, 3)[0,1]: 15.2508026013158453 0 ( 3, 3)[1,1]: 8.21054322293596961 1 ( 3, 3)[2,2]: 0 1 FAIL: SV_decomp (3x3) A=[ 0, 0, 0; 0, 1, 0; 1, 0, 1] [859] ( 3, 3)[0,1]: -0.499889 0 ( 3, 3)[1,2]: -1.00022 0 ( 3, 3)[2,1]: 0.499889 1 - Stuff Log - FAIL: SV_decomp_mod (4x4) A=[ 1, 1, 1, 1; 1, 1, 1, 1; 0, 1, 0, 1; 0, 0, 1, 1] [233613] FAIL: test == 1 of 1 test failed == make[2]: *** [check-TESTS] Error 1 make[1]: *** [check-am] Error 2 make: *** [check-recursive] Error 1 - I searched is the archive with: svd make check. The searched shrunk to 4 results, including this old post (2011 Aug) http://lists.gnu.org/archive/html/help-gsl/2011-08/msg00032.html But no answers… Anyone has an idea? Thanks for your time and help! PH
[Help-gsl] log probability density functions
Hi, I'm just wondering whether it's deliberate that there aren't any log probability density functions in the GSL? I've had a quick search through the archives and haven't seen anything obvious, but if you could point me in the right direction that would be great! As a bit of background, I'm using the GSL for doing Bayesian MCMC inference and the starting point of a chain tends to be somewhere with (very) low density. The lack of log density functions means that densities will be truncated to zero before I can take the log of them. For all of the distributions I've looked at in GSL it's been trivial to rearrange the maths so it's working with log densities and I'd be happy to tidy up my hacks into a patch if it would be useful to other people. Which, as far as I can tell, seems to be anyone doing much with likelihoods--the product of lots of very small numbers gets truncated to zero very quickly and working with the log of these is an easy way of getting sensible results! Of course, any other suggestions would be appreciated! Thanks in advance, Sam
Re: [Help-gsl] log probability density functions
On 29 March 2012 14:26, Rodney Sparapani rspar...@mcw.edu wrote: I'm just wondering whether it's deliberate that there aren't any log probability density functions in the GSL? That is a very good point. Many other packages like R allow you to return the log-density rather than the density. Yes, I use R lots as well--very useful for non-intensive bits of code. This would be a good addition to GSL. However, I see two problems. 1) as I understand it, GSL is feature complete at this point. 2) after many years of great stewardship, Brian Gough has stepped down as maintainer and no one has stepped up. Yes, I saw the recent messages from Brian. I'm surprised nobody has suggested taking over, there must be quite a few users of the library! So, you can either code your functions as a GSL extension or maybe you just use the R math library directly. I tried using the R library, but I couldn't follow enough it well enough to make use of it; the GSL API seems better designed. Does anybody else have write access to the website where patches/pointers could be accumulated till somebody gets the motivation to integrate some of them? Sam