cumath 0.2.1

Cuda-based matrix/vector computations
docs.rs failed to build cumath-0.2.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

cumath

Cuda-based matrix/vector computations

Install nvcc before using this library CuVector and CuMatrix are allocated on device during their lifetime.

Example :

extern crate cumath;
use cumath::*;

fn assert_equals_float(a: f32, b: f32) {
    let d = a-b;
    if d < -0.000001 || d > 0.000001 {
        panic!("{} != {}", a, b);
    }
}

fn main() {
    let value0 = -0.23254;
    let value1 = 1.185254;
    let mut vector0 = CuVector::new(5, 0.0); //(len, initial_value)
    let mut vector1 = CuVector::new(2, 0.0);

    vector0.init(value0);
    vector1.init(value1);
    vector0.slice_mut(2 /*offset*/, 2 /*length*/).add_self(&vector1);

    let mut output = vec![0.0; 5];
    vector0.clone_to_host(&mut output);

    assert_equals_float(output[0], value0);
    assert_equals_float(output[1], value0);
    assert_equals_float(output[2], value0+value1);
    assert_equals_float(output[3], value0+value1);
    assert_equals_float(output[4], value0);
}