1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com)
//

/*!
The Wigner 3-j, 6-j and 9-j symbols give the coupling coefficients for combined angular momentum vectors.
Since the arguments of the standard coupling coefficient functions are integer or half-integer, the arguments of the following functions
are, by convention, integers equal to twice the actual spin value.
!*/

use std::mem::zeroed;
use enums;

/// This routine computes the Wigner 3-j coefficient,
/// 
/// (ja jb jc
///  ma mb mc)
/// 
/// where the arguments are given in half-integer units, ja = two_ja/2, ma = two_ma/2, etc.
pub fn _3j(two_ja: i32, two_jb: i32, two_jc: i32, two_ma: i32, two_mb: i32, two_mc: i32) -> f64 {
    unsafe { ::ffi::gsl_sf_coupling_3j(two_ja, two_jb, two_jc, two_ma, two_mb, two_mc) }
}

/// This routine computes the Wigner 3-j coefficient,
/// 
/// (ja jb jc
///  ma mb mc)
/// 
/// where the arguments are given in half-integer units, ja = two_ja/2, ma = two_ma/2, etc.
pub fn _3j_e(two_ja: i32, two_jb: i32, two_jc: i32, two_ma: i32, two_mb: i32, two_mc: i32) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<::ffi::gsl_sf_result>() };
    let ret = unsafe { ::ffi::gsl_sf_coupling_3j_e(two_ja, two_jb, two_jc, two_ma, two_mb, two_mc, &mut result) };

    (ret, ::types::Result{val: result.val, err: result.err})
}

/// This routine computes the Wigner 6-j coefficient,
/// 
/// {ja jb jc
/// jd je jf}
/// 
/// where the arguments are given in half-integer units, ja = two_ja/2, ma = two_ma/2, etc.
pub fn _6j(two_ja: i32, two_jb: i32, two_jc: i32, two_jd: i32, two_je: i32, two_jf: i32) -> f64 {
    unsafe { ::ffi::gsl_sf_coupling_6j(two_ja, two_jb, two_jc, two_jd, two_je, two_jf) }
}

/// This routine computes the Wigner 6-j coefficient,
/// 
/// {ja jb jc
/// jd je jf}
/// 
/// where the arguments are given in half-integer units, ja = two_ja/2, ma = two_ma/2, etc.
pub fn _6j_e(two_ja: i32, two_jb: i32, two_jc: i32, two_jd: i32, two_je: i32, two_jf: i32) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<::ffi::gsl_sf_result>() };
    let ret = unsafe { ::ffi::gsl_sf_coupling_6j_e(two_ja, two_jb, two_jc, two_jd, two_je, two_jf, &mut result) };

    (ret, ::types::Result{val: result.val, err: result.err})
}

/// This routine computes the Wigner 9-j coefficient,
/// 
/// {ja jb jc
/// jd je jf
/// jg jh ji}
/// where the arguments are given in half-integer units, ja = two_ja/2, ma = two_ma/2, etc.
pub fn _9j(two_ja: i32, two_jb: i32, two_jc: i32, two_jd: i32, two_je: i32, two_jf: i32, two_jg: i32,
    two_jh: i32, two_ji: i32) -> f64 {
    unsafe { ::ffi::gsl_sf_coupling_9j(two_ja, two_jb, two_jc, two_jd, two_je, two_jf, two_jg, two_jh, two_ji) }
}

/// This routine computes the Wigner 9-j coefficient,
/// 
/// {ja jb jc
/// jd je jf
/// jg jh ji}
/// where the arguments are given in half-integer units, ja = two_ja/2, ma = two_ma/2, etc.
pub fn _9j_e(two_ja: i32, two_jb: i32, two_jc: i32, two_jd: i32, two_je: i32, two_jf: i32, two_jg: i32,
    two_jh: i32, two_ji: i32) -> (enums::Value, ::types::Result) {
    let mut result = unsafe { zeroed::<::ffi::gsl_sf_result>() };
    let ret = unsafe { ::ffi::gsl_sf_coupling_9j_e(two_ja, two_jb, two_jc, two_jd, two_je, two_jf, two_jg, two_jh, two_ji,
        &mut result) };

    (ret, ::types::Result{val: result.val, err: result.err})
}