Matrix class

Silverling este_aqui_ at hotmail.com.remove.underscores
Thu May 10 05:25:09 PDT 2007


Frits van Bommel Wrote:

> Bill Baxter wrote:
> > Frits van Bommel wrote:
> >> Bill Baxter wrote:
> >>> Silverling wrote:
> >>  >> Bill Baxter wrote:
> >>>>> Storage format?
> >>>> Currently Type[row][col].
> >>>
> >>> Got it.  You may be better off with Type[row*col].  Type[row][col] is 
> >>> an array of col pointers to 1D arrays of rows, rather than densely 
> >>> packed memory.
> >>
> >> No, it's definitely densely packed memory. Static arrays always put 
> >> their elements directly where you put the array itself, "inline".
> >>
> >> Only dynamic (Type[]) and associative (Type[Type2]) arrays use 
> >> "hidden" pointers.
> > 
> > Ok, but he said it was going to be resizeable.  Does that change your 
> > answer?
> 
> Hmm... Right. I don't see how he could do that for non-square matrices 
> without allocating a new matrix; if general resizing is implemented, he 
> must've used a different storage format (not Type[row*col] either, but 
> Type[] with length (row*col) would work). Maybe he was just inaccurate 
> with in his answer...


With resizeable arrays, I init a new array like this

Type[][] data=new Type[][](rows, cols);

Since array resizings only occur in multiplications and transposes of matrices of non-square matrices, I believe it to be doable.


More information about the Digitalmars-d-learn mailing list