Skip to content

Commit

Permalink
Merge pull request #585 from sebasv/blas-gemv-error
Browse files Browse the repository at this point in the history
Fix blas mat-vec multiplication on array with only 1 nontrivial dimension
  • Loading branch information
bluss authored Sep 4, 2019
2 parents 35065cb + a5fe624 commit 5e32de2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions blas-tests/tests/oper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ fn dot_product() {
assert_eq!(a.dot(&b), dot as i32);
}

#[test]
fn mat_vec_product_1d() {
let a = arr2(&[[1.], [2.]]);
let b = arr1(&[1., 2.]);
let ans = arr1(&[5.]);
assert_eq!(a.t().dot(&b), ans);
}

// test that we can dot product with a broadcast array
#[test]
fn dot_product_0() {
Expand Down
8 changes: 6 additions & 2 deletions src/linalg/impl_linalg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,12 @@ pub fn general_mat_vec_mul<A, S1, S2, S3>(
if blas_compat_1d::<$ty, _>(&x) && blas_compat_1d::<$ty, _>(&y) {
let a_trans = CblasNoTrans;
let a_stride = match layout {
CBLAS_LAYOUT::CblasRowMajor => a.strides()[0] as blas_index,
CBLAS_LAYOUT::CblasColMajor => a.strides()[1] as blas_index,
CBLAS_LAYOUT::CblasRowMajor => {
a.strides()[0].max(k as isize) as blas_index
}
CBLAS_LAYOUT::CblasColMajor => {
a.strides()[1].max(m as isize) as blas_index
}
};

let x_stride = x.strides()[0] as blas_index;
Expand Down

0 comments on commit 5e32de2

Please sign in to comment.