Re: Nim Wrapper for ArrayFire

2016-12-30 Thread perturbation2
I'm really excited to see this! I'm using Nim for data science and I would love 
more wrappers and libraries :)

There's also:

[https://github.com/stavenko/nim-glm](https://github.com/stavenko/nim-glm)

[https://github.com/unicredit/linear-algebra](https://github.com/unicredit/linear-algebra)

if looking for other libraries with similar aims. I've used andreaferreti's 
linear-algebra library for a project, and it's been great. The one thing I 
really would like is higher-dimensional matrices (which it looks like this 
provides). Awesome!


Re: Nim Wrapper for ArrayFire

2016-12-30 Thread bitstorm
Hi - I think the reason for Julia being so fast in the matmul benchmark is that 
it uses many high performance c/c++ libraries in the background, I am not sure 
what they use for matrices but the julia result is probably just what you would 
get with c/c++ and blas or atlas.

My guess is that with the CPU backend the results for ArrayFire would be very 
similar - I did not do any optimization yet but I would assume that the Nim 
wrapper does not slow down things too much - the results would be quite similar 
to the Julia results.

For me Julia is a good example how clever integration of existing libraries can 
make a language interesting for scientific applications. After ArrayFire I am 
planning to make Nim wrapper for some more libraries - c2nim is a very fine 
tool although the documentation for it and Nim in general has the density of a 
neutron star ;)

Best Regards


Re: Nim Wrapper for ArrayFire

2016-12-30 Thread Libman
Excellent! :D

I wonder how this would affect Nim's standing in the 
[kostya/benchmarks](https://github.com/kostya/benchmarks) (which were [just 
recently mentioned](http://forum.nim-lang.org///forum.nim-lang.org/t/2687) 
here), namely [matrix 
multiplication](https://github.com/kostya/benchmarks/tree/master/matmul)...


Nim Wrapper for ArrayFire

2016-12-29 Thread bitstorm
Hello,

I have just published a Nim wrapper for ArrayFire on github: 
[https://github.com/bitstormGER/ArrayFire-Nim](https://github.com/bitstormGER/ArrayFire-Nim)

This is my first Nim project but the wrapper seems quite usable to me.

I hope this helps (ones it is working properly) to make Nim even more 
attractive for scientific computing - my main area of interest. I am currently 
mostly using Python but would love to see more work being done with Nim.

The wrapper is based on the unified backend of ArrayFire so you can change 
backends at runtime. Supported backends are CPU, OpenCL and CUDA - this means 
you have access to GPU accelerated operations and even parallel for loops (see 
gfor in the documentation on github)

To give an idea how code with the wrapper looks - here are some code examples:

Some linear algebra computations - ArrayFire is extremely fast and feature rich


var ain = matrix(2,3,@[1'f32, 4'f32, 2'f32, 5'f32, 3'f32, 6'f32])
var (u,s_vec,vt) = ain.svd()

var s_mat = diag(s_vec ,0, false)
var in_recon = matmul(u,s_mat, vt[mseq(2), span])



Computer Vision (translated from a c++ example)


setDevice(0)
info()
var img_color = loadImage("assets/man.jpg",true)
let img = colorSpace(img_color, CSpace.GRAY, CSpace.RGB)

img_color /= 255

let feat = fast(img,20.0, 9, true, 0.05)

let hx = feat.getX().to_seq(float)
let hy = feat.getY().to_seq(float)

let draw_len = 3

for f in 0..