No description
Find a file
2024-12-27 21:37:22 -05:00
include/gsl initial commit 2021-02-25 22:41:01 -05:00
lib initial commit 2021-02-25 22:37:30 -05:00
sample Delete sample/sample_gsl_poly 2024-12-27 21:37:22 -05:00
src fixes indentation 2024-10-20 12:11:21 -04:00
test add some tests 2021-02-27 12:02:35 -05:00
gsl.nimble Update gsl.nimble 2024-12-27 21:36:33 -05:00
LICENSE Initial commit 2021-02-25 22:22:37 -05:00
README.md Update README.md 2021-03-04 21:02:15 -05:00

gsl-nim GNU Scientific Library for nim

Install

    1. install GNU GSL library
    • Ubuntu

      sudo apt-get install libgsl-dev

    • MacOs

      brew install gsl

    • Windows

      Why do you want to do this on windows? Use WSL maybe.

    • Build from source

      download source code from https://www.gnu.org/software/gsl/

      ./configure --prefix=???
      make
      make check
      make install
      
    1. install gsl-nim package
    git clone https://github.com/YesDrX/gsl-nim
    cd gsl-nim
    nimble install
    
    or
    nimble install gsl
    

Sample code & Test code

samples

tests

  • example : solve for root of a 5th order polynomial equation
import gsl/gsl_poly
import strformat

var
  i : cint
  a = @[-1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
  z = newSeq[cdouble](10)

  w = gsl_poly_complex_workspace_alloc(6)

discard gsl_poly_complex_solve(a[0].addr, 6, w, z[0].addr)
gsl_poly_complex_workspace_free(w)

echo fmt"Roots for x^5 - 1 = 0"
for i in 0 .. 4:
  echo fmt"z{i} = {z[2*i]} + {z[2*i+1]} i"
  • output
Roots for x^5 - 1 = 0
z0 = -0.8090169943749477 + 0.5877852522924734 i
z1 = -0.8090169943749477 + -0.5877852522924734 i
z2 = 0.3090169943749475 + 0.951056516295153 i
z3 = 0.3090169943749475 + -0.951056516295153 i
z4 = 0.9999999999999999 + 0.0 i