<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Nov 1, 2015 at 10:59 PM, Alasdair McAndrew <span dir="ltr"><<a href="mailto:amca01@gmail.com" target="_blank">amca01@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div>Brilliant! - thank you so much - that works just as it should. Why cannot the input to integration-qagp be simply a list or a vector? As in<br><br>(gsll:integration-QAGp 'integration-test-f454 '(0.0d0 1.0d0 (sqrt 2.0d0) 3.0d0) 0.0d0 1.0d-3 1000)<br><br></div>or<br><br>(gsll:integration-QAGp 'integration-test-f454 (vector 0.0d0 1.0d0 (sqrt 2.0d0) 3.0d0) 0.0d0 1.0d-3 1000)<br><br></div>I'm not sure (told you I was a newbie!) what grid provides that a list or vector can't.<br></div></div></div></div></div></div></div></blockquote><div> </div><div>Grids can be thought of as generalized arrays. Since GSL is a foreign (C) library, its arrays are incompatible with CL arrays. The grid part of Antik provides a way to bridge that gap, so you can handle them with similarly-named functions. However, they are different, and foreign calls need foreign arrays.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><br></div>And here's a tiny problem from my tiny brain: suppose the endpoints and singularities are given as a standard Lisp list, S say. Then (I'm using SBCL):<br><br></div>(defvar S2)<br>(setf S2 (grid:make-foreign-array 'double-float :dimensions (length S) :initial-contents S))<br><br></div>turns the list into a foreign array grid (is there an easier way?). </div></div></div></div></blockquote><div>There are multiple ways to convert lists to foreign-arrays. This should work.<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>But then, my attempts to use S2 as input to gaqp produces errors:<br><br>(gsll:integration-QAGp 'my-fun 'S2 0.0d0 1.0d-3 1000)<br></div></div></div></div></blockquote><div><br></div><div>While you didn't provide the error, this will not work as you have quoted S2, so you are sending the symbol 'S2 where you need to send the foreign array as the argument. This has nothing to do with arrays and foreign-arrays, it is just a basic syntax error.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><br></div>Basically I need a way of turning a numeric list into input for integration-QAGp. I'll keep fiddling!<br></div></div></div></blockquote><div><br></div><div>You have it, you just have a syntax error.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><br></div>Many thanks again,<br></div>Alasdair<br></div></blockquote><div><br></div><div>No problem,<br></div><div>Liam <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 1:34 PM, Liam Healy <span dir="ltr"><<a href="mailto:lhealy@common-lisp.net" target="_blank">lhealy@common-lisp.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Sun, Nov 1, 2015 at 5:10 AM, Alasdair McAndrew <span dir="ltr"><<a href="mailto:amca01@gmail.com" target="_blank">amca01@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div>Hello,<br><br></div>I am using the excellent gsll package (in the first instance), to provide an interface to quadpack for the mathematics system FriCAS. I'm slowly going through calculus/numerical-integration.lisp one function at a time and writing each one into FriCAS as I go. This means writing functions in FriCAS's own language SPAD which interface with gsll.<br><br></div>This is made harder by me being a lisp newbie.<br><br></div>However, I've come to integration-QAGP, and I've tried to run the test command (having first defined the function it calls). However, all I get is errors.<br><br></div>I'm using SBCL in emacs-slime, and I have installed gsll with quicklisp, so that I can call an integration routine with<br><br>* (gsll:integration-qng (lambda (x) (exp (- (* x x)))) 0.0 1.0)<br clear="all"><div><div><div><br></div><div>But the commands<br><br>* (defun integration-test-f454 (x)<br> (* (expt x 3) (* (log (abs (* (- (expt x 2) 1.0d0) (- (expt x 2) 2.0d0)))))))<br><br>* (gsll:integration-QAGp<br> 'integration-test-f454<br> (grid:copy-to (vector 0.0d0 1.0d0 (sqrt 2.0d0) 3.0d0))<br> 0.0d0 1.0d-3 1000)<br><br></div><div>just produces a long list of errors. Is "grid" a standard library, or does it need to be loaded first? (Told you I was a newbie...)<br><br></div><div>Thanks<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>Alasdair<br></div><div><div><div>--<br></div></div></div></font></span></div></div></div></blockquote><div><br></div></span><div>Try this<br><br>(setf grid:*default-grid-type* 'grid:foreign-array)<br>(gsll:integration-QAGp 'integration-test-f454 (grid:grid 0.0d0 1.0d0 (sqrt 2.0d0) 3.0d0) 0.0d0 1.0d-3 1000)<br><br></div><div>and let us know what happens.<br><br></div><div>Thanks,<br></div><div>Liam<br></div></div></div></div>
</blockquote></div><br><br clear="all"><br></div></div><span class="">-- <br><div><div dir="ltr"><a href="http://www.facebook.com/alasdair.mcandrew" target="_blank"><img alt="http://www.facebook.com/alasdair.mcandrew"></a> <a href="https://plus.google.com/+AlasdairMcAndrew/posts" target="_blank"><img alt="https://plus.google.com/+AlasdairMcAndrew/posts"></a> <a href="https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108" target="_blank"><img alt="https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108"></a> <a href="https://twitter.com/amca01" target="_blank"><img alt="https://twitter.com/amca01"></a> <a href="http://numbersandshapes.net" target="_blank"><img alt="http://numbersandshapes.net"></a><br></div></div>
</span></div>
</blockquote></div><br></div></div>