blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
404 stars 83 forks source link

patch: slicing, lhs/rhs f-ctions, null ranges, EXPOSE_MEMBER, list initialisers #88

Open slayoo opened 5 years ago

slayoo commented 5 years ago

Migrated from SF (patch by @mdsuresh): https://sourceforge.net/p/blitz/patches/4/

patch.gz

Original comment:

... i have changed blitz itself in some important ways.

As usual, i have implemented newer algorithms, now under the alg subdirectory. The code is nicely formatted and gringed with asserts and prechecks so that error tracing is easier now.

The most prevalent change is slicing.

That is suppose: u have Array<int, 3> A(4,4,3); A( 4, Range(2, 3) ) is same as A( 4, Range(2,3) , Range::all()) . I have also added new _x classes for slicing.

Secondly, i have add lhs and rhs functions and their relavent classes to the blitz library so that we can return multiple parameters.

ie. result = rhs( int(2) , Array<int,2>(2,2) , float(3) ) returns 3 parameters.

int a; Array<int,2> b(2,2); float c; and lhs( a, b , c) = result; This will automaically set a, b, c to their appropriate values. Moreover, it is also possible to do. lhs( a, ref(b), c) = result. Now, b references the array inside the 2 result.

I have also added support for Null Ranges.

ie. Array<int, 1> A; A( Range(1,-1,1) ) = is an empty slice.

Then, of course, now, there is a nice way for multicomponent object to expose themselves.

struct Sample { int a, b, c; };

EXPOSE_MEMBER_3( Sample, int, a,b,c )

Array<Sample, 1> A; A->a() is now possible.

Moreover, i will also be changing List initializers with comma operators so that they allow arrays to be inserted.

That is:

Array<int, 1> a(2), b(1); Array<int, 2> c(2,2); a = 2; b = 1; c = a , b , 0;

so that c is 2 2 1 0

I have also added a readme.txt file to the alg directory. It loosely says what it is about.