use crate::rocsolver::ffi;
pub use crate::rocblas::types::{DataType, Diagonal, Fill, Operation, Side};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Svect {
All,
Singular,
Overwrite,
None,
}
impl From<Svect> for ffi::rocblas_svect {
fn from(svect: Svect) -> Self {
match svect {
Svect::All => ffi::rocblas_svect__rocblas_svect_all,
Svect::Singular => ffi::rocblas_svect__rocblas_svect_singular,
Svect::Overwrite => ffi::rocblas_svect__rocblas_svect_overwrite,
Svect::None => ffi::rocblas_svect__rocblas_svect_none,
}
}
}
impl From<ffi::rocblas_svect> for Svect {
fn from(svect: ffi::rocblas_svect) -> Self {
match svect {
ffi::rocblas_svect__rocblas_svect_all => Svect::All,
ffi::rocblas_svect__rocblas_svect_singular => Svect::Singular,
ffi::rocblas_svect__rocblas_svect_overwrite => Svect::Overwrite,
ffi::rocblas_svect__rocblas_svect_none => Svect::None,
_ => Svect::None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Evect {
Original,
Tridiagonal,
None,
}
impl From<Evect> for ffi::rocblas_evect {
fn from(evect: Evect) -> Self {
match evect {
Evect::Original => ffi::rocblas_evect__rocblas_evect_original,
Evect::Tridiagonal => ffi::rocblas_evect__rocblas_evect_tridiagonal,
Evect::None => ffi::rocblas_evect__rocblas_evect_none,
}
}
}
impl From<ffi::rocblas_evect> for Evect {
fn from(evect: ffi::rocblas_evect) -> Self {
match evect {
ffi::rocblas_evect__rocblas_evect_original => Evect::Original,
ffi::rocblas_evect__rocblas_evect_tridiagonal => Evect::Tridiagonal,
ffi::rocblas_evect__rocblas_evect_none => Evect::None,
_ => Evect::None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Erange {
All,
Value,
Index,
}
impl From<Erange> for ffi::rocblas_erange {
fn from(erange: Erange) -> Self {
match erange {
Erange::All => ffi::rocblas_erange__rocblas_erange_all,
Erange::Value => ffi::rocblas_erange__rocblas_erange_value,
Erange::Index => ffi::rocblas_erange__rocblas_erange_index,
}
}
}
impl From<ffi::rocblas_erange> for Erange {
fn from(erange: ffi::rocblas_erange) -> Self {
match erange {
ffi::rocblas_erange__rocblas_erange_all => Erange::All,
ffi::rocblas_erange__rocblas_erange_value => Erange::Value,
ffi::rocblas_erange__rocblas_erange_index => Erange::Index,
_ => Erange::All,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Storev {
ColumnWise,
RowWise,
}
impl From<Storev> for ffi::rocblas_storev {
fn from(storev: Storev) -> Self {
match storev {
Storev::ColumnWise => ffi::rocblas_storev__rocblas_column_wise,
Storev::RowWise => ffi::rocblas_storev__rocblas_row_wise,
}
}
}
impl From<ffi::rocblas_storev> for Storev {
fn from(storev: ffi::rocblas_storev) -> Self {
match storev {
ffi::rocblas_storev__rocblas_column_wise => Storev::ColumnWise,
ffi::rocblas_storev__rocblas_row_wise => Storev::RowWise,
_ => Storev::ColumnWise,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Direct {
Forward,
Backward,
}
impl From<Direct> for ffi::rocblas_direct {
fn from(direct: Direct) -> Self {
match direct {
Direct::Forward => ffi::rocblas_direct__rocblas_forward_direction,
Direct::Backward => ffi::rocblas_direct__rocblas_backward_direction,
}
}
}
impl From<ffi::rocblas_direct> for Direct {
fn from(direct: ffi::rocblas_direct) -> Self {
match direct {
ffi::rocblas_direct__rocblas_forward_direction => Direct::Forward,
ffi::rocblas_direct__rocblas_backward_direction => Direct::Backward,
_ => Direct::Forward,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Workmode {
OutOfPlace,
InPlace,
}
impl From<Workmode> for ffi::rocblas_workmode {
fn from(workmode: Workmode) -> Self {
match workmode {
Workmode::OutOfPlace => ffi::rocblas_workmode__rocblas_outofplace,
Workmode::InPlace => ffi::rocblas_workmode__rocblas_inplace,
}
}
}
impl From<ffi::rocblas_workmode> for Workmode {
fn from(workmode: ffi::rocblas_workmode) -> Self {
match workmode {
ffi::rocblas_workmode__rocblas_outofplace => Workmode::OutOfPlace,
ffi::rocblas_workmode__rocblas_inplace => Workmode::InPlace,
_ => Workmode::OutOfPlace,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Eform {
Ax,
Abx,
Bax,
}
impl From<Eform> for ffi::rocblas_eform {
fn from(eform: Eform) -> Self {
match eform {
Eform::Ax => ffi::rocblas_eform__rocblas_eform_ax,
Eform::Abx => ffi::rocblas_eform__rocblas_eform_abx,
Eform::Bax => ffi::rocblas_eform__rocblas_eform_bax,
}
}
}
impl From<ffi::rocblas_eform> for Eform {
fn from(eform: ffi::rocblas_eform) -> Self {
match eform {
ffi::rocblas_eform__rocblas_eform_ax => Eform::Ax,
ffi::rocblas_eform__rocblas_eform_abx => Eform::Abx,
ffi::rocblas_eform__rocblas_eform_bax => Eform::Bax,
_ => Eform::Ax,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Eorder {
Blocks,
Entire,
}
impl From<Eorder> for ffi::rocblas_eorder {
fn from(eorder: Eorder) -> Self {
match eorder {
Eorder::Blocks => ffi::rocblas_eorder__rocblas_eorder_blocks,
Eorder::Entire => ffi::rocblas_eorder__rocblas_eorder_entire,
}
}
}
impl From<ffi::rocblas_eorder> for Eorder {
fn from(eorder: ffi::rocblas_eorder) -> Self {
match eorder {
ffi::rocblas_eorder__rocblas_eorder_blocks => Eorder::Blocks,
ffi::rocblas_eorder__rocblas_eorder_entire => Eorder::Entire,
_ => Eorder::Entire,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Esort {
None,
Ascending,
}
impl From<Esort> for ffi::rocblas_esort {
fn from(esort: Esort) -> Self {
match esort {
Esort::None => ffi::rocblas_esort__rocblas_esort_none,
Esort::Ascending => ffi::rocblas_esort__rocblas_esort_ascending,
}
}
}
impl From<ffi::rocblas_esort> for Esort {
fn from(esort: ffi::rocblas_esort) -> Self {
match esort {
ffi::rocblas_esort__rocblas_esort_none => Esort::None,
ffi::rocblas_esort__rocblas_esort_ascending => Esort::Ascending,
_ => Esort::None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AlgMode {
Gpu,
Hybrid,
Mixed,
}
impl From<AlgMode> for ffi::rocsolver_alg_mode {
fn from(mode: AlgMode) -> Self {
match mode {
AlgMode::Gpu => ffi::rocsolver_alg_mode__rocsolver_alg_mode_gpu,
AlgMode::Hybrid => ffi::rocsolver_alg_mode__rocsolver_alg_mode_hybrid,
AlgMode::Mixed => ffi::rocsolver_alg_mode__rocsolver_alg_mode_mixed,
}
}
}
impl From<ffi::rocsolver_alg_mode> for AlgMode {
fn from(mode: ffi::rocsolver_alg_mode) -> Self {
match mode {
ffi::rocsolver_alg_mode__rocsolver_alg_mode_gpu => AlgMode::Gpu,
ffi::rocsolver_alg_mode__rocsolver_alg_mode_hybrid => AlgMode::Hybrid,
ffi::rocsolver_alg_mode__rocsolver_alg_mode_mixed => AlgMode::Mixed,
_ => AlgMode::Gpu,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Srange {
All,
Value,
Index,
}
impl From<Srange> for ffi::rocblas_srange {
fn from(srange: Srange) -> Self {
match srange {
Srange::All => ffi::rocblas_srange__rocblas_srange_all,
Srange::Value => ffi::rocblas_srange__rocblas_srange_value,
Srange::Index => ffi::rocblas_srange__rocblas_srange_index,
}
}
}
impl From<ffi::rocblas_srange> for Srange {
fn from(srange: ffi::rocblas_srange) -> Self {
match srange {
ffi::rocblas_srange__rocblas_srange_all => Srange::All,
ffi::rocblas_srange__rocblas_srange_value => Srange::Value,
ffi::rocblas_srange__rocblas_srange_index => Srange::Index,
_ => Srange::All,
}
}
}
pub type Complex32 = crate::rocsolver::bindings::rocblas_float_complex;
pub type Complex64 = crate::rocsolver::bindings::rocblas_double_complex;
impl Complex32 {
#[inline]
pub fn new(re: f32, im: f32) -> Self {
Self { x: re, y: im }
}
#[inline]
pub fn re(&self) -> f32 {
self.x
}
#[inline]
pub fn im(&self) -> f32 {
self.y
}
}
impl Complex64 {
#[inline]
pub fn new(re: f64, im: f64) -> Self {
Self { x: re, y: im }
}
#[inline]
pub fn re(&self) -> f64 {
self.x
}
#[inline]
pub fn im(&self) -> f64 {
self.y
}
}