#include #include "blitz/array.h" #include "bul/Extract.h" int main() { using std::cout; using std::endl; using namespace blitz; // Extract using integer index Array x(6); Array y(6,4); firstIndex i; secondIndex j; // x = cast(i*i, float()); // obsolete syntax // y = cast((i+1)*(j+1), float()); // obsolete syntax x = cast(i*i); y = cast((i+1)*(j+1)); Array xIndex(3); xIndex(0) = 1; xIndex(1) = 2; xIndex(2) = 4; cout << "X = " << x << endl; cout << "Y = " << y << endl; cout << "Integer index = " << xIndex << endl; cout << "Indexed elements of X = " << bul::extract(xIndex, x) << endl; Array ycolumn(y(Range::all(),1)); cout << "Indexed elements of 2nd column of Y = " << bul::extract(xIndex, ycolumn) << endl; cout << "Indexed rows of Y = " << bul::extract(xIndex, firstDim, y) << endl; Array bIndex(x.size()); bIndex = false; bIndex(0) = true; bIndex(x.size()-1) = true; cout << "Boolean index = " << bIndex << endl; cout << "Indexed elements of X = " << bul::extract(bIndex, x) << endl; cout << "Indexed elements of 2nd column of Y = " << bul::extract(bIndex, ycolumn) << endl; cout << "Indexed rows of Y = " << bul::extract(bIndex, firstDim, y) << endl; Array bcolIndex(y.columns()); bcolIndex = false; bcolIndex(0) = true; bcolIndex(y.columns()-1) = true; cout << "Boolean index for columns of Y = " << bcolIndex << endl; cout << "Indexed columns of Y = " << bul::extract(bcolIndex, secondDim, y) << endl; return 0; }