Skip to content

Commit 58c489e

Browse files
author
Jason Ramapuram
committed
specialize bool
1 parent 3a4f23a commit 58c489e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/data/mod.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,26 @@ impl ConstGenerator for Complex<f64> {
114114
}
115115
}
116116

117+
#[allow(unused_mut)]
118+
impl ConstGenerator for bool {
119+
fn generate(&self, dims: Dim4) -> Array {
120+
unsafe {
121+
let mut temp: i64 = 0;
122+
af_constant(&mut temp as MutAfArray, *self as c_int as c_double,
123+
dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT, 4);
124+
Array::from(temp)
125+
}
126+
}
127+
}
128+
117129
macro_rules! cnst {
118130
($rust_type:ty, $ffi_type:expr) => (
119131
#[allow(unused_mut)]
120132
impl ConstGenerator for $rust_type {
121133
fn generate(&self, dims: Dim4) -> Array {
122134
unsafe {
123135
let mut temp: i64 = 0;
124-
af_constant(&mut temp as MutAfArray, *self as u64 as c_double,
136+
af_constant(&mut temp as MutAfArray, *self as c_double,
125137
dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT,
126138
$ffi_type);
127139
Array::from(temp)
@@ -133,7 +145,6 @@ macro_rules! cnst {
133145

134146
cnst!(f32 , 0);
135147
cnst!(f64 , 2);
136-
cnst!(bool, 4);
137148
cnst!(i32 , 5);
138149
cnst!(u32 , 6);
139150
cnst!(u8 , 7);

0 commit comments

Comments
 (0)