#array #ndarray #convert #matlab #matfile

matfile-ndarray

Utility library to convert between matfile and ndarray array formats

2 unstable releases

0.2.0 Feb 28, 2020
0.1.0 Apr 5, 2019

#12 in #matlab

MIT license

74KB
1.5K SLoC

matfile-ndarray

Helpers for converting between matfile::Array and ndarray::Array.

While matfile arrays abstract over the underlying data type, ndarray arrays are parameterized by a concrete data type. Thus the conversions provided are fallible in case the data types are not compatible.

Examples

First, bring the TryInto trait into scope:

use matfile_ndarray::TryInto;

Dynamically dimensioned arrays

Converting a matfile array mf_arr to a dynamic dimension ndarray array nd_arr:

let nd_arr: ndarray::ArrayD<f64> = mf_arr.try_into()?;

Statically dimensioned arrays

Converting a matfile array mf_arr to a static dimension ndarray array nd_arr:

let nd_arr: ndarray::Array2<num_complex::Complex<f32>> = mf_arr.try_into()?;

lib.rs:

Helpers for converting between matfile::Array and ndarray::Array.

While matfile arrays abstract over the underlying data type, ndarray arrays are parameterized by a concrete data type. Thus the conversions provided are fallible in case the data types are not compatible.

Examples

First, bring the TryInto trait into scope:

use matfile_ndarray::TryInto;

Dynamically dimensioned arrays

Converting a matfile array mf_arr to a dynamic dimension ndarray array nd_arr:

let nd_arr: ndarray::ArrayD<f64> = mf_arr.try_into()?;

Statically dimensioned arrays

Converting a matfile array mf_arr to a static dimension ndarray array nd_arr:

let nd_arr: ndarray::Array2<num_complex::Complex<f32>> = mf_arr.try_into()?;

Dependencies

~4.5MB
~91K SLoC