How to sum multidimensional arrays?

bachmeier no at spam.net
Thu Feb 27 15:48:53 UTC 2020


On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote:

[...]

> This works but it does not look very efficient considering we 
> flatten and then calling array twice. It will get even worse 
> with 3D arrays. Is there a better way without relying on 
> mir.ndslice?

Is there a reason you can't create a struct around a double[] 
like this?

struct Matrix {
   double[] data;
}

Then to add Matrix A to Matrix B, you use A.data[] + B.data[]. 
But since I'm not sure what exactly you're doing, maybe that 
won't work.


More information about the Digitalmars-d-learn mailing list