Multidimensional slice
Rafael
rfkadyrov at gmail.com
Wed Dec 19 01:58:36 PST 2012
Hi, all!
In advance, excuse me for my terrible english.
I try to learn the D language. One of the areas of my work is
numerical calculations, and there are lot of linear algebra
objects and operations. For beginning I started with
implementation of matrix calculations. Note, that I am doing this
is only in order to learn a language.
So, I try to implement operations with density and sparse
matrixes with uniform interface. And was confused with slice
operations. For example:
uint rows = 100, cols = 100;
auto A = new MatrixDensity!double(rows, cols);
auto S = new MatrixSparse!double(rows, cols);
auto x = new VectorColumn!double(rows);
auto y = new VectorRow!double(cols);
//and now it possible to implement:
auto a_ij = A[i, j]; //opIndex(uint row, uint col)
S[i, j] = a_ij; //opIndexAssign(T value, uint row, uint col)
y = S[i]; //opIndex(uint row)
A[i] = y; //opIndexAssign(VectorRow!T value, uint row)
//Then I want to do something like
x = S[0..$, 1]; //get column
S[0..$, 2] = A[0..$, 2]; //get and set column
auto B = A[0..10, 0..10]; //get submatrix block of matrix A
I.e. I want to implement multimentional slices to realize simple,
generalized and "human readable" syntax for matrix and vectors
operations (like a Matlab syntax for example). Or may be I use
not right way for realization?
More information about the Digitalmars-d-learn
mailing list