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
//! Define Errors

use ndarray::{Ixs, ShapeError};
use thiserror::Error;

pub type Result<T> = ::std::result::Result<T, LinalgError>;

/// Master Error type of this crate
#[derive(Debug, Error)]
pub enum LinalgError {
    /// Matrix is not square
    #[error("Not square: rows({}) != cols({})", rows, cols)]
    NotSquare { rows: i32, cols: i32 },

    /// LAPACK subroutine returns non-zero code
    #[error(transparent)]
    Lapack(#[from] lax::error::Error),

    /// Strides of the array is not supported
    #[error("invalid stride: s0={}, s1={}", s0, s1)]
    InvalidStride { s0: Ixs, s1: Ixs },

    /// Memory is not aligned continously
    #[error("Memroy is not continously")]
    MemoryNotCont,

    /// Obj cannot be made from a (rows, cols) matrix
    #[error("{} cannot be made from a ({}, {}) matrix", obj, rows, cols)]
    NotStandardShape {
        obj: &'static str,
        rows: i32,
        cols: i32,
    },

    /// Strides of the array is not supported
    #[error(transparent)]
    Shape(#[from] ShapeError),
}