<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Message: 29<br>
Date: Sat, 6 Nov 2010 13:22:10 +0100<br>
From: Roel van Dijk &lt;<a href="mailto:vandijk.roel@gmail.com">vandijk.roel@gmail.com</a>&gt;<br>
Subject: [Haskell-cafe] hmatrix&#39;s fitModel function crashes ghc(i)<br>
To: Haskell Caf? &lt;<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>&gt;<br>
Message-ID:<br>
        &lt;AANLkTim5eGSL_BZ+RUv-=d-Z3DB65Sc8o=<a href="mailto:cKQLTcyKT4@mail.gmail.com">cKQLTcyKT4@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
Hello,<br>
<br>
I would like to use hmatrix to do some function fitting with the<br>
Levenberg Marquardt algorithm. As an example I would like to fit the<br>
very simple function &quot;f x = a*x + b&quot; on some data points. The problem<br>
is that executing the &#39;fitModel&#39; function crashes GHC(i) with a<br>
segmentation fault. This makes debugging difficult. Can anyone spot<br>
what I am doing wrong? Given all the lists of Double&#39;s it seems very<br>
easy to make an error regarding the number of arguments with the model<br>
function or the derivative.<br>
<br>
Try to evaluate the &#39;test&#39; function in the small program listed below.<br>
I would expect an output of [1, 0] (y = 1*x + 0) instead of a<br>
segmentation fault.<br>
<br>
Relevant versions:<br>
 - hmatrix-0.10.0.0<br>
 - gsl-1.14<br>
 - ghc-6.12.3 (64 bit)<br>
<br></blockquote><div><br>Is that the 64 bit Linux ghc?<br><br>I think the problem is with the GSL random number generation through GHCi.<br><br>Try:<br><br>&gt; module Test where<br>&gt; <br>&gt; Import Numeric.Container(RandDist,randomVector)<br>
&gt;<br>&gt; seed = 0<br>&gt; size = 100<br>&gt; <br>&gt; main = putStrLn $ show $ randomVector seed Gaussian size<br> <br>This should work when compiled with `ghc --make` and crash when invoked in `ghci`.<br><br>I think the problem is with linking static data in GHCi on x86_64.<br>
<br>Hope this helps.  I seem to recall there might be a ghc trac ticket related to this but a quick search turned up nothing.<br><br>Cheers,<br><br>Vivian<br></div></div><br>