ndarray_linalg/
error.rs

1//! Define Errors
2
3use ndarray::{Ixs, ShapeError};
4use thiserror::Error;
5
6pub type Result<T> = ::std::result::Result<T, LinalgError>;
7
8/// Master Error type of this crate
9#[derive(Debug, Error)]
10pub enum LinalgError {
11    /// Matrix is not square
12    #[error("Not square: rows({}) != cols({})", rows, cols)]
13    NotSquare { rows: i32, cols: i32 },
14
15    /// LAPACK subroutine returns non-zero code
16    #[error(transparent)]
17    Lapack(#[from] lax::error::Error),
18
19    /// Strides of the array is not supported
20    #[error("invalid stride: s0={}, s1={}", s0, s1)]
21    InvalidStride { s0: Ixs, s1: Ixs },
22
23    /// Memory is not aligned continously
24    #[error("Memroy is not continously")]
25    MemoryNotCont,
26
27    /// Obj cannot be made from a (rows, cols) matrix
28    #[error("{} cannot be made from a ({}, {}) matrix", obj, rows, cols)]
29    NotStandardShape {
30        obj: &'static str,
31        rows: i32,
32        cols: i32,
33    },
34
35    /// Strides of the array is not supported
36    #[error(transparent)]
37    Shape(#[from] ShapeError),
38}