Questions tagged [rust-ndarray]

54 questions
0
votes
1 answer

rust crate dependencies: norman::Norm trait is not defined for ndarray::Array1

I am trying to get a P-norm for my simple 1D Vec in Rust, but I am failing with every norman example. Error states that there is no method named `norm` found for struct `ArrayBase` in the current scope. What I did: cargo new norman-test cd…
0
votes
1 answer

Rust ndarray: iterate over array in column order

I have a 2D array with shape (2, N), from the ndarray crate, of i16 audio samples (a stereo (2-channel) audio clip). The standard way that these values are written to a file is in column-major order, so every even entry belongs to channel 1 / row 0…
0
votes
0 answers

How can I get ndarray::stack to build a matrix from an iterator of column vectors?

I have a problem where I want to build a matrix of boolean values. I first found a way to get bit vectors from integers, but I want to combine these vectors into a matrix, using (I guess) the stack function. The problem is, the docs for the stack…
whatf0xx
  • 108
  • 7
0
votes
1 answer

Parallel computation of values for `ndarray` `Array2` in Rust

I am trying to speed up my calculations and I am not sure, how to best use .into_par_iter() or some of the Zip:: options from the ndarray crate in order to "correctly" parallelize the computation to speed up things. I have tried 2 ways, but I think…
0
votes
1 answer

How to implement graph data structure consisting of ndarray arrays?

I wanted to implement some computational graph data structure in Rust (that can hopefully support autodiff), and I decided to use the ndarray crate, since that is most similar to NumPy. Making a graph data structure isn't really all that difficult,…
nekechs
  • 1
  • 1
0
votes
1 answer

iter map(v…) in rust - efficient recalculation of ndarray elements into two arrays at once?

I’d like to iter over array elements and modify them. Additionally I would like (for efficiency purposes) compute at once two new results. The pseudocode in rust is below: use ndarray::*; //definition of Array1 // let's assume examplary…
mathmax
  • 5
  • 2
0
votes
1 answer

Macro to slice ndarray

I have a struct with one Array and other properties associated to it. I want to be able to slice the array in order to write values at specific indices. However, I don't want the user to have to know the field name where the array is stored, so just…
javirk
  • 23
  • 5
0
votes
1 answer

How to use rayon to update a personal struct containing an Array in Rust

CONTEXT General overview (Here is the github page with the minimal example of my problem, and the page of my whole project) I'm very new to rust and I'm trying to simulate the behavior of a fluid in Rust. This is easy: computing large arrays with…
payasson
  • 3
  • 3
0
votes
0 answers

Rust Equivalent to Python scipy.interp1d?

I'm porting some scientific python code to Rust as a learning exercise. In the Python version, I make use of scipy.interp1d, which I'm using to do things like the following: Given sorted array x and array y, calculate array new_y using new_x. (with…
John Brodie
  • 971
  • 1
  • 6
  • 5
0
votes
1 answer

ndarray rust, change values of a slice

In python's numpy given an array a = np.zeros((10,10,2)) I could modify values of the array corresponding to a slice 4:6,: as such: a[4:6,:] = [0,255] In rust: given a ndarray from the ndarray package, i can slice let mut img =…
Conformal
  • 239
  • 2
  • 11
0
votes
1 answer

into_shape after remove_index fails

I have an &[f64] with 309.760 elements. This dataset is an array of 7040 property sets. Each property set contains a pair of f64s and 14 triplets of f64. I am only interested in the triplets. I can read this dataset into an ndarray like this: let…
Obenland
  • 856
  • 16
  • 28
0
votes
0 answers

ndarray::Array is not able to handle an arbitrary dimension

I have a struct with an array struct Model { b: f64, j: f64, arr: Array, } And I noticed that I cannot access the value in arr via [usize; D], e.g. impl for Model { fn sum(&self) -> f64…
xis
  • 24,330
  • 9
  • 43
  • 59
0
votes
0 answers

Strange bug using Rust and ndarray

I have a very strange bug in my Rust code using ndarray. The following code runs with no error: // ...other code before producing a lot of print on screen // let rank = 2; let mut Q = Array2::::zeros((rank,rank)); // U is an Array2 where F…
0
votes
0 answers

Convert an Array to Array3 in rust ndarray

Using the ndarray crate in rust. I got a vector of array2 (which i know is not the best performance setup). I want to create a a Array3 from the this, but when I use from vector, or use the iter map, I only get Array1. What would be the methode to…
will.mendil
  • 752
  • 2
  • 6
  • 21
0
votes
1 answer

Rust returnig iterator with trait bound on its items

I am trying to write a common interface for different types of matrices that provides a way to mutably iterate their rows and modify them. I have the following matrix types: struct NdArrayMatrix { matrix: Array2, } struct ByteMatrix<'a> { …
stomfaig
  • 15
  • 4