F.h   F.h 
// -*- C++ -*-
// $Id$
/* /*
* F distribution * F distribution
* *
* This code has been adapted from RANDLIB.C 1.3, by * This code has been adapted from RANDLIB.C 1.3, by
* Barry W. Brown, James Lovato, Kathy Russell, and John Venier. * Barry W. Brown, James Lovato, Kathy Russell, and John Venier.
* Code was originally by Ahrens and Dieter (see above). * Code was originally by Ahrens and Dieter (see above).
* *
* Adapter's notes: * Adapter's notes:
* BZ_NEEDS_WORK: how to handle seeding for the two gamma RNGs if * BZ_NEEDS_WORK: how to handle seeding for the two gamma RNGs if
* independentState is used? * independentState is used?
skipping to change at line 33 skipping to change at line 36
template<typename T = double, typename IRNG = defaultIRNG, template<typename T = double, typename IRNG = defaultIRNG,
typename stateTag = defaultState> typename stateTag = defaultState>
class F { class F {
public: public:
typedef T T_numtype; typedef T T_numtype;
F(T numeratorDF, T denominatorDF) F(T numeratorDF, T denominatorDF)
{ {
setDF(numeratorDF, denominatorDF); setDF(numeratorDF, denominatorDF);
mindenom = 0.085 * tiny(T()); mindenom = 0.085 * blitz::tiny(T());
}
F(T numeratorDF, T denominatorDF, unsigned int i) :
ngamma(i), dgamma(i)
{
setDF(numeratorDF, denominatorDF);
mindenom = 0.085 * blitz::tiny(T());
} }
void setDF(T _dfn, T _dfd) void setDF(T _dfn, T _dfd)
{ {
BZPRECONDITION(_dfn > 0.0); BZPRECONDITION(_dfn > 0.0);
BZPRECONDITION(_dfd > 0.0); BZPRECONDITION(_dfd > 0.0);
dfn = _dfn; dfn = _dfn;
dfd = _dfd; dfd = _dfd;
ngamma.setMean(dfn/2.0); ngamma.setMean(dfn/2.0);
skipping to change at line 56 skipping to change at line 66
T random() T random()
{ {
T xnum = 2.0 * ngamma.random() / dfn; T xnum = 2.0 * ngamma.random() / dfn;
T xden = 2.0 * ngamma.random() / dfd; T xden = 2.0 * ngamma.random() / dfd;
// Rare event: Will an overflow probably occur? // Rare event: Will an overflow probably occur?
if (xden <= mindenom) if (xden <= mindenom)
{ {
// Yes, just return huge(T()) // Yes, just return huge(T())
return huge(T()); return blitz::huge(T());
} }
return xnum / xden; return xnum / xden;
} }
void seed(IRNG_int s) void seed(IRNG_int s, IRNG_int r)
{ {
// This is such a bad idea if independentState is used. Ugh. // This is such a bad idea if independentState is used. Ugh.
// If sharedState is used, it is merely inefficient (the // If sharedState is used, it is merely inefficient (the
// same RNG is seeded twice). // same RNG is seeded twice).
// yes it's unacceptable -- changed to using two seeds / Patrik
// in fact should probably be two uncorrelated IRNGs...
ngamma.seed(s); ngamma.seed(s);
dgamma.seed(s); dgamma.seed(r);
} }
protected: protected:
Gamma<T,IRNG,stateTag> ngamma, dgamma; Gamma<T,IRNG,stateTag> ngamma, dgamma;
T dfn, dfd, mindenom; T dfn, dfd, mindenom;
}; };
BZ_NAMESPACE_END BZ_NAMESPACE_END
#endif // BZ_RANDOM_F #endif // BZ_RANDOM_F
 End of changes. 6 change blocks. 
4 lines changed or deleted 17 lines changed or added


 array-impl.h   array-impl.h 
// -*- C++ -*- // -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array-impl.h Definition of the Array<P_numtype, N_rank> class * blitz/array-impl.h Definition of the Array<P_numtype, N_rank> class
* *
* $Id: array-impl.h,v 1.25 2005/10/13 23:46:43 julianc Exp $ * $Id$
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* *
* This program is free software; you can redistribute it and/or * This file is a part of Blitz.
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
/* /*
* Wish list for array classes. * Wish list for array classes.
* - Arrays whose dimensions are unknown at compile time. * - Arrays whose dimensions are unknown at compile time.
* - where()/elsewhere()/elsewhere() as in Dan Quinlan's implementation * - where()/elsewhere()/elsewhere() as in Dan Quinlan's implementation
* - block reduction operations * - block reduction operations
* - conversion to/from matrix & vector * - conversion to/from matrix & vector
* - apply(T func(T)) * - apply(T func(T))
* - apply(T func(const T&)) * - apply(T func(const T&))
* - apply<T func(T)> * - apply<T func(T)>
*/ */
#ifndef BZ_ARRAY_H #ifndef BZ_ARRAY_H
#define BZ_ARRAY_H #define BZ_ARRAY_H
#include <blitz/blitz.h> #include <blitz/blitz.h>
#include <blitz/memblock.h> #include <blitz/memblock.h>
#include <blitz/range.h> #include <blitz/range.h>
#include <blitz/tinyvec.h> #include <blitz/tinyvec2.h>
#include <blitz/tvecglobs.h>
#ifdef BZ_ARRAY_SPACE_FILLING_TRAVERSAL
#include <blitz/traversal.h>
#endif
#include <blitz/indexexpr.h> #include <blitz/indexexpr.h>
#include <blitz/prettyprint.h>
#include <blitz/array/slice.h> // Subarrays and slicing #include <blitz/array/slice.h> // Subarrays and slicing
#include <blitz/array/map.h> // Tensor index notation #include <blitz/array/map.h> // Tensor index notation
#include <blitz/array/multi.h> // Multicomponent arrays #include <blitz/array/multi.h> // Multicomponent arrays
#include <blitz/array/domain.h> // RectDomain class #include <blitz/array/domain.h> // RectDomain class
#include <blitz/array/storage.h> // GeneralArrayStorage #include <blitz/array/storage.h> // GeneralArrayStorage
#ifdef BZ_HAVE_BOOST_SERIALIZATION
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/base_object.hpp>
#endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
/* /*
* Forward declarations * Forward declarations
*/ */
template<typename T_numtype, int N_rank> template<typename T_numtype, int N_rank>
class ArrayIterator; class ArrayIterator;
template<typename T_numtype, int N_rank> template<typename T_numtype, int N_rank>
skipping to change at line 86 skipping to change at line 92
template<typename T_array, typename T_index> template<typename T_array, typename T_index>
class IndirectArray; class IndirectArray;
template <typename P_numtype,int N_rank> template <typename P_numtype,int N_rank>
void swap(Array<P_numtype,N_rank>&,Array<P_numtype,N_rank>&); void swap(Array<P_numtype,N_rank>&,Array<P_numtype,N_rank>&);
template <typename P_numtype, int N_rank> template <typename P_numtype, int N_rank>
void find(Array<TinyVector<int,N_rank>,1>&,const Array<P_numtype,N_rank>&); void find(Array<TinyVector<int,N_rank>,1>&,const Array<P_numtype,N_rank>&);
/* /** Declaration of class Array, the "Swiss army knife" of Blitz
* Declaration of class Array expression template classes. This is an arbitrary (at compile
*/ time) rank, arbitrary size container.
// NEEDS_WORK: Array should inherit protected from MemoryBlockReference. \todo Array should inherit protected from MemoryBlockReference.
// To make this work, need to expose MemoryBlockReference::numReferences() To make this work, need to expose
// and make Array<P,N2> a friend of Array<P,N> for slicing. MemoryBlockReference::numReferences() and make Array<P,N2> a
friend of Array<P,N> for slicing. (Is this still relevant? Array
DOES inherit from MemoryBlockReference.)
*/
template<typename P_numtype, int N_rank> template<typename P_numtype, int N_rank>
class Array : public MemoryBlockReference<P_numtype> class Array : public MemoryBlockReference<P_numtype>
#ifdef BZ_NEW_EXPRESSION_TEMPLATES #ifdef BZ_NEW_EXPRESSION_TEMPLATES
, public ETBase<Array<P_numtype,N_rank> > , public ETBase<Array<P_numtype,N_rank> >
#endif #endif
{ {
private: private:
typedef MemoryBlockReference<P_numtype> T_base; typedef MemoryBlockReference<P_numtype> T_base;
using T_base::data_; using T_base::data_;
using T_base::changeToNullBlock;
using T_base::numReferences;
public: public:
////////////////////////////////////////////// //////////////////////////////////////////////
// Public Types // Public Types
////////////////////////////////////////////// //////////////////////////////////////////////
/* /*
* T_numtype is the numeric type stored in the array. * T_numtype is the numeric type stored in the array.
* T_index is a vector type which can be used to access elements * T_index is a vector type which can be used to access elements
* of many-dimensional arrays. * of many-dimensional arrays.
* T_array is the array type itself -- Array<T_numtype, N_rank> * T_array is the array type itself -- Array<T_numtype, N_rank>
* T_iterator is a a fast iterator for the array, used for expression * T_iterator is a a fast iterator for the array, used for expression
* templates * templates
* iterator is a STL-style iterator * iterator is a STL-style iterator
* const_iterator is an STL-style const iterator * const_iterator is an STL-style const iterator
* T_default_storage is the default storage class type for the array
*/ */
typedef P_numtype T_numtype; typedef P_numtype T_numtype;
typedef TinyVector<int, N_rank> T_index; typedef TinyVector<int, N_rank> T_index;
typedef Array<T_numtype, N_rank> T_array; typedef Array<T_numtype, N_rank> T_array;
typedef FastArrayIterator<T_numtype, N_rank> T_iterator; typedef FastArrayIterator<T_numtype, N_rank> T_iterator;
typedef ArrayIterator<T_numtype,N_rank> iterator; typedef ArrayIterator<T_numtype,N_rank> iterator;
typedef ConstArrayIterator<T_numtype,N_rank> const_iterator; typedef ConstArrayIterator<T_numtype,N_rank> const_iterator;
static const int _bz_rank = N_rank; /**
* Set default storage order. This is configurable
* via #defines as it is can be beneficial to set a
* specific storage for an entire project/file.
*
* First check for the Fortan flag and then the column
* major flag, since Fortran arrays are column major.
*/
#if defined(BZ_FORTRAN_ARRAY)
typedef FortranArray<N_rank> T_default_storage;
#elif defined(BZ_COLUMN_MAJOR_ARRAY)
typedef ColumnMajorArray<N_rank> T_default_storage;
#else
typedef GeneralArrayStorage<N_rank> T_default_storage;
#endif
static const int rank_ = N_rank;
////////////////////////////////////////////// //////////////////////////////////////////////
// Constructors // // Constructors //
////////////////////////////////////////////// //////////////////////////////////////////////
/* /** Construct an array from an expression. Because this entails a
* Construct an array from an array expression. memory allocation, it is explicit so this fact is obvious to
*/ the user. (There may also be ambiguities in making it
implicit?) */
template<typename T_expr> template<typename T_expr>
explicit Array(_bz_ArrayExpr<T_expr> expr); explicit Array(_bz_ArrayExpr<T_expr> expr);
/* /*
* Any missing length arguments will have their value taken from the * Any missing length arguments will have their value taken from the
* last argument. For example, * last argument. For example,
* Array<int,3> A(32,64); * Array<int,3> A(32,64);
* will create a 32x64x64 array. This is handled by setupStorage(). * will create a 32x64x64 array. This is handled by setupStorage().
*/ */
Array(GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank> ()) Array(GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
length_ = 0; length_ = 0;
stride_ = 0; stride_ = 0;
zeroOffset_ = 0; zeroOffset_ = 0;
} }
explicit Array(int length0, explicit Array(int length0,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
length_[0] = length0; length_[0] = length0;
setupStorage(0); setupStorage(0);
} }
Array(int length0, int length1, Array(int length0, int length1,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 2); BZPRECONDITION(N_rank >= 2);
TAU_TYPE_STRING(p1, "Array<T,N>::Array() [T=" TAU_TYPE_STRING(p1, "Array<T,N>::Array() [T="
+ CT(T_numtype) + ",N=" + CT(N_rank) + "]"); + CT(T_numtype) + ",N=" + CT(N_rank) + "]");
TAU_PROFILE(p1, "void (int,int)", TAU_BLITZ); TAU_PROFILE(p1, "void (int,int)", TAU_BLITZ);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
setupStorage(1); setupStorage(1);
} }
Array(int length0, int length1, int length2, Array(int length0, int length1, int length2,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 3); BZPRECONDITION(N_rank >= 3);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
setupStorage(2); setupStorage(2);
} }
Array(int length0, int length1, int length2, int length3, Array(int length0, int length1, int length2, int length3,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 4); BZPRECONDITION(N_rank >= 4);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
setupStorage(3); setupStorage(3);
} }
Array(int length0, int length1, int length2, int length3, int length4, Array(int length0, int length1, int length2, int length3, int length4,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 5); BZPRECONDITION(N_rank >= 5);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
length_[4] = length4; length_[4] = length4;
setupStorage(4); setupStorage(4);
} }
Array(int length0, int length1, int length2, int length3, int length4, Array(int length0, int length1, int length2, int length3, int length4,
int length5, int length5,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 6); BZPRECONDITION(N_rank >= 6);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
length_[4] = length4; length_[4] = length4;
length_[5] = length5; length_[5] = length5;
setupStorage(5); setupStorage(5);
} }
Array(int length0, int length1, int length2, int length3, int length4, Array(int length0, int length1, int length2, int length3, int length4,
int length5, int length6, int length5, int length6,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 7); BZPRECONDITION(N_rank >= 7);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
length_[4] = length4; length_[4] = length4;
length_[5] = length5; length_[5] = length5;
length_[6] = length6; length_[6] = length6;
setupStorage(6); setupStorage(6);
} }
Array(int length0, int length1, int length2, int length3, int length4, Array(int length0, int length1, int length2, int length3, int length4,
int length5, int length6, int length7, int length5, int length6, int length7,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 8); BZPRECONDITION(N_rank >= 8);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
length_[4] = length4; length_[4] = length4;
length_[5] = length5; length_[5] = length5;
length_[6] = length6; length_[6] = length6;
length_[7] = length7; length_[7] = length7;
setupStorage(7); setupStorage(7);
} }
Array(int length0, int length1, int length2, int length3, int length4, Array(int length0, int length1, int length2, int length3, int length4,
int length5, int length6, int length7, int length8, int length5, int length6, int length7, int length8,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 9); BZPRECONDITION(N_rank >= 9);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
length_[4] = length4; length_[4] = length4;
length_[5] = length5; length_[5] = length5;
length_[6] = length6; length_[6] = length6;
length_[7] = length7; length_[7] = length7;
length_[8] = length8; length_[8] = length8;
setupStorage(8); setupStorage(8);
} }
Array(int length0, int length1, int length2, int length3, int length4, Array(int length0, int length1, int length2, int length3, int length4,
int length5, int length6, int length7, int length8, int length9, int length5, int length6, int length7, int length8, int length9,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 10); BZPRECONDITION(N_rank >= 10);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
length_[4] = length4; length_[4] = length4;
length_[5] = length5; length_[5] = length5;
length_[6] = length6; length_[6] = length6;
length_[7] = length7; length_[7] = length7;
length_[8] = length8; length_[8] = length8;
length_[9] = length9; length_[9] = length9;
setupStorage(9); setupStorage(9);
} }
Array(int length0, int length1, int length2, int length3, int length4, Array(int length0, int length1, int length2, int length3, int length4,
int length5, int length6, int length7, int length8, int length9, int length5, int length6, int length7, int length8, int length9,
int length10, int length10,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(N_rank >= 11); BZPRECONDITION(N_rank >= 11);
length_[0] = length0; length_[0] = length0;
length_[1] = length1; length_[1] = length1;
length_[2] = length2; length_[2] = length2;
length_[3] = length3; length_[3] = length3;
length_[4] = length4; length_[4] = length4;
length_[5] = length5; length_[5] = length5;
length_[6] = length6; length_[6] = length6;
skipping to change at line 328 skipping to change at line 352
length_[9] = length9; length_[9] = length9;
length_[10] = length10; length_[10] = length10;
setupStorage(10); setupStorage(10);
} }
/* /*
* Construct an array from an existing block of memory. Ownership * Construct an array from an existing block of memory. Ownership
* is not acquired (this is provided for backwards compatibility). * is not acquired (this is provided for backwards compatibility).
*/ */
Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() GeneralArrayStorage<N_rank> storage =
) T_default_storage(contiguousData))
: MemoryBlockReference<T_numtype>(product(shape), dataFirst, : MemoryBlockReference<T_numtype>(_bz_returntype<sizeType>::product(s
hape), dataFirst,
neverDeleteData), neverDeleteData),
storage_(storage) storage_(storage)
{ {
BZPRECONDITION(dataFirst != 0); BZPRECONDITION(dataFirst != 0);
length_ = shape; length_ = shape;
computeStrides(); computeStrides();
data_ += zeroOffset_; data_ += zeroOffset_;
} }
/* /**
* Construct an array from an existing block of memory, with a Construct an array from an existing block of memory, with a
* given set of strides. Ownership is not acquired (i.e. the memory given set of strides. Ownership is not acquired (i.e. the
* block will not be freed by Blitz++). memory block will not be freed by Blitz++). This constructor is
used by extractComponent to make a component view of a
multicomponent array, which is by design noncontiguous. This
creates an incorrect length in the MemoryBlockReference (though
that may be of no consequence since we're not freeing the
memory).
*/ */
Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape,
TinyVector<int, N_rank> stride, TinyVector<diffType, N_rank> stride,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() GeneralArrayStorage<N_rank> storage =
) T_default_storage(contiguousData))
: MemoryBlockReference<T_numtype>(product(shape), dataFirst, : MemoryBlockReference<T_numtype>(_bz_returntype<sizeType>::product(s
hape), dataFirst,
neverDeleteData), neverDeleteData),
storage_(storage) storage_(storage)
{ {
BZPRECONDITION(dataFirst != 0); BZPRECONDITION(dataFirst != 0);
length_ = shape; length_ = shape;
stride_ = stride; stride_ = stride;
calculateZeroOffset(); calculateZeroOffset();
data_ += zeroOffset_; data_ += zeroOffset_;
} }
/* /**
* Construct an array from an existing block of memory. Construct an array from an existing block of memory. If the
storage represents a padded array, the length of the memory block
will be incorrect, which would lead to a crash if
"deleteDataWhenDone" is used. For this reason, we check that the
resulting array is contiguous.
*/ */
Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape,
preexistingMemoryPolicy deletionPolicy, preexistingMemoryPolicy deletionPolicy,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() GeneralArrayStorage<N_rank> storage =
) T_default_storage(contiguousData))
: MemoryBlockReference<T_numtype>(product(shape), dataFirst, : MemoryBlockReference<T_numtype>(_bz_returntype<sizeType>::product(s
hape), dataFirst,
deletionPolicy), deletionPolicy),
storage_(storage) storage_(storage)
{ {
BZPRECONDITION(dataFirst != 0); BZPRECONDITION(dataFirst != 0);
length_ = shape; length_ = shape;
computeStrides(); computeStrides();
data_ += zeroOffset_; data_ += zeroOffset_;
BZPRECHECK(deletionPolicy!=deleteDataWhenDone || isStorageContiguous
(), "Non-contiguous storage used with owned pre-existing memory");
if (deletionPolicy == duplicateData) if (deletionPolicy == duplicateData)
reference(copy()); reference(copy());
} }
/* /**
* Construct an array from an existing block of memory, with a Construct an array from an existing block of memory, with a given
* given set of strides. set of strides. If the strides represent a noncontiguous array,
the calculated length of the memory block will be wrong, which
will lead to a crash if "deleteDataWhenDone" is specified. For
this reason, we check that the resulting array is contiguous.
*/ */
Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, Array(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape,
TinyVector<int, N_rank> stride, TinyVector<diffType, N_rank> stride,
preexistingMemoryPolicy deletionPolicy, preexistingMemoryPolicy deletionPolicy,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() GeneralArrayStorage<N_rank> storage =
) T_default_storage(contiguousData))
: MemoryBlockReference<T_numtype>(product(shape), dataFirst, : MemoryBlockReference<T_numtype>(_bz_returntype<sizeType>::product(s
hape), dataFirst,
deletionPolicy), deletionPolicy),
storage_(storage) storage_(storage)
{ {
BZPRECONDITION(dataFirst != 0); BZPRECONDITION(dataFirst != 0);
length_ = shape; length_ = shape;
stride_ = stride; stride_ = stride;
calculateZeroOffset(); calculateZeroOffset();
data_ += zeroOffset_; data_ += zeroOffset_;
BZPRECHECK(deletionPolicy!=deleteDataWhenDone || isStorageContiguous
(), "Non-contiguous storage used with owned pre-existing memory");
if (deletionPolicy == duplicateData) if (deletionPolicy == duplicateData)
reference(copy()); reference(copy());
} }
/* /*
* This constructor takes an extent (length) vector and storage format. * This constructor takes an extent (length) vector and storage format.
*/ */
Array(const TinyVector<int, N_rank>& extent, Array(const TinyVector<int, N_rank>& extent,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
length_ = extent; length_ = extent;
setupStorage(N_rank - 1); setupStorage(N_rank - 1);
} }
/* /*
* This construct takes a vector of bases (lbounds) and a vector of * This construct takes a vector of bases (lbounds) and a vector of
* extents. * extents.
*/ */
Array(const TinyVector<int, N_rank>& lbounds, Array(const TinyVector<int, N_rank>& lbounds,
const TinyVector<int, N_rank>& extent, const TinyVector<int, N_rank>& extent,
const GeneralArrayStorage<N_rank>& storage const GeneralArrayStorage<N_rank>& storage
= GeneralArrayStorage<N_rank>()); = T_default_storage());
/* /*
* These constructors allow arbitrary bases (starting indices) to be se t. * These constructors allow arbitrary bases (starting indices) to be se t.
* e.g. Array<int,2> A(Range(10,20), Range(20,30)) * e.g. Array<int,2> A(Range(10,20), Range(20,30))
* will create an 11x11 array whose indices are 10..20 and 20..30 * will create an 11x11 array whose indices are 10..20 and 20..30
*/ */
Array(Range r0, Array(Range r0,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous()); BZPRECONDITION(r0.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
setupStorage(0); setupStorage(0);
} }
Array(Range r0, Range r1, Array(Range r0, Range r1,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous()); r1.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
length_[1] = r1.length(); length_[1] = r1.length();
storage_.setBase(1, r1.first()); storage_.setBase(1, r1.first());
setupStorage(1); setupStorage(1);
} }
Array(Range r0, Range r1, Range r2, Array(Range r0, Range r1, Range r2,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous()); r1.isAscendingContiguous() && r2.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
length_[1] = r1.length(); length_[1] = r1.length();
storage_.setBase(1, r1.first()); storage_.setBase(1, r1.first());
length_[2] = r2.length(); length_[2] = r2.length();
storage_.setBase(2, r2.first()); storage_.setBase(2, r2.first());
setupStorage(2); setupStorage(2);
} }
Array(Range r0, Range r1, Range r2, Range r3, Array(Range r0, Range r1, Range r2, Range r3,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous()); && r3.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
length_[1] = r1.length(); length_[1] = r1.length();
storage_.setBase(1, r1.first()); storage_.setBase(1, r1.first());
length_[2] = r2.length(); length_[2] = r2.length();
storage_.setBase(2, r2.first()); storage_.setBase(2, r2.first());
length_[3] = r3.length(); length_[3] = r3.length();
storage_.setBase(3, r3.first()); storage_.setBase(3, r3.first());
setupStorage(3); setupStorage(3);
} }
Array(Range r0, Range r1, Range r2, Range r3, Range r4, Array(Range r0, Range r1, Range r2, Range r3, Range r4,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous() && r4.isAscendingContiguous()); && r3.isAscendingContiguous() && r4.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
length_[1] = r1.length(); length_[1] = r1.length();
storage_.setBase(1, r1.first()); storage_.setBase(1, r1.first());
skipping to change at line 516 skipping to change at line 561
storage_.setBase(2, r2.first()); storage_.setBase(2, r2.first());
length_[3] = r3.length(); length_[3] = r3.length();
storage_.setBase(3, r3.first()); storage_.setBase(3, r3.first());
length_[4] = r4.length(); length_[4] = r4.length();
storage_.setBase(4, r4.first()); storage_.setBase(4, r4.first());
setupStorage(4); setupStorage(4);
} }
Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous() && r4.isAscendingContiguous() && r3.isAscendingContiguous() && r4.isAscendingContiguous()
&& r5.isAscendingContiguous()); && r5.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
length_[1] = r1.length(); length_[1] = r1.length();
skipping to change at line 542 skipping to change at line 587
length_[4] = r4.length(); length_[4] = r4.length();
storage_.setBase(4, r4.first()); storage_.setBase(4, r4.first());
length_[5] = r5.length(); length_[5] = r5.length();
storage_.setBase(5, r5.first()); storage_.setBase(5, r5.first());
setupStorage(5); setupStorage(5);
} }
Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
Range r6, Range r6,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous() && r4.isAscendingContiguous() && r3.isAscendingContiguous() && r4.isAscendingContiguous()
&& r5.isAscendingContiguous() && r6.isAscendingContiguous()); && r5.isAscendingContiguous() && r6.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
length_[1] = r1.length(); length_[1] = r1.length();
skipping to change at line 570 skipping to change at line 615
length_[5] = r5.length(); length_[5] = r5.length();
storage_.setBase(5, r5.first()); storage_.setBase(5, r5.first());
length_[6] = r6.length(); length_[6] = r6.length();
storage_.setBase(6, r6.first()); storage_.setBase(6, r6.first());
setupStorage(6); setupStorage(6);
} }
Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
Range r6, Range r7, Range r6, Range r7,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous() && r4.isAscendingContiguous() && r3.isAscendingContiguous() && r4.isAscendingContiguous()
&& r5.isAscendingContiguous() && r6.isAscendingContiguous() && r5.isAscendingContiguous() && r6.isAscendingContiguous()
&& r7.isAscendingContiguous()); && r7.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
skipping to change at line 601 skipping to change at line 646
length_[6] = r6.length(); length_[6] = r6.length();
storage_.setBase(6, r6.first()); storage_.setBase(6, r6.first());
length_[7] = r7.length(); length_[7] = r7.length();
storage_.setBase(7, r7.first()); storage_.setBase(7, r7.first());
setupStorage(7); setupStorage(7);
} }
Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
Range r6, Range r7, Range r8, Range r6, Range r7, Range r8,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous() && r4.isAscendingContiguous() && r3.isAscendingContiguous() && r4.isAscendingContiguous()
&& r5.isAscendingContiguous() && r6.isAscendingContiguous() && r5.isAscendingContiguous() && r6.isAscendingContiguous()
&& r7.isAscendingContiguous() && r8.isAscendingContiguous()); && r7.isAscendingContiguous() && r8.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
storage_.setBase(0, r0.first()); storage_.setBase(0, r0.first());
skipping to change at line 634 skipping to change at line 679
length_[7] = r7.length(); length_[7] = r7.length();
storage_.setBase(7, r7.first()); storage_.setBase(7, r7.first());
length_[8] = r8.length(); length_[8] = r8.length();
storage_.setBase(8, r8.first()); storage_.setBase(8, r8.first());
setupStorage(8); setupStorage(8);
} }
Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
Range r6, Range r7, Range r8, Range r9, Range r6, Range r7, Range r8, Range r9,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous() && r4.isAscendingContiguous() && r3.isAscendingContiguous() && r4.isAscendingContiguous()
&& r5.isAscendingContiguous() && r6.isAscendingContiguous() && r5.isAscendingContiguous() && r6.isAscendingContiguous()
&& r7.isAscendingContiguous() && r8.isAscendingContiguous() && r7.isAscendingContiguous() && r8.isAscendingContiguous()
&& r9.isAscendingContiguous()); && r9.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
skipping to change at line 670 skipping to change at line 715
length_[8] = r8.length(); length_[8] = r8.length();
storage_.setBase(8, r8.first()); storage_.setBase(8, r8.first());
length_[9] = r9.length(); length_[9] = r9.length();
storage_.setBase(9, r9.first()); storage_.setBase(9, r9.first());
setupStorage(9); setupStorage(9);
} }
Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Array(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5,
Range r6, Range r7, Range r8, Range r9, Range r10, Range r6, Range r7, Range r8, Range r9, Range r10,
GeneralArrayStorage<N_rank> storage = GeneralArrayStorage<N_rank>() ) GeneralArrayStorage<N_rank> storage = T_default_storage())
: storage_(storage) : storage_(storage)
{ {
BZPRECONDITION(r0.isAscendingContiguous() && BZPRECONDITION(r0.isAscendingContiguous() &&
r1.isAscendingContiguous() && r2.isAscendingContiguous() r1.isAscendingContiguous() && r2.isAscendingContiguous()
&& r3.isAscendingContiguous() && r4.isAscendingContiguous() && r3.isAscendingContiguous() && r4.isAscendingContiguous()
&& r5.isAscendingContiguous() && r6.isAscendingContiguous() && r5.isAscendingContiguous() && r6.isAscendingContiguous()
&& r7.isAscendingContiguous() && r8.isAscendingContiguous() && r7.isAscendingContiguous() && r8.isAscendingContiguous()
&& r9.isAscendingContiguous() && r10.isAscendingContiguous()); && r9.isAscendingContiguous() && r10.isAscendingContiguous());
length_[0] = r0.length(); length_[0] = r0.length();
skipping to change at line 851 skipping to change at line 896
const_iterator begin() const const_iterator begin() const
{ return const_iterator(*this); } { return const_iterator(*this); }
T_iterator beginFast() const T_iterator beginFast() const
{ return T_iterator(*this); } { return T_iterator(*this); }
// Deprecated: now extractComponent(...) // Deprecated: now extractComponent(...)
template<typename P_numtype2> template<typename P_numtype2>
Array<P_numtype2,N_rank> chopComponent(P_numtype2 a, int compN um, Array<P_numtype2,N_rank> chopComponent(P_numtype2 a, int compN um,
int numComponents) const int numComponents) cons t
{ return extractComponent(a, compNum, numComponents); } { return extractComponent(a, compNum, numComponents); }
int cols() const int cols() const
{ return length_[1]; } { return length_[1]; }
int columns() const int columns() const
{ return length_[1]; } { return length_[1]; }
T_array copy() const; T_array copy() const;
// data_ always refers to the point (0,0,...,0) which may // data_ always refers to the point (0,0,...,0) which may
// not be in the array if the base is not zero in each rank. // not be in the array if the base is not zero in each rank.
// These data() routines return a pointer to the first // These data() routines return a pointer to the first
// element in the array (but note that it may not be // element in the array (but note that it may not be
// stored first in memory if some ranks are stored descending). // stored first in memory if some ranks are stored descending).
int dataOffset() const diffType dataOffset() const
{ { return dot(storage_.base(), stride_); }
return dot(storage_.base(), stride_);
}
const T_numtype* restrict data() const const T_numtype* restrict data() const
{ return data_ + dataOffset(); } { return data_ + dataOffset(); }
T_numtype* restrict data() T_numtype* restrict data()
{ return data_ + dataOffset(); } { return data_ + dataOffset(); }
// These dataZero() routines refer to the point (0,0,...,0) // These dataZero() routines refer to the point (0,0,...,0)
// which may not be in the array if the bases are nonzero. // which may not be in the array if the bases are nonzero.
const T_numtype* restrict dataZero() const const T_numtype* restrict dataZero() const
{ return data_; } { return data_; }
T_numtype* restrict dataZero() T_numtype* restrict dataZero()
{ return data_; } { return data_; }
// These dataFirst() routines refer to the element in the // These dataFirst() routines refer to the element in the
// array which falls first in memory. // array which falls first in memory.
int dataFirstOffset() const diffType dataFirstOffset() const
{ {
int pos = 0; diffType pos = 0;
// Used to use tinyvector expressions: // Used to use tinyvector expressions:
// return data_ + dot(storage_.base() // return data_ + dot(storage_.base()
// + (1 - storage_.ascendingFlag()) * (length_ - 1), stride_); // + (1 - storage_.ascendingFlag()) * (length_ - 1), stride_);
for (int i=0; i < N_rank; ++i) for (int i=0; i < N_rank; ++i)
pos += (storage_.base(i) + (1-storage_.isRankStoredAscending(i)) * pos += (storage_.base(i) + (1-storage_.isRankStoredAscending(i)) *
(length_(i)-1)) * stride_(i); (length_(i)-1)) * stride_(i);
return pos; return pos;
} }
const T_numtype* restrict dataFirst() const const T_numtype* restrict dataFirst() const
{ { return data_ + dataFirstOffset(); }
return data_ + dataFirstOffset();
}
T_numtype* restrict dataFirst() T_numtype* restrict dataFirst()
{ { return data_ + dataFirstOffset(); }
return data_ + dataFirstOffset();
}
int depth() const int depth() const
{ return length_[2]; } { return length_[2]; }
int dimensions() const int dimensions() const
{ return N_rank; } { return N_rank; }
RectDomain<N_rank> domain() const RectDomain<N_rank> domain() const
{ { return RectDomain<N_rank>(lbound(), ubound()); }
return RectDomain<N_rank>(lbound(), ubound());
}
void dumpStructureInformation(ostream& os = cout) const; void dumpStructureInformation(ostream& os = cout) const;
iterator end() iterator end()
{ { return iterator(*this,0); }
return iterator();
}
const_iterator end() const const_iterator end() const
{ { return const_iterator(*this,0); }
return const_iterator();
}
int extent(int rank) const int extent(int rank) const
{ return length_[rank]; } { return length_[rank]; }
const TinyVector<int,N_rank>& extent() const const TinyVector<int,N_rank>& extent() const
{ return length_; } { return length_; }
template<typename P_numtype2> template<typename P_numtype2>
Array<P_numtype2,N_rank> extractComponent(P_numtype2, int comp Num, Array<P_numtype2,N_rank> extractComponent(P_numtype2, int comp Num,
int numComponents) const; int numComponents) c onst;
void free() void free()
{ {
changeToNullBlock(); T_base::changeToNullBlock();
length_ = 0; length_ = 0;
} }
bool isMajorRank(int rank) const { return storage_.ordering(rank) == 0; bool isMajorRank(int rank) const
} { return storage_.ordering(rank) == N_rank-1; }
bool isMinorRank(int rank) const { return storage_.ordering(rank) != 0; bool isMinorRank(int rank) const
} { return storage_.ordering(rank) != N_rank-1; }
bool isRankStoredAscending(int rank) const { bool isRankStoredAscending(int rank) const
return storage_.isRankStoredAscending(rank); { return storage_.isRankStoredAscending(rank); }
}
bool isStorageContiguous() const; bool isStorageContiguous() const;
int lbound(int rank) const { return base(rank); } int lbound(int rank) const
TinyVector<int,N_rank> lbound() const { return base(); } { return base(rank); }
TinyVector<int,N_rank> lbound() const
{ return base(); }
int length(int rank) const { return length_[ int length(int rank) const
rank]; } { return length_[rank]; }
const TinyVector<int, N_rank>& length() const { return length_; const TinyVector<int, N_rank>& length() const
} { return length_; }
void makeUnique(); void makeUnique();
int numElements() const { return product(length_); } sizeType numElements() const
{ return _bz_returntype<sizeType>::product(length_); }
// NEEDS_WORK -- Expose the numReferences() method // NEEDS_WORK -- Expose the numReferences() method
// MemoryBlockReference<T_numtype>::numReferences; // MemoryBlockReference<T_numtype>::numReferences;
// The storage_.ordering_ array is a list of dimensions from // The storage_.ordering_ array is a list of dimensions from
// the most minor (stride 1) to major dimension. Generally, // the most minor (stride 1) to major dimension. Generally,
// ordering(0) will return the dimension which has the smallest // ordering(0) will return the dimension which has the smallest
// stride, and ordering(N_rank-1) will return the dimension with // stride, and ordering(N_rank-1) will return the dimension with
// the largest stride. // the largest stride.
int ordering(int storageRankIndex) const int ordering(int storageRankIndex) const
{ return storage_.ordering(storageRankIndex); } { return storage_.ordering(storageRankIndex); }
const TinyVector<int, N_rank>& ordering() const const TinyVector<int, N_rank>& ordering() const
{ return storage_.ordering(); } { return storage_.ordering(); }
void transposeSelf(int r0, int r1, int r2= 0, void transposeSelf(int r0, int r1, int r2= 0,
int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int
r9=0, int r10=0); r9=0, int r10=0);
T_array transpose(int r0, int r1, int r2=0, T_array transpose(int r0, int r1, int r2=0,
int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int
r9=0, int r10=0); r9=0, int r10=0) const;
int rank() const static int rank()
{ return N_rank; } { return rank_; }
void reference(const T_array&); void reference(const T_array&);
void weakReference(const T_array&);
// Added by Derrick Bass // Added by Derrick Bass
T_array reindex(const TinyVector<int,N_rank>& ); T_array reindex(const TinyVector<int,N_rank>& );
void reindexSelf(const void reindexSelf(
TinyVector<int,N_rank>&); const TinyVector<int,N_rank>&);
void resize(int extent); void resize(int extent);
void resize(int extent1, int extent2); void resize(int extent1, int extent2);
void resize(int extent1, int extent2, void resize(int extent1, int extent2,
int extent3); int extent3);
void resize(int extent1, int extent2, void resize(int extent1, int extent2,
int extent3, int extent4); int extent3, int extent4);
void resize(int extent1, int extent2, void resize(int extent1, int extent2,
int extent3, int extent4, int exten t5); int extent3, int extent4, int exten t5);
void resize(int extent1, int extent2, void resize(int extent1, int extent2,
skipping to change at line 1117 skipping to change at line 1157
int rows() const int rows() const
{ return length_[0]; } { return length_[0]; }
void setStorage(GeneralArrayStorage<N_rank >); void setStorage(GeneralArrayStorage<N_rank >);
void slice(int rank, Range r); void slice(int rank, Range r);
const TinyVector<int, N_rank>& shape() const const TinyVector<int, N_rank>& shape() const
{ return length_; } { return length_; }
int size() const sizeType size() const
{ return numElements(); } { return numElements(); }
const TinyVector<int, N_rank>& stride() const /** Returns the length of the array storage. This can be larger than
the number of elements due to padding to meet alignment
requirements. If you want to extract the array data to, for
example, write it to disk, this is the size of the block
needed. \todo Is this safe if there is no block? */
sizeType storageSize() const
{ return T_base::blockLength(); }
const TinyVector<diffType, N_rank>& stride() const
{ return stride_; } { return stride_; }
int stride(int rank) const diffType stride(int rank) const
{ return stride_[rank]; } { return stride_[rank]; }
bool threadLocal(bool disableLock = true)
const
{ return T_base::lockReferenceCount(!disableLock); }
int ubound(int rank) const int ubound(int rank) const
{ return base(rank) + length_(rank) - 1; } { return base(rank) + length_(rank) - 1; }
TinyVector<int, N_rank> ubound() const TinyVector<int, N_rank> ubound() const
{ {
TinyVector<int, N_rank> ub; TinyVector<int, N_rank> ub;
for (int i=0; i < N_rank; ++i) for (int i=0; i < N_rank; ++i)
ub(i) = base(i) + extent(i) - 1; ub(i) = base(i) + extent(i) - 1;
// WAS: ub = base() + extent() - 1; // WAS: ub = base() + extent() - 1;
return ub; return ub;
} }
int zeroOffset() const int zeroOffset() const
{ return zeroOffset_; } { return zeroOffset_; }
/** Returns true if the array is aligned on a simd vector width. */
bool isVectorAligned(diffType offset) const
{ return simdTypes<T_numtype>::isVectorAligned(dataFirst()+offset); };
////////////////////////////////////////////// //////////////////////////////////////////////
// Debugging routines // Debugging routines
////////////////////////////////////////////// //////////////////////////////////////////////
bool isInRangeForDim(int i, int d) const { bool isInRangeForDim(int i, int d) const {
return i >= base(d) && (i - base(d)) < length_[d]; return i >= base(d) && (i - base(d)) < length_[d];
} }
bool isInRange(int i0) const { bool isInRange(int i0) const {
return i0 >= base(0) && (i0 - base(0)) < length_[0]; return i0 >= base(0) && (i0 - base(0)) < length_[0];
skipping to change at line 1432 skipping to change at line 1487
T_numtype& operator()(TinyVector<int,1> index) T_numtype& operator()(TinyVector<int,1> index)
{ {
assertInRange(index[0]); assertInRange(index[0]);
return data_[index[0] * stride_[0]]; return data_[index[0] * stride_[0]];
} }
const T_numtype& restrict operator()(TinyVector<int,2> index) const const T_numtype& restrict operator()(TinyVector<int,2> index) const
{ {
assertInRange(index[0], index[1]); assertInRange(index[0], index[1]);
return data_[index[0] * stride_[0] + index[1] * stride_[1]]; return data_[index[0] * stride_[0]
+ index[1] * stride_[1]];
} }
T_numtype& operator()(TinyVector<int,2> index) T_numtype& operator()(TinyVector<int,2> index)
{ {
assertInRange(index[0], index[1]); assertInRange(index[0], index[1]);
return data_[index[0] * stride_[0] + index[1] * stride_[1]]; return data_[index[0] * stride_[0]
+ index[1] * stride_[1]];
} }
const T_numtype& restrict operator()(TinyVector<int,3> index) const const T_numtype& restrict operator()(TinyVector<int,3> index) const
{ {
assertInRange(index[0], index[1], index[2]); assertInRange(index[0], index[1], index[2]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2]]; + index[1] * stride_[1]
+ index[2] * stride_[2]];
} }
T_numtype& operator()(TinyVector<int,3> index) T_numtype& operator()(TinyVector<int,3> index)
{ {
assertInRange(index[0], index[1], index[2]); assertInRange(index[0], index[1], index[2]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2]]; + index[1] * stride_[1]
+ index[2] * stride_[2]];
} }
const T_numtype& restrict operator()(const TinyVector<int,4>& index) co nst const T_numtype& restrict operator()(const TinyVector<int,4>& index) co nst
{ {
assertInRange(index[0], index[1], index[2], index[3]); assertInRange(index[0], index[1], index[2], index[3]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3]]; + index[1] * stride_[1]
+ index[2] * stride_[2] + index[3] * stride_[3]];
} }
T_numtype& operator()(const TinyVector<int,4>& index) T_numtype& operator()(const TinyVector<int,4>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3]); assertInRange(index[0], index[1], index[2], index[3]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3]]; + index[1] * stride_[1]
+ index[2] * stride_[2] + index[3] * stride_[3]];
} }
const T_numtype& restrict operator()(const TinyVector<int,5>& index) co nst const T_numtype& restrict operator()(const TinyVector<int,5>& index) co nst
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4]); index[4]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4]]; + index[2] * stride_[2] + index[3] * stride_[3]
+ index[4] * stride_[4]];
} }
T_numtype& operator()(const TinyVector<int,5>& index) T_numtype& operator()(const TinyVector<int,5>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4]); index[4]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4]]; + index[2] * stride_[2] + index[3] * stride_[3]
+ index[4] * stride_[4]];
} }
const T_numtype& restrict operator()(const TinyVector<int,6>& index) co nst const T_numtype& restrict operator()(const TinyVector<int,6>& index) co nst
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5]); index[4], index[5]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5]]; + index[2] * stride_[2] + index[3] * stride_[3]
+ index[4] * stride_[4] + index[5] * stride_[5]];
} }
T_numtype& operator()(const TinyVector<int,6>& index) T_numtype& operator()(const TinyVector<int,6>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5]); index[4], index[5]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5]]; + index[2] * stride_[2] + index[3] * stride_[3]
+ index[4] * stride_[4] + index[5] * stride_[5]];
} }
const T_numtype& restrict operator()(const TinyVector<int,7>& index) co nst const T_numtype& restrict operator()(const TinyVector<int,7>& index) co nst
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6]); index[4], index[5], index[6]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6]]; + index[4] * stride_[4] + index[5] * stride_[5]
+ index[6] * stride_[6]];
} }
T_numtype& operator()(const TinyVector<int,7>& index) T_numtype& operator()(const TinyVector<int,7>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6]); index[4], index[5], index[6]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6]]; + index[4] * stride_[4] + index[5] * stride_[5]
+ index[6] * stride_[6]];
} }
const T_numtype& restrict operator()(const TinyVector<int,8>& index) co nst const T_numtype& restrict operator()(const TinyVector<int,8>& index) co nst
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7]); index[4], index[5], index[6], index[7]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7]]; + index[4] * stride_[4] + index[5] * stride_[5]
+ index[6] * stride_[6] + index[7] * stride_[7]];
} }
T_numtype& operator()(const TinyVector<int,8>& index) T_numtype& operator()(const TinyVector<int,8>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7]); index[4], index[5], index[6], index[7]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7]]; + index[4] * stride_[4] + index[5] * stride_[5]
+ index[6] * stride_[6] + index[7] * stride_[7]];
} }
const T_numtype& restrict operator()(const TinyVector<int,9>& index) co nst const T_numtype& restrict operator()(const TinyVector<int,9>& index) co nst
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7], index[8]); index[4], index[5], index[6], index[7], index[8]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7] + index[4] * stride_[4] + index[5] * stride_[5]
+ index[8] * stride_[8]]; + index[6] * stride_[6] + index[7] * stride_[7]
+ index[8] * stride_[8]];
} }
T_numtype& operator()(const TinyVector<int,9>& index) T_numtype& operator()(const TinyVector<int,9>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7], index[8]); index[4], index[5], index[6], index[7], index[8]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7] + index[4] * stride_[4] + index[5] * stride_[5]
+ index[8] * stride_[8]]; + index[6] * stride_[6] + index[7] * stride_[7]
+ index[8] * stride_[8]];
} }
const T_numtype& restrict operator()(const TinyVector<int,10>& index) c onst const T_numtype& restrict operator()(const TinyVector<int,10>& index) c onst
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7], index[8], index[9]); index[4], index[5], index[6], index[7], index[8], index[9]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7] + index[4] * stride_[4] + index[5] * stride_[5]
+ index[8] * stride_[8] + index[9] * stride_[9]]; + index[6] * stride_[6] + index[7] * stride_[7]
+ index[8] * stride_[8] + index[9] * stride_[9]];
} }
T_numtype& operator()(const TinyVector<int,10>& index) T_numtype& operator()(const TinyVector<int,10>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7], index[8], index[9]); index[4], index[5], index[6], index[7], index[8], index[9]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7] + index[4] * stride_[4] + index[5] * stride_[5]
+ index[8] * stride_[8] + index[9] * stride_[9]]; + index[6] * stride_[6] + index[7] * stride_[7]
+ index[8] * stride_[8] + index[9] * stride_[9]];
} }
const T_numtype& restrict operator()(const TinyVector<int,11>& index) c onst const T_numtype& restrict operator()(const TinyVector<int,11>& index) c onst
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7], index[8], index[9], index[4], index[5], index[6], index[7], index[8], index[9],
index[10]); index[10]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7] + index[4] * stride_[4] + index[5] * stride_[5]
+ index[8] * stride_[8] + index[9] * stride_[9] + index[6] * stride_[6] + index[7] * stride_[7]
+ index[10] * stride_[10]]; + index[8] * stride_[8] + index[9] * stride_[9]
+ index[10] * stride_[10]];
} }
T_numtype& operator()(const TinyVector<int,11>& index) T_numtype& operator()(const TinyVector<int,11>& index)
{ {
assertInRange(index[0], index[1], index[2], index[3], assertInRange(index[0], index[1], index[2], index[3],
index[4], index[5], index[6], index[7], index[8], index[9], index[4], index[5], index[6], index[7], index[8], index[9],
index[10]); index[10]);
return data_[index[0] * stride_[0] + index[1] * stride_[1] return data_[(index[0]) * stride_[0]
+ index[2] * stride_[2] + index[3] * stride_[3] + index[1] * stride_[1]
+ index[4] * stride_[4] + index[5] * stride_[5] + index[2] * stride_[2] + index[3] * stride_[3]
+ index[6] * stride_[6] + index[7] * stride_[7] + index[4] * stride_[4] + index[5] * stride_[5]
+ index[8] * stride_[8] + index[9] * stride_[9] + index[6] * stride_[6] + index[7] * stride_[7]
+ index[10] * stride_[10]]; + index[8] * stride_[8] + index[9] * stride_[9]
+ index[10] * stride_[10]];
} }
const T_numtype& restrict operator()(int i0) const const T_numtype& restrict operator()(int i0) const
{ {
assertInRange(i0); assertInRange(i0);
return data_[i0 * stride_[0]]; return data_[(i0) * stride_[0]];
} }
T_numtype& restrict operator()(int i0) T_numtype& restrict operator()(int i0)
{ {
assertInRange(i0); assertInRange(i0);
return data_[i0 * stride_[0]]; return data_[(i0) * stride_[0]];
} }
const T_numtype& restrict operator()(int i0, int i1) const const T_numtype& restrict operator()(int i0, int i1) const
{ {
assertInRange(i0, i1); assertInRange(i0, i1);
return data_[i0 * stride_[0] + i1 * stride_[1]]; return data_[(i0) * stride_[0] + i1 * stride_[1]];
} }
T_numtype& restrict operator()(int i0, int i1) T_numtype& restrict operator()(int i0, int i1)
{ {
assertInRange(i0, i1); assertInRange(i0, i1);
return data_[i0 * stride_[0] + i1 * stride_[1]]; return data_[(i0) * stride_[0] + i1 * stride_[1]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2) const const T_numtype& restrict operator()(int i0, int i1, int i2) const
{ {
assertInRange(i0, i1, i2); assertInRange(i0, i1, i2);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2]]; + i2 * stride_[2]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2) T_numtype& restrict operator()(int i0, int i1, int i2)
{ {
assertInRange(i0, i1, i2); assertInRange(i0, i1, i2);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2]]; + i2 * stride_[2]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3) co nst const T_numtype& restrict operator()(int i0, int i1, int i2, int i3) co nst
{ {
assertInRange(i0, i1, i2, i3); assertInRange(i0, i1, i2, i3);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3]]; + i2 * stride_[2] + i3 * stride_[3]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3) T_numtype& restrict operator()(int i0, int i1, int i2, int i3)
{ {
assertInRange(i0, i1, i2, i3); assertInRange(i0, i1, i2, i3);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3]]; + i2 * stride_[2] + i3 * stride_[3]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3, const T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4) const int i4) const
{ {
assertInRange(i0, i1, i2, i3, i4); assertInRange(i0, i1, i2, i3, i4);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]]; + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3, T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4) int i4)
{ {
assertInRange(i0, i1, i2, i3, i4); assertInRange(i0, i1, i2, i3, i4);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]]; + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3, const T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5) const int i4, int i5) const
{ {
assertInRange(i0, i1, i2, i3, i4, i5); assertInRange(i0, i1, i2, i3, i4, i5);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5]]; + i5 * stride_[5]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3, T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5) int i4, int i5)
{ {
assertInRange(i0, i1, i2, i3, i4, i5); assertInRange(i0, i1, i2, i3, i4, i5);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5]]; + i5 * stride_[5]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3, const T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6) const int i4, int i5, int i6) const
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6); assertInRange(i0, i1, i2, i3, i4, i5, i6);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6]]; + i5 * stride_[5] + i6 * stride_[6]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3, T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6) int i4, int i5, int i6)
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6); assertInRange(i0, i1, i2, i3, i4, i5, i6);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6]]; + i5 * stride_[5] + i6 * stride_[6]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3, const T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7) const int i4, int i5, int i6, int i7) const
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7); assertInRange(i0, i1, i2, i3, i4, i5, i6, i7);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]]; + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3, T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7) int i4, int i5, int i6, int i7)
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7); assertInRange(i0, i1, i2, i3, i4, i5, i6, i7);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]]; + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3, const T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7, int i8) const int i4, int i5, int i6, int i7, int i8) const
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8); assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7] + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+ i8 * stride_[8]]; + i8 * stride_[8]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3, T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7, int i8) int i4, int i5, int i6, int i7, int i8)
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8); assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7] + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+ i8 * stride_[8]]; + i8 * stride_[8]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3, const T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7, int i8, int i9) const int i4, int i5, int i6, int i7, int i8, int i9) const
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9); assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7] + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+ i8 * stride_[8] + i9 * stride_[9]]; + i8 * stride_[8] + i9 * stride_[9]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3, T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7, int i8, int i9) int i4, int i5, int i6, int i7, int i8, int i9)
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9); assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7] + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+ i8 * stride_[8] + i9 * stride_[9]]; + i8 * stride_[8] + i9 * stride_[9]];
} }
const T_numtype& restrict operator()(int i0, int i1, int i2, int i3, const T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7, int i8, int i9, int i10) const int i4, int i5, int i6, int i7, int i8, int i9, int i10) const
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8,
i9, i10); i9, i10);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7] + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+ i8 * stride_[8] + i9 * stride_[9] + i10 * stride_[10]]; + i8 * stride_[8] + i9 * stride_[9] + i10 * stride_[10]];
} }
T_numtype& restrict operator()(int i0, int i1, int i2, int i3, T_numtype& restrict operator()(int i0, int i1, int i2, int i3,
int i4, int i5, int i6, int i7, int i8, int i9, int i10) int i4, int i5, int i6, int i7, int i8, int i9, int i10)
{ {
assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8, assertInRange(i0, i1, i2, i3, i4, i5, i6, i7, i8,
i9, i10); i9, i10);
return data_[i0 * stride_[0] + i1 * stride_[1] return data_[(i0) * stride_[0] + i1 * stride_[1]
+ i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4] + i2 * stride_[2] + i3 * stride_[3] + i4 * stride_[4]
+ i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7] + i5 * stride_[5] + i6 * stride_[6] + i7 * stride_[7]
+ i8 * stride_[8] + i9 * stride_[9] + i10 * stride_[10]]; + i8 * stride_[8] + i9 * stride_[9] + i10 * stride_[10]];
} }
/* /*
* Slicing to produce subarrays. If the number of Range arguments is * Slicing to produce subarrays. If the number of Range arguments is
* fewer than N_rank, then missing arguments are treated like Range::al l(). * fewer than N_rank, then missing arguments are treated like Range::al l().
*/ */
skipping to change at line 2014 skipping to change at line 2089
* array notation, e.g. * array notation, e.g.
* *
* Array<float, 2> A, B; * Array<float, 2> A, B;
* firstIndex i; * firstIndex i;
* secondIndex j; * secondIndex j;
* thirdIndex k; * thirdIndex k;
* Array<float, 3> C = A(i,j) * B(j,k); * Array<float, 3> C = A(i,j) * B(j,k);
*/ */
template<int N0> template<int N0>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0> > _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0> >
operator()(IndexPlaceholder<N0>) const operator()(IndexPlaceholder<N0>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0> > return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0> >
(noConst()); (noConst());
} }
template<int N0, int N1> template<int N0, int N1>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1> > _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>) const operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1> >(noConst()); N1> >(noConst());
} }
template<int N0, int N1, int N2> template<int N0, int N1, int N2>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2> > _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>) const IndexPlaceholder<N2>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2> >(noConst()); N1, N2> >(noConst());
} }
template<int N0, int N1, int N2, int N3> template<int N0, int N1, int N2, int N3>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3> > _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>) const IndexPlaceholder<N2>, IndexPlaceholder<N3>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3> >(noConst()); N1, N2, N3> >(noConst());
} }
template<int N0, int N1, int N2, int N3, int N4> template<int N0, int N1, int N2, int N3, int N4>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, N4> > _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3, N4> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N2>, IndexPlaceholder<N3>,
IndexPlaceholder<N4>) const IndexPlaceholder<N4>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3, N4> >(noConst()); N1, N2, N3, N4> >(noConst());
} }
template<int N0, int N1, int N2, int N3, int N4, int N5> template<int N0, int N1, int N2, int N3, int N4, int N5>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3,
N4, N5> > N4, N5> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>, IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
IndexPlaceholder<N5>) const IndexPlaceholder<N5>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3, N4, N5> >(noConst()); N1, N2, N3, N4, N5> >(noConst());
} }
template<int N0, int N1, int N2, int N3, int N4, int N5, int N6> template<int N0, int N1, int N2, int N3, int N4, int N5, int N6>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3,
N4, N5, N6> > N4, N5, N6> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>, IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
IndexPlaceholder<N5>, IndexPlaceholder<N6>) const IndexPlaceholder<N5>, IndexPlaceholder<N6>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3, N4, N5, N6> >(noConst()); N1, N2, N3, N4, N5, N6> >(noConst());
} }
template<int N0, int N1, int N2, int N3, int N4, int N5, int N6, template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
int N7> int N7>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3,
N4, N5, N6, N7> > N4, N5, N6, N7> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>, IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N5>, IndexPlaceholder<N6>,
IndexPlaceholder<N7>) const IndexPlaceholder<N7>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3, N4, N5, N6, N7> >(noConst()); N1, N2, N3, N4, N5, N6, N7> >(noConst());
} }
template<int N0, int N1, int N2, int N3, int N4, int N5, int N6, template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
int N7, int N8> int N7, int N8>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3,
N4, N5, N6, N7, N8> > N4, N5, N6, N7, N8> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>, IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>, IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>,
IndexPlaceholder<N8>) const IndexPlaceholder<N8>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3, N4, N5, N6, N7, N8> >(noConst()); N1, N2, N3, N4, N5, N6, N7, N8> >(noConst());
} }
template<int N0, int N1, int N2, int N3, int N4, int N5, int N6, template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
int N7, int N8, int N9> int N7, int N8, int N9>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3,
N4, N5, N6, N7, N8, N9> > N4, N5, N6, N7, N8, N9> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>, IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>, IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>,
IndexPlaceholder<N8>, IndexPlaceholder<N9>) const IndexPlaceholder<N8>, IndexPlaceholder<N9>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3, N4, N5, N6, N7, N8, N9> >(noConst()); N1, N2, N3, N4, N5, N6, N7, N8, N9> >(noConst());
} }
template<int N0, int N1, int N2, int N3, int N4, int N5, int N6, template<int N0, int N1, int N2, int N3, int N4, int N5, int N6,
int N7, int N8, int N9, int N10> int N7, int N8, int N9, int N10>
_bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, N1, N2, N3, _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T_expr, N0, N1, N2, N3,
N4, N5, N6, N7, N8, N9, N10> > N4, N5, N6, N7, N8, N9, N10> >
operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>, operator()(IndexPlaceholder<N0>, IndexPlaceholder<N1>,
IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>, IndexPlaceholder<N2>, IndexPlaceholder<N3>, IndexPlaceholder<N4>,
IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>, IndexPlaceholder<N5>, IndexPlaceholder<N6>, IndexPlaceholder<N7>,
IndexPlaceholder<N8>, IndexPlaceholder<N9>, IndexPlaceholder<N8>, IndexPlaceholder<N9>,
IndexPlaceholder<N10>) const IndexPlaceholder<N10>) const
{ {
return _bz_ArrayExpr<ArrayIndexMapping<T_numtype, N_rank, N0, return _bz_ArrayExpr<ArrayIndexMapping<typename asExpr<T_array >::T _expr, N0,
N1, N2, N3, N4, N5, N6, N7, N8, N9, N10> >(noConst()); N1, N2, N3, N4, N5, N6, N7, N8, N9, N10> >(noConst());
} }
////////////////////////////////////////////// //////////////////////////////////////////////
// Support for multicomponent arrays // Support for multicomponent arrays
////////////////////////////////////////////// //////////////////////////////////////////////
/* /*
* See <blitz/array/multi.h> for an explanation of the traits class * See <blitz/array/multi.h> for an explanation of the traits class
* multicomponent_traits. * multicomponent_traits.
skipping to change at line 2183 skipping to change at line 2258
operator[](const T_indexContainer& index) operator[](const T_indexContainer& index)
{ {
return IndirectArray<T_array, T_indexContainer>(*this, return IndirectArray<T_array, T_indexContainer>(*this,
const_cast<T_indexContainer&>(index)); const_cast<T_indexContainer&>(index));
} }
////////////////////////////////////////////// //////////////////////////////////////////////
// Assignment Operators // Assignment Operators
////////////////////////////////////////////// //////////////////////////////////////////////
// Scalar operand /** \name Assignment operators. \todo Index placeholder
// NEEDS_WORK : need a precondition check on operand. \todo Random operand. @{ */
// isStorageContiguous when operator, is used.
ListInitializationSwitch<T_array,T_numtype*> operator=(T_numtype x) /**
Scalar operand assignment. \todo Need a precondition check on
isStorageContiguous when operator, is used. \todo We should do
bounds checking, right now we will buffer overrun if the number
of initializers in the list is larger than numElements. */
ListInitializationSwitch<T_array> operator=(T_numtype x)
{ {
return ListInitializationSwitch<T_array,T_numtype*>(*this, x); return ListInitializationSwitch<T_array>(*this, x);
} }
T_array& initialize(T_numtype); T_array& initialize(T_numtype);
// Was: // Was:
// T_array& operator=(T_numtype); // T_array& operator=(T_numtype);
#ifdef BZ_NEW_EXPRESSION_TEMPLATES #ifdef BZ_NEW_EXPRESSION_TEMPLATES
template<typename T_expr>
T_array& operator=(const ETBase<T_expr>&);
T_array& operator=(const Array<T_numtype,N_rank>&);
template<typename T> T_array& operator+=(const T&); // we need this because we can't use default assignment op so it
template<typename T> T_array& operator-=(const T&); // must be overridden
template<typename T> T_array& operator*=(const T&); T_array& operator=(const Array<T_numtype,N_rank>&);
template<typename T> T_array& operator/=(const T&);
template<typename T> T_array& operator%=(const T&); // we can't define a generic template for the assignment operator
template<typename T> T_array& operator^=(const T&); // because it will cause the list initialization assignment above to
template<typename T> T_array& operator&=(const T&); // not work when implict conversions to T_numtype are necessary.
template<typename T> T_array& operator|=(const T&);
template<typename T> T_array& operator>>=(const T&); //template<typename T> T_array& operator=(const T&);
template<typename T> T_array& operator<<=(const T&); template<typename T_expr> T_array& operator=(const ETBase<T_expr>&);
T_array& operator+=(const T_array&);
T_array& operator-=(const T_array&);
T_array& operator*=(const T_array&);
T_array& operator/=(const T_array&);
T_array& operator%=(const T_array&);
T_array& operator^=(const T_array&);
T_array& operator&=(const T_array&);
T_array& operator|=(const T_array&);
T_array& operator>>=(const T_array&);
T_array& operator<<=(const T_array&);
T_array& operator+=(const T_numtype&);
T_array& operator-=(const T_numtype&);
T_array& operator*=(const T_numtype&);
T_array& operator/=(const T_numtype&);
T_array& operator%=(const T_numtype&);
T_array& operator^=(const T_numtype&);
T_array& operator&=(const T_numtype&);
T_array& operator|=(const T_numtype&);
T_array& operator>>=(const T_numtype&);
T_array& operator<<=(const T_numtype&);
template<typename T_expr> T_array& operator+=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator-=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator*=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator/=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator%=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator^=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator&=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator|=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator>>=(const ETBase<T_expr>&);
template<typename T_expr> T_array& operator<<=(const ETBase<T_expr>&);
#else #else
T_array& operator+=(T_numtype); T_array& operator+=(T_numtype);
T_array& operator-=(T_numtype); T_array& operator-=(T_numtype);
T_array& operator*=(T_numtype); T_array& operator*=(T_numtype);
T_array& operator/=(T_numtype); T_array& operator/=(T_numtype);
T_array& operator%=(T_numtype); T_array& operator%=(T_numtype);
T_array& operator^=(T_numtype); T_array& operator^=(T_numtype);
T_array& operator&=(T_numtype); T_array& operator&=(T_numtype);
T_array& operator|=(T_numtype); T_array& operator|=(T_numtype);
skipping to change at line 2274 skipping to change at line 2384
inline T_array& operator^=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr); inline T_array& operator^=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr);
template<typename T_expr> template<typename T_expr>
inline T_array& operator&=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr); inline T_array& operator&=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr);
template<typename T_expr> template<typename T_expr>
inline T_array& operator|=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr); inline T_array& operator|=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr);
template<typename T_expr> template<typename T_expr>
inline T_array& operator>>=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr); inline T_array& operator>>=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr);
template<typename T_expr> template<typename T_expr>
inline T_array& operator<<=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr); inline T_array& operator<<=(BZ_ETPARM(_bz_ArrayExpr<T_expr>) expr);
// NEEDS_WORK -- Index placeholder operand /// @}
// NEEDS_WORK -- Random operand
#endif #endif
public: public:
// Undocumented implementation routines
template<typename T_expr, typename T_update>
inline T_array& evaluate(T_expr expr, T_update);
#ifdef BZ_HAVE_STD
#ifdef BZ_ARRAY_SPACE_FILLING_TRAVERSAL
template<typename T_expr, typename T_update>
inline T_array& evaluateWithFastTraversal(
const TraversalOrder<N_rank - 1>& order,
T_expr expr, T_update);
#endif // BZ_ARRAY_SPACE_FILLING_TRAVERSAL
#endif
#ifdef BZ_ARRAY_2D_STENCIL_TILING
template<typename T_expr, typename T_update>
inline T_array& evaluateWithTiled2DTraversal(
T_expr expr, T_update);
#endif
template<typename T_expr, typename T_update>
inline T_array& evaluateWithIndexTraversal1(
T_expr expr, T_update);
template<typename T_expr, typename T_update>
inline T_array& evaluateWithIndexTraversalN(
T_expr expr, T_update);
template<typename T_expr, typename T_update>
inline T_array& evaluateWithStackTraversal1(
T_expr expr, T_update);
template<typename T_expr, typename T_update> T_numtype* restrict getInitializationIterator() { return dataFirst(); }
inline T_array& evaluateWithStackTraversalN( //iterator getInitializationIterator() { return begin(); }
T_expr expr, T_update);
T_numtype* restrict getInitializationIterator() { return dataFirst(); }
bool canCollapse(int outerRank, int innerRank) const { bool canCollapse(int outerRank, int innerRank) const {
#ifdef BZ_DEBUG_TRAVERSE #ifdef BZ_DEBUG_TRAVERSE
BZ_DEBUG_MESSAGE("stride(" << innerRank << ")=" << stride(innerRank ) BZ_DEBUG_MESSAGE("stride(" << innerRank << ")=" << stride(innerRank )
<< ", extent()=" << extent(innerRank) << ", stride(outerRank)=" << ", extent()=" << extent(innerRank) << ", stride(outerRank)="
<< stride(outerRank)); << stride(outerRank));
#endif #endif
return (stride(innerRank) * extent(innerRank) == stride(outerRank)) ; return (stride(innerRank) * extent(innerRank) == stride(outerRank)) ;
} }
skipping to change at line 2385 skipping to change at line 2460
void slice(int& setRank, int i, Array<T_numtype,N_rank2>& array, void slice(int& setRank, int i, Array<T_numtype,N_rank2>& array,
TinyVector<int,N_rank2>& rankMap, int sourceRank); TinyVector<int,N_rank2>& rankMap, int sourceRank);
template<int N_rank2> template<int N_rank2>
void slice(int&, nilArraySection, Array<T_numtype,N_rank2>&, void slice(int&, nilArraySection, Array<T_numtype,N_rank2>&,
TinyVector<int,N_rank2>&, int) TinyVector<int,N_rank2>&, int)
{ } { }
void doTranspose(int destRank, int sourceRank, T_array& array); void doTranspose(int destRank, int sourceRank, T_array& array);
private:
// serialization support
#ifdef BZ_HAVE_BOOST_SERIALIZATION
friend class boost::serialization::access;
template<class T_arch>
void serialize(T_arch& ar, const unsigned int version) {
ar & boost::serialization::base_object<MemoryBlockReference<P_numtype
> >(*this);
ar & length_;
ar & storage_;
ar & stride_;
ar & zeroOffset_;
};
#endif
protected: protected:
////////////////////////////////////////////// //////////////////////////////////////////////
// Data members // Data members
////////////////////////////////////////////// //////////////////////////////////////////////
// NB: adding new data members may require changes to ctors, reference( ) // NB: adding new data members may require changes to ctors, reference( )
/* /*
* For a description of the storage_ members, see the comments for clas s * For a description of the storage_ members, see the comments for clas s
* GeneralArrayStorage<N_rank> above. * GeneralArrayStorage<N_rank> above.
skipping to change at line 2409 skipping to change at line 2499
* rank. * rank.
* zeroOffset_ is the distance from the first element in the array * zeroOffset_ is the distance from the first element in the array
* to the point (0,0,...,0). If base_ is zero and all ranks are * to the point (0,0,...,0). If base_ is zero and all ranks are
* stored ascending, then zeroOffset_ is zero. This value * stored ascending, then zeroOffset_ is zero. This value
* is needed because to speed up indexing, the data_ member * is needed because to speed up indexing, the data_ member
* (inherited from MemoryBlockReference) always refers to * (inherited from MemoryBlockReference) always refers to
* (0,0,...,0). * (0,0,...,0).
*/ */
GeneralArrayStorage<N_rank> storage_; GeneralArrayStorage<N_rank> storage_;
TinyVector<int, N_rank> length_; TinyVector<int, N_rank> length_;
TinyVector<int, N_rank> stride_; TinyVector<diffType, N_rank> stride_;
int zeroOffset_; diffType zeroOffset_;
}; };
/* /*
* Rank numbers start with zero, which may be confusing to users coming
* from Fortran. To make code more readable, the following constants
* may help. Example: instead of
*
* int firstRankExtent = A.extent(0);
*
* One can write:
*
* int firstRankExtent = A.extent(firstRank);
*/
const int firstRank = 0;
const int secondRank = 1;
const int thirdRank = 2;
const int fourthRank = 3;
const int fifthRank = 4;
const int sixthRank = 5;
const int seventhRank = 6;
const int eighthRank = 7;
const int ninthRank = 8;
const int tenthRank = 9;
const int eleventhRank = 10;
const int firstDim = 0;
const int secondDim = 1;
const int thirdDim = 2;
const int fourthDim = 3;
const int fifthDim = 4;
const int sixthDim = 5;
const int seventhDim = 6;
const int eighthDim = 7;
const int ninthDim = 8;
const int tenthDim = 9;
const int eleventhDim = 10;
/*
* Global Functions * Global Functions
*/ */
template<typename T_numtype> template<typename T_numtype>
ostream& operator<<(ostream&, const Array<T_numtype,1>&); ostream& operator<<(ostream&, const Array<T_numtype,1>&);
template<typename T_numtype>
ostream& operator<<(ostream&, const Array<T_numtype,2>&);
template<typename T_numtype, int N_rank> template<typename T_numtype, int N_rank>
ostream& operator<<(ostream&, const Array<T_numtype,N_rank>&); ostream& operator<<(ostream&, const Array<T_numtype,N_rank>&);
template<typename T_numtype, int N_rank> template<typename T_numtype, int N_rank>
istream& operator>>(istream& is, Array<T_numtype,N_rank>& x); istream& operator>>(istream& is, Array<T_numtype,N_rank>& x);
template <typename P_numtype,int N_rank> template <typename P_numtype,int N_rank>
void swap(Array<P_numtype,N_rank>& a,Array<P_numtype,N_rank>& b) { void swap(Array<P_numtype,N_rank>& a,Array<P_numtype,N_rank>& b) {
Array<P_numtype,N_rank> c(a); Array<P_numtype,N_rank> c(a);
a.reference(b); a.reference(b);
skipping to change at line 2498 skipping to change at line 2549
if (j) if (j)
indices.resizeAndPreserve(j); indices.resizeAndPreserve(j);
else else
indices.free(); indices.free();
return; return;
} }
BZ_NAMESPACE_END BZ_NAMESPACE_END
/* /*
* Include implementations of the member functions and some additional * Removed the "kitchen-sink inclusion" here because it made
* global functions. * dependencies very difficult to figure out.
*/ */
#include <blitz/array.cc>
#include <blitz/array/iter.h> // Array iterators #include <blitz/tinyvec2.cc>
#include <blitz/array/fastiter.h> // Fast Array iterators (for et)
#include <blitz/array/expr.h> // Array expression objects
#include <blitz/array/methods.cc> // Member functions
#include <blitz/array/eval.cc> // Array expression evaluation
#include <blitz/array/ops.cc> // Assignment operators
#include <blitz/array/io.cc> // Output formatting
#include <blitz/array/et.h> // Expression templates
#include <blitz/array/reduce.h> // Array reduction expression templates
#include <blitz/array/interlace.cc> // Allocation of interlaced arrays
#include <blitz/array/resize.cc> // Array resize, resizeAndPreserve
#include <blitz/array/slicing.cc> // Slicing and subarrays
#include <blitz/array/cycle.cc> // Cycling arrays
#include <blitz/array/complex.cc> // Special support for complex arrays
#include <blitz/array/zip.h> // Zipping multicomponent types
#include <blitz/array/where.h> // where(X,Y,Z)
#include <blitz/array/indirect.h> // Indirection
#include <blitz/array/stencils.h> // Stencil objects
#endif // BZ_ARRAY_H #endif // BZ_ARRAY_H
 End of changes. 165 change blocks. 
376 lines changed or deleted 410 lines changed or added


 array.h   array.h 
/************************************************************************** * /************************************************************************** *
* blitz/array.h Minimal include version of Array<T,N> * blitz/array.h Minimal include version of Array<T,N>
* *
* $Id: array.h,v 1.6 2003/01/14 11:29:18 patricg Exp $ * $Id$
* *
* Copyright (C) 1997-2000 Todd Veldhuizen <tveldhui@oonumerics.org> * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* *
* This program is free software; you can redistribute it and/or * This file is a part of Blitz.
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_ARRAY_ONLY_H #ifndef BZ_ARRAY_ONLY_H
#define BZ_ARRAY_ONLY_H #define BZ_ARRAY_ONLY_H
// See comments in <blitz/array-old.h> for an explanation of the new // See comments in <blitz/array-old.h> for an explanation of the new
// headers arrangement. // headers arrangement.
#include <blitz/array-impl.h> #include <blitz/array-impl.h>
 End of changes. 7 change blocks. 
10 lines changed or deleted 15 lines changed or added


 asexpr.h   asexpr.h 
// -*- C++ -*- // -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array/asexpr.h Declaration of the asExpr helper functions * blitz/array/asexpr.h Declaration of the asExpr helper functions
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_ARRAYASEXPR_H #ifndef BZ_ASEXPR_H
#define BZ_ARRAYASEXPR_H #define BZ_ASEXPR_H
#ifndef BZ_ARRAY_H #include <blitz/et-forward.h>
#error <blitz/array/asexpr.h> must be included via <blitz/array.h> #include <blitz/numtrait.h>
#endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
// The traits class asExpr converts arbitrary things to // The traits class asExpr converts arbitrary things to
// expression templatable operands. // expression templatable operands.
// Default to scalar. // Default to scalar.
template <typename T> template <typename T>
struct asExpr { struct asExpr {
typedef _bz_ArrayExprConstant<T> T_expr; typedef _bz_ArrayExpr<_bz_ArrayExprConstant<T> > T_expr;
static T_expr getExpr(const T& x) { return T_expr(x); } static T_expr getExpr(const T& x);
}; };
// Already an expression template term // Already an expression template term
template <typename T> template <typename T>
struct asExpr<_bz_ArrayExpr<T> > { struct asExpr<_bz_ArrayExpr<T> > {
typedef _bz_ArrayExpr<T> T_expr; typedef _bz_ArrayExpr<T> T_expr;
static const T_expr& getExpr(const T_expr& x) { return x; } static const T_expr& getExpr(const T_expr& x);
}; };
// An array operand // Specialization of asExpr for array operands
// why doesn't it wrap iterators in an ArrayExpr?
template <typename T,int N> template <typename T,int N>
struct asExpr<Array<T,N> > { struct asExpr<Array<T,N> > {
typedef FastArrayIterator<T,N> T_expr; //typedef FastArrayIterator<T,N> T_expr;
static T_expr getExpr(const Array<T,N>& x) { return x.beginFast(); } typedef _bz_ArrayExpr<FastArrayIterator<T,N> > T_expr;
static T_expr getExpr(const Array<T,N>& x);
}; };
// Index placeholder // Specialization of asExpr for tinyvector operands
template <typename T,int N>
struct asExpr<TinyVector<T,N> > {
typedef _bz_ArrayExpr<FastTV2Iterator<T,N> > T_expr;
static T_expr getExpr(const TinyVector<T,N>& x);
};
// Specialization of asExpr for tinymatrix operands
template <typename T,int Nr, int Nc>
struct asExpr<TinyMatrix<T,Nr, Nc> > {
typedef _bz_ArrayExpr<FastTM2Iterator<T,Nr, Nc> > T_expr;
static T_expr getExpr(const TinyMatrix<T,Nr,Nc>& x);
};
// Index placeholder
template <int N> template <int N>
struct asExpr<IndexPlaceholder<N> > { struct asExpr<IndexPlaceholder<N> > {
typedef IndexPlaceholder<N> T_expr; // typedef _bz_ArrayExpr<IndexPlaceholder<N> > T_expr;
static T_expr getExpr(T_expr x) { return x; } typedef _bz_ArrayExpr<IndexPlaceholder<N> > T_expr;
static T_expr getExpr(const T_expr& x);
};
// the levi-civita symbol
template <>
struct asExpr<LeviCivita> {
typedef _bz_ArrayExpr<LeviCivita> T_expr;
static T_expr getExpr(T_expr x);
};
// Range
template <>
struct asExpr<Range> {
typedef _bz_ArrayExpr<Range> T_expr;
static T_expr getExpr(T_expr x);
};
// traits class that transforms ETBase subclasses into the
// ET<>-wrapped superclass and corresponding expression, but unlike
// the asExpr class it leaves POD types alone. This is necessary so
// operators on multicomponent arrays can resolve properly.
template<typename T>
struct asET {
typedef T T_wrapped;
typedef T T_expr;
};
template<typename T>
struct asET<ETBase<T> > {
typedef ETBase<typename asExpr<T>::T_expr> T_wrapped;
typedef typename asExpr<T>::T_expr T_expr;
};
template<typename T, int N>
struct asET<Array<T,N> > {
typedef ETBase<typename asExpr<Array<T,N> >::T_expr> T_wrapped;
typedef typename asExpr<Array<T,N> >::T_expr T_expr;
};
template<typename T, int N>
struct asET<TinyVector<T,N> > {
typedef ETBase<typename asExpr<TinyVector<T,N> >::T_expr> T_wrapped;
typedef typename asExpr<TinyVector<T,N> >::T_expr T_expr;
};
template<typename T, int Nr, int Nc>
struct asET<TinyMatrix<T,Nr,Nc> > {
typedef ETBase<typename asExpr<TinyMatrix<T,Nr,Nc> >::T_expr> T_wrapped;
typedef typename asExpr<TinyMatrix<T,Nr,Nc> >::T_expr T_expr;
};
// traits class that unwraps an ETBase type, otherwise leaves it untouched.
template<typename T>
struct unwrapET {
typedef T T_unwrapped;
};
template<typename T>
struct unwrapET<ETBase<T> > {
typedef T T_unwrapped;
};
// traits classes that are used to switch between an ET type or an
// unknown type. If the supplied type T is an ET type, T_selected will
// be T_ifET, otherwise T.
template<typename T, typename T_ifnotET, typename T_ifET>
struct selectET {
typedef T_ifnotET T_selected;
};
template<typename T, typename T_ifnotET, typename T_ifET>
struct selectET<ETBase<T>, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
// for binary exprs, it is more complicated. if T1 or T2 are an ET,
// T_ifET is selected, otherwise T_ifnotET.
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2 {
typedef T_ifnotET T_selected;
};
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2<ETBase<T1>, T2, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2<T1, ETBase<T2>, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
template<typename T1, typename T2, typename T_ifnotET, typename T_ifET>
struct selectET2<ETBase<T1>, ETBase<T2>, T_ifnotET, T_ifET> {
typedef ETBase<T_ifET> T_selected;
};
// traits class that resolves to the ultimate numeric datatype used
// for operations on the container. This is necessary because for
// multicomponent containers we need to determine what the ultimate
// POD data type is.
template<typename T>
struct opType {
typedef T T_optype;
};
template<typename T>
struct opType<ETBase<T> > {
typedef typename opType<T>::T_optype T_optype;
};
template<typename T, int N>
struct opType<Array<T,N> > {
typedef typename opType<T>::T_optype T_optype;
};
template<typename T, int N>
struct opType<TinyVector<T,N> > {
typedef typename opType<T>::T_optype T_optype;
};
template<typename T, int Nr, int Nc>
struct opType<TinyMatrix<T,Nr,Nc> > {
typedef typename opType<T>::T_optype T_optype;
}; };
#ifdef BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS #ifdef BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS
// A traits class that provides the return type of a binary operation. // traits classes that provide the return type of operations
template <template <typename T1> class OP, typename O1> template <template <typename T1> class OP, typename O1>
struct BzUnaryExprResult { struct BzUnaryExprResult {
typedef _bz_ArrayExpr<_bz_ArrayExprUnaryOp< typedef _bz_ArrayExpr<
typename asExpr<O1>::T_expr, _bz_ArrayExprUnaryOp<
OP<typename asExpr<O1>::T_expr::T_numtype> > > T_result; typename asExpr<O1>::T_expr,
OP<
typename asExpr<O1>::T_expr::T_optype
>
> > T_result;
}; };
template <template <typename T1, typename T2> class OP, template <template <typename T1, typename T2> class OP,
typename O1, typename O2> typename O1, typename O2>
struct BzBinaryExprResult { struct BzBinaryExprResult {
typedef _bz_ArrayExpr<_bz_ArrayExprBinaryOp< typedef _bz_ArrayExpr<_bz_ArrayExprBinaryOp<
typename asExpr<O1>::T_expr, typename asExpr<O1>::T_expr,
typename asExpr<O2>::T_expr, typename asExpr<O2>::T_expr,
OP<typename asExpr<O1>::T_expr::T_numtype, OP<
typename asExpr<O2>::T_expr::T_numtype> > > T_result; typename asExpr<O1>::T_expr::T_optype,
typename asExpr<O2>::T_expr::T_optype
> > > T_result;
}; };
template <template <typename T1, typename T2, typename T3> class OP, template <template <typename T1, typename T2, typename T3> class OP,
typename O1, typename O2, typename O3> typename O1, typename O2, typename O3>
struct BzTernaryExprResult { struct BzTernaryExprResult {
typedef _bz_ArrayExpr<_bz_ArrayExprTernaryOp< typedef _bz_ArrayExpr<_bz_ArrayExprTernaryOp<
typename asExpr<O1>::T_expr, typename asExpr<O1>::T_expr,
typename asExpr<O2>::T_expr, typename asExpr<O2>::T_expr,
typename asExpr<O3>::T_expr, typename asExpr<O3>::T_expr,
OP<typename asExpr<O1>::T_expr::T_numtype, OP<
typename asExpr<O2>::T_expr::T_numtype, typename asExpr<O1>::T_expr::T_optype,
typename asExpr<O3>::T_expr::T_numtype> > > T_result; typename asExpr<O2>::T_expr::T_optype,
typename asExpr<O3>::T_expr::T_optype
> > > T_result;
};
template <template <typename T1, typename T2, typename T3, typename T4> cla
ss OP,
typename O1, typename O2, typename O3, typename O4>
struct BzQuaternaryExprResult {
typedef _bz_ArrayExpr<_bz_ArrayExprQuaternaryOp<
typename asExpr<O1>::T_expr,
typename asExpr<O2>::T_expr,
typename asExpr<O3>::T_expr,
typename asExpr<O4>::T_expr,
OP<
typename asExpr<O1>::T_expr::T_optype,
typename asExpr<O2>::T_expr::T_optype,
typename asExpr<O3>::T_expr::T_optype,
typename asExpr<O4>::T_expr::T_optype
> > > T_result;
};
template <template <typename T1, typename T2> class RED, int N, typename O1
,
typename P_result = BZ_SUMTYPE(typename asExpr<O1>::T_expr::T_opty
pe)>
struct BzReductionResult {
typedef _bz_ArrayExpr<
_bz_ArrayExprReduce<
typename asExpr<O1>::T_expr,
N,
RED<typename asExpr<O1>::T_expr::T_optype, P_result>
> > T_result;
};
template<typename O1, int N0, int N1=0, int N2=0, int N3=0, int N4=0,
int N5=0, int N6=0, int N7=0, int N8=0, int N9=0, int N10=0>
struct BzIndexmapResult {
typedef _bz_ArrayExpr<
ArrayIndexMapping<
typename asExpr<O1>::T_expr,
N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, N10
>
> T_result;
};
template<template <typename T> class STENCIL, typename O1>
struct BzStencilResult {
typedef _bz_ArrayExpr<
STENCIL<
typename asExpr<O1>::T_expr::T_range_result
>
> T_result;
};
template<template <typename T1, typename T2, typename T3> class STENCIL,
typename O1, typename O2, typename P_result>
struct BzBinaryStencilResult {
typedef _bz_ArrayExpr<
STENCIL<
typename asExpr<O1>::T_expr::T_range_result,
typename asExpr<O2>::T_expr::T_range_result,
P_result
> > T_result;
}; };
#endif /* BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS */ #endif /* BZ_HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS */
BZ_NAMESPACE_END BZ_NAMESPACE_END
#endif #endif
 End of changes. 21 change blocks. 
35 lines changed or deleted 233 lines changed or added


 bench.cc   bench.cc 
/* /**************************************************************************
* Copyright (C) 1997 Todd Veldhuizen <tveldhui@oonumerics.org> *
* All rights reserved. Please see <blitz/blitz.h> for terms and * blitz/bench.cc Benchmarking class methods.
* conditions of use.
* *
*/ * $Id$
*
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
*
* This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
*
* For more information, please see the Blitz++ Home Page:
* https://sourceforge.net/projects/blitz/
*
**************************************************************************
**/
#ifndef BZ_BENCH_CC #ifndef BZ_BENCH_CC
#define BZ_BENCH_CC #define BZ_BENCH_CC
#ifndef BZ_BENCH_H #ifndef BZ_BENCH_H
#error <blitz/bench.cc> must be included via <blitz/bench.h> #error <blitz/bench.cc> must be included via <blitz/bench.h>
#endif #endif
#ifdef BZ_HAVE_STD #ifdef BZ_HAVE_STD
#include <fstream> #include <fstream>
#include <string>
#else #else
#include <fstream.h> #include <fstream.h>
#include <string.h>
#endif #endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
template<typename P_parameter> template<typename P_parameter>
Benchmark<P_parameter>::Benchmark(unsigned numImplementations) Benchmark<P_parameter>::Benchmark(unsigned numImplementations)
{ {
state_ = uninitialized; state_ = uninitialized;
numImplementations_ = numImplementations; numImplementations_ = numImplementations;
numStoredImplementations_ = 0; numStoredImplementations_ = 0;
skipping to change at line 132 skipping to change at line 156
BZPRECONDITION(setting < numParameterSettings()); BZPRECONDITION(setting < numParameterSettings());
return rates_(implementation, setting); return rates_(implementation, setting);
} }
template<typename P_parameter> template<typename P_parameter>
void Benchmark<P_parameter>::saveMatlabGraph(const char* filename) const void Benchmark<P_parameter>::saveMatlabGraph(const char* filename) const
{ {
BZPRECONDITION(state_ == done); BZPRECONDITION(state_ == done);
{
//ugly but saveMatlabGraph is coded into all benchmarks
std::string pyfn(filename);
pyfn=pyfn.replace(pyfn.find(".m"),2,std::string(".py"),0,3);
savePylabGraph(pyfn.c_str());
}
ofstream ofs(filename); ofstream ofs(filename);
assert(ofs.good()); assert(ofs.good());
ofs << "% This matlab file generated automatically by class Benchmark" ofs << "% This matlab file generated automatically by class Benchmark"
<< endl << "% of the Blitz++ class library." << endl << endl; << endl << "% of the Blitz++ class library." << endl << endl;
ofs.setf(ios::scientific); ofs.setf(ios::scientific);
ofs << "parm = [ "; ofs << "parm = [ ";
skipping to change at line 175 skipping to change at line 206
{ {
ofs << "'" << implementations_[j]->implementationName() ofs << "'" << implementations_[j]->implementationName()
<< "'"; << "'";
if (j != numImplementations_ - 1) if (j != numImplementations_ - 1)
ofs << ", "; ofs << ", ";
} }
ofs << ")" << endl; ofs << ")" << endl;
} }
template<typename P_parameter>
void Benchmark<P_parameter>::savePylabGraph(const char* filename) const
{
BZPRECONDITION(state_ == done);
ofstream ofs(filename);
assert(ofs.good());
ofs << "# This python file generated automatically by class Benchmark\n
"
<< "# of the Blitz++ class library.\n"
<< "from pylab import *\nfrom numpy import *\n"
<< "clf()\n";
ofs.setf(ios::scientific);
ofs << "parm = array([ ";
int i;
for (i=0; i < numParameterSettings(); ++i)
ofs << setprecision(12) << double(getParameterSetting(i)) << ", ";
ofs << "])\n\n";
ofs << "Mf = array([[ ";
for (i=0; i < numParameterSettings(); ++i)
{
if(i>0) ofs << ", [ ";
for (int j=0; j < numImplementations_; ++j)
{
ofs << setprecision(12) << getMflops(j,i) << ", ";
}
ofs << "]";
}
ofs << "])" << endl << endl;
ofs << "semilogx(parm,Mf)\ntitle('" << description() << "')\n"
<< "xlabel('" << parameterDescription() << "')\n"
<< "ylabel('Mflops')\n";
<< "legend([";
for (int j=0; j < numImplementations_; ++j)
{
ofs << "'" << implementations_[j]->implementationName()
<< "'";
if (j != numImplementations_ - 1)
ofs << ", ";
}
ofs << "])\n";
}
BZ_NAMESPACE_END BZ_NAMESPACE_END
#endif // BZ_BENCH_CC #endif // BZ_BENCH_CC
 End of changes. 6 change blocks. 
7 lines changed or deleted 91 lines changed or added


 bench.h   bench.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/bench.h Benchmark classes * blitz/bench.h Benchmark classes
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_BENCH_H #ifndef BZ_BENCH_H
#define BZ_BENCH_H #define BZ_BENCH_H
#ifndef BZ_MATRIX_H #include <blitz/matrix.h>
#include <blitz/matrix.h> #include <blitz/timer.h>
#endif
#ifndef BZ_TIMER_H
#include <blitz/timer.h>
#endif
#if defined(BZ_HAVE_STD)
#include <cmath>
#else
#include <math.h> #include <math.h>
#endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
// Forward declaration // Forward declaration
template<typename P_parameter = unsigned> template<typename P_parameter = unsigned>
class BenchmarkImplementation; class BenchmarkImplementation;
// Declaration of class Benchmark<T> // Declaration of class Benchmark<T>
// The template parameter T is the parameter type which is varied in // The template parameter T is the parameter type which is varied in
// the benchmark. Typically T will be an unsigned, and will represent // the benchmark. Typically T will be an unsigned, and will represent
skipping to change at line 68 skipping to change at line 75
void addImplementation(BenchmarkImplementation<T_parameter>* void addImplementation(BenchmarkImplementation<T_parameter>*
implementation); implementation);
void run(ostream& log = cout); void run(ostream& log = cout);
double getMflops(unsigned implementation, unsigned setting) const; double getMflops(unsigned implementation, unsigned setting) const;
double getRate(unsigned implementation, unsigned setting) const; double getRate(unsigned implementation, unsigned setting) const;
void saveMatlabGraph(const char* filename) const; void saveMatlabGraph(const char* filename) const;
void savePylabGraph(const char* filename) const;
public: public:
// Virtual functions // Virtual functions
virtual const char* description() const virtual const char* description() const
{ return ""; } { return ""; }
virtual const char* parameterDescription() const virtual const char* parameterDescription() const
{ return "Vector length"; } { return "Vector length"; }
virtual unsigned numParameterSettings() const virtual unsigned numParameterSettings() const
{ return 19; } { return 19; }
virtual T_parameter getParameterSetting(unsigned i) const virtual T_parameter getParameterSetting(unsigned i) const
{ return ::pow(10.0, (i+1)/4.0); } { return BZ_MATHFN_SCOPE(pow)(10.0, (i+1)/4.0); }
virtual long getIterationSetting(unsigned i) const virtual long getIterationSetting(unsigned i) const
{ return 1000000L / getParameterSetting(i); } { return 1000000L / getParameterSetting(i); }
private: private:
Benchmark(const Benchmark<P_parameter>&) { } Benchmark(const Benchmark<P_parameter>&) { }
void operator=(const Benchmark<P_parameter>&) { } void operator=(const Benchmark<P_parameter>&) { }
enum { uninitialized, initialized, running, done } state_; enum { uninitialized, initialized, running, done } state_;
 End of changes. 12 change blocks. 
17 lines changed or deleted 25 lines changed or added


 benchext.cc   benchext.cc 
/* /**************************************************************************
* Copyright (C) 1997 Todd Veldhuizen <tveldhui@oonumerics.org> *
* All rights reserved. Please see <blitz/blitz.h> for terms and * blitz/benchext.cc Methods for Benchmarking class with external control.
* conditions of use.
* *
*/ * $Id$
*
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
*
* This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
*
* For more information, please see the Blitz++ Home Page:
* https://sourceforge.net/projects/blitz/
*
**************************************************************************
**/
#ifndef BZ_BENCHEXT_CC #ifndef BZ_BENCHEXT_CC
#define BZ_BENCHEXT_CC #define BZ_BENCHEXT_CC
#ifndef BZ_BENCHEXT_H #ifndef BZ_BENCHEXT_H
#error <blitz/benchext.cc> must be included via <blitz/benchext.h> #error <blitz/benchext.cc> must be included via <blitz/benchext.h>
#endif #endif
#include <blitz/vector-et.h> //#include <blitz/vector-et.h>
#ifdef BZ_HAVE_STD #ifdef BZ_HAVE_STD
#include <fstream> #include <fstream>
#include <string>
#else #else
#include <fstream.h> #include <fstream.h>
#include <string.h>
#endif #endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
template<typename P_parameter> template<typename P_parameter>
BenchmarkExt<P_parameter>::BenchmarkExt(const char* name, BenchmarkExt<P_parameter>::BenchmarkExt(const char* name,
int numImplementations) int numImplementations)
{ {
BZPRECONDITION(numImplementations > 0); BZPRECONDITION(numImplementations > 0);
description_ = name; description_ = name;
numImplementations_ = numImplementations; numImplementations_ = numImplementations;
implementationDescriptions_.resize(numImplementations); implementationDescriptions_.resize(numImplementations);
parameterDescription_ = "Vector length"; parameterDescription_ = "Vector length";
rateDescription_ = "Mflops/s";
// we don't really know this is the default, do we...
setDependentVariable("flops");
/*
// Set up default parameters and iterations // Set up default parameters and iterations
setNumParameters(19); setNumParameters(19);
// NEEDS_WORK: once pow(X,Y) is supported, can just say // NEEDS_WORK: once pow(X,Y) is supported, can just say
// parameters_ = pow(10.0, Range(1,20)/4.0); // parameters_ = pow(10.0, Range(1,20)/4.0);
for (unsigned i=0; i < numParameters_; ++i) for (unsigned i=0; i < numParameters_; ++i)
parameters_[i] = (P_parameter)::pow(10.0, (i+1)/4.0); parameters_(i) = static_cast<P_parameter>(BZ_MATHFN_SCOPE(pow)(10.0, (i+1)/4.0));
iterations_ = 5.0e+5 / parameters_; iterations_ = 5.0e+5 / parameters_;
flopsPerIteration_ = parameters_; flopsPerIteration_ = parameters_;
*/
// Set up initial state // Set up initial state
state_ = initializing; state_ = initializing;
implementationNumber_ = 0; implementationNumber_ = 0;
} }
template<typename P_parameter> template<typename P_parameter>
BenchmarkExt<P_parameter>::~BenchmarkExt() BenchmarkExt<P_parameter>::~BenchmarkExt()
{ {
} }
skipping to change at line 73 skipping to change at line 100
//BZPRECONDITION(state_ == initializing); //BZPRECONDITION(state_ == initializing);
numParameters_ = numParameters; numParameters_ = numParameters;
parameters_.resize(numParameters_); parameters_.resize(numParameters_);
iterations_.resize(numParameters_); iterations_.resize(numParameters_);
flopsPerIteration_.resize(numParameters_); flopsPerIteration_.resize(numParameters_);
// Set up timer and Mflops array // Set up timer and Mflops array
times_.resize(numImplementations_, numParameters_); times_.resize(numImplementations_, numParameters_);
instr_.resize(numImplementations_, numParameters_);
flops_.resize(numImplementations_, numParameters_);
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::setParameterVector(Vector<P_parameter> parm s) void BenchmarkExt<P_parameter>::setParameterVector(Array<P_parameter,1> par ms)
{ {
BZPRECONDITION(state_ == initializing); BZPRECONDITION(state_ == initializing);
BZPRECONDITION(parms.length() == parameters_.length()); BZPRECONDITION(parms.size() == parameters_.size());
// NEEDS_WORK: should use operator=(), once that problem parameters_ = parms;
// gets sorted out.
// parameters_ = parms;
for (int i=0; i < parameters_.length(); ++i)
parameters_[i] = parms(i);
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::setParameterDescription(const char* string) void BenchmarkExt<P_parameter>::setParameterDescription(const char* string)
{ {
parameterDescription_ = string; parameterDescription_ = string;
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::setIterations(Vector<long> iters) void BenchmarkExt<P_parameter>::setIterations(Array<long,1> iters)
{ {
BZPRECONDITION(state_ == initializing); BZPRECONDITION(state_ == initializing);
// NEEDS_WORK: should use operator=(), once that problem iterations_ = iters;
// gets sorted out.
// iterations_ = iters;
for (int i=0; i < iterations_.length(); ++i)
iterations_[i] = iters(i);
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::setFlopsPerIteration(Vector<double> void BenchmarkExt<P_parameter>::setOpsPerIteration(Array<double,1>
flopsPerIteration) flopsPerIteration)
{ {
BZPRECONDITION(flopsPerIteration_.length() == flopsPerIteration.length( BZPRECONDITION(flopsPerIteration_.size() == flopsPerIteration.size());
));
// NEEDS_WORK: should use operator=(), once that problem
// gets sorted out.
// flopsPerIteration_ = flopsPerIteration;
for (int i=0; i < flopsPerIteration_.length(); ++i) flopsPerIteration_ = flopsPerIteration;
flopsPerIteration_[i] = flopsPerIteration[i];
} }
/** Set the dependent variable of the measurements. If the independent
variable is seconds, we output "G<dvar>/s", if it is cycles, we
output "<dvar/c". */
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::setRateDescription(const char* string) void BenchmarkExt<P_parameter>::setDependentVariable(const char* dvar)
{ {
rateDescription_ = string; BZPRECONDITION(Timer::indep_var()!="");
if(timer_.indep_var()=="s") {
depvar_ = string("G")+dvar+"/s";
timerconversion_ = 1./1e9;
}
else if(timer_.indep_var()=="c") {
depvar_ = string(dvar)+"/c";
timerconversion_ = 1.;
}
else {
depvar_ = std::string(dvar)+"/"+timer_.indep_var();
timerconversion_ = 1;
}
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::beginBenchmarking() void BenchmarkExt<P_parameter>::beginBenchmarking()
{ {
BZPRECONDITION(state_ == initializing); BZPRECONDITION(state_ == initializing);
state_ = benchmarking; state_ = benchmarking;
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::beginImplementation(const char* description ) void BenchmarkExt<P_parameter>::beginImplementation(const char* description )
{ {
// it would really be better if it worked for as many as we give it
BZPRECONDITION(implementationNumber_ < numImplementations_); BZPRECONDITION(implementationNumber_ < numImplementations_);
BZPRECONDITION(state_ == benchmarking); BZPRECONDITION(state_ == benchmarking);
implementationDescriptions_[implementationNumber_] = description; implementationDescriptions_[implementationNumber_] = description;
state_ = benchmarkingImplementation; state_ = benchmarkingImplementation;
parameterNumber_ = 0; parameterNumber_ = 0;
} }
template<typename P_parameter> template<typename P_parameter>
bool BenchmarkExt<P_parameter>::doneImplementationBenchmark() const bool BenchmarkExt<P_parameter>::doneImplementationBenchmark() const
{ {
BZPRECONDITION(state_ == benchmarkingImplementation); BZPRECONDITION(state_ == benchmarkingImplementation);
return parameterNumber_ == numParameters_; return parameterNumber_ == numParameters_;
} }
template<typename P_parameter> template<typename P_parameter>
const string& BenchmarkExt<P_parameter>::currentImplementation() const
{
BZPRECONDITION(implementationNumber_ < numImplementations_);
return implementationDescriptions_[implementationNumber_];
}
template<typename P_parameter>
P_parameter BenchmarkExt<P_parameter>::getParameter() const P_parameter BenchmarkExt<P_parameter>::getParameter() const
{ {
BZPRECONDITION(state_ == benchmarkingImplementation); BZPRECONDITION(state_ == benchmarkingImplementation);
BZPRECONDITION(parameterNumber_ < numParameters_); BZPRECONDITION(parameterNumber_ < numParameters_);
return parameters_[parameterNumber_]; return parameters_(parameterNumber_);
} }
template<typename P_parameter> template<typename P_parameter>
long BenchmarkExt<P_parameter>::getIterations() const long BenchmarkExt<P_parameter>::getIterations() const
{ {
BZPRECONDITION(state_ == benchmarkingImplementation); BZPRECONDITION(state_ == benchmarkingImplementation);
BZPRECONDITION(parameterNumber_ < numParameters_); BZPRECONDITION(parameterNumber_ < numParameters_);
return iterations_[parameterNumber_]; return iterations_(parameterNumber_);
} }
template<typename P_parameter> template<typename P_parameter>
inline void BenchmarkExt<P_parameter>::start() inline void BenchmarkExt<P_parameter>::start()
{ {
BZPRECONDITION(state_ == benchmarkingImplementation); BZPRECONDITION(state_ == benchmarkingImplementation);
BZPRECONDITION(parameterNumber_ < numParameters_); BZPRECONDITION(parameterNumber_ < numParameters_);
state_ = running; state_ = running;
timer_.start(); timer_.start();
} }
template<typename P_parameter> template<typename P_parameter>
inline void BenchmarkExt<P_parameter>::stop() inline void BenchmarkExt<P_parameter>::stop()
{ {
timer_.stop(); timer_.stop();
BZPRECONDITION(state_ == running); BZPRECONDITION(state_ == running);
state_ = benchmarkingImplementation; state_ = benchmarkingImplementation;
times_(implementationNumber_, parameterNumber_) = timer_.elapsedSeconds times_(int(implementationNumber_), int(parameterNumber_)) = timer_.elap
(); sed();
instr_(int(implementationNumber_), int(parameterNumber_)) = timer_.inst
r();
flops_(int(implementationNumber_), int(parameterNumber_)) = timer_.flop
s();
++parameterNumber_; ++parameterNumber_;
} }
template<typename P_parameter> template<typename P_parameter>
inline void BenchmarkExt<P_parameter>::startOverhead() inline void BenchmarkExt<P_parameter>::startOverhead()
{ {
BZPRECONDITION(state_ == benchmarkingImplementation); BZPRECONDITION(state_ == benchmarkingImplementation);
BZPRECONDITION(parameterNumber_ > 0); BZPRECONDITION(parameterNumber_ > 0);
BZPRECONDITION(parameterNumber_ <= numParameters_); BZPRECONDITION(parameterNumber_ <= numParameters_);
state_ = runningOverhead; state_ = runningOverhead;
overheadTimer_.start(); timer_.start();
} }
template<typename P_parameter> template<typename P_parameter>
inline void BenchmarkExt<P_parameter>::stopOverhead() inline void BenchmarkExt<P_parameter>::stopOverhead()
{ {
BZPRECONDITION(state_ == runningOverhead); BZPRECONDITION(state_ == runningOverhead);
overheadTimer_.stop(); timer_.stop();
times_(implementationNumber_, parameterNumber_-1) -=
overheadTimer_.elapsedSeconds(); cout << "\ttimer overhead: " <<
1.0*timer_.elapsed()/times_(int(implementationNumber_), int(parameter
Number_-1)) << endl;
times_(int(implementationNumber_), int(parameterNumber_-1)) -=
timer_.elapsed();
instr_(int(implementationNumber_), int(parameterNumber_-1)) -=
timer_.instr();
flops_(int(implementationNumber_), int(parameterNumber_-1)) -=
timer_.flops();
if(times_(int(implementationNumber_), int(parameterNumber_-1))<0) {
cerr << "\tError: Timer underflow in benchmark " << implementationDes
criptions_[implementationNumber_] << " " << parameters_(parameterNumber_-1)
<< endl;
times_(int(implementationNumber_), int(parameterNumber_-1)) = blitz::
huge(times_(0,0));
}
state_ = benchmarkingImplementation;
}
template<typename P_parameter>
inline void BenchmarkExt<P_parameter>::skip()
{
BZPRECONDITION(state_ == benchmarkingImplementation);
BZPRECONDITION(parameterNumber_ < numParameters_);
times_(int(implementationNumber_), int(parameterNumber_)) = blitz::quie
t_NaN(double());
++parameterNumber_;
state_ = benchmarkingImplementation; state_ = benchmarkingImplementation;
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::endImplementation() void BenchmarkExt<P_parameter>::endImplementation()
{ {
BZPRECONDITION(state_ == benchmarkingImplementation); BZPRECONDITION(state_ == benchmarkingImplementation);
BZPRECONDITION(parameterNumber_ == numParameters_); BZPRECONDITION(parameterNumber_ == numParameters_);
++implementationNumber_; ++implementationNumber_;
skipping to change at line 240 skipping to change at line 302
state_ = done; state_ = done;
} }
template<typename P_parameter> template<typename P_parameter>
double BenchmarkExt<P_parameter>::getMflops(unsigned implementation, double BenchmarkExt<P_parameter>::getMflops(unsigned implementation,
unsigned parameterNum) const unsigned parameterNum) const
{ {
BZPRECONDITION(state_ == done); BZPRECONDITION(state_ == done);
BZPRECONDITION(implementation < numImplementations_); BZPRECONDITION(implementation < numImplementations_);
BZPRECONDITION(parameterNum < numParameters_); BZPRECONDITION(parameterNum < numParameters_);
return iterations_(parameterNum) * flopsPerIteration_(parameterNum) return 1.0*iterations_(parameterNum) * flopsPerIteration_(parameterNum)
/ times_(implementation, parameterNum) / 1.0e+6; / times_(int(implementation), int(parameterNum)) * timerconversion_;
}
template<typename P_parameter>
double BenchmarkExt<P_parameter>::getinstrperc(int implementation,
int parameterNum) const
{
BZPRECONDITION(state_ == done);
BZPRECONDITION(implementation < numImplementations_);
BZPRECONDITION(parameterNum < numParameters_);
return 1.0*instr_(implementation,parameterNum)/
times_(int(implementation), int(parameterNum));
}
template<typename P_parameter>
double BenchmarkExt<P_parameter>::getflopsperc(int implementation,
int parameterNum) const
{
BZPRECONDITION(state_ == done);
BZPRECONDITION(implementation < numImplementations_);
BZPRECONDITION(parameterNum < numParameters_);
return 1.0*flops_(implementation,parameterNum)/
times_(int(implementation), int(parameterNum));
} }
template<typename P_parameter> template<typename P_parameter>
void BenchmarkExt<P_parameter>::saveMatlabGraph(const char* filename, const char* graphType) const void BenchmarkExt<P_parameter>::saveMatlabGraph(const char* filename, const char* graphType) const
{ {
BZPRECONDITION(state_ == done); BZPRECONDITION(state_ == done);
{
//ugly but saveMatlabGraph is coded into all benchmarks
std::string pyfn(filename);
pyfn=pyfn.replace(pyfn.find(".m"),2,std::string(".py"),0,3);
savePylabGraph(pyfn.c_str());
}
ofstream ofs(filename); ofstream ofs(filename);
assert(ofs.good()); assert(ofs.good());
ofs << "% This matlab file generated automatically by class Benchmark" ofs << "% This matlab file generated automatically by class Benchmark"
<< endl << "% of the Blitz++ class library." << endl << endl; << endl << "% of the Blitz++ class library." << endl << endl;
ofs.setf(ios::scientific); ofs.setf(ios::scientific);
// This will be a lot simpler once Matlab-style output formatting // This will be a lot simpler once Matlab-style output formatting
// of vectors & matrices is finished. // of vectors & matrices is finished.
// ofs << "parm = " << parameters_ << ";" << endl << endl; // ofs << "parm = " << parameters_ << ";" << endl << endl;
ofs << "parm = [ "; ofs << "parm = [ ";
unsigned i; unsigned i;
for (i=0; i < numParameters_; ++i) for (i=0; i < numParameters_; ++i)
ofs << setprecision(12) << double(parameters_[i]) << " "; ofs << setprecision(12) << double(parameters_(i)) << " ";
ofs << "]; " << endl << endl; ofs << "]; " << endl << endl;
ofs << "Mf = [ "; ofs << "Mf = [ ";
for (i=0; i < numParameters_; ++i) for (i=0; i < numParameters_; ++i)
{ {
for (unsigned j=0; j < numImplementations_; ++j) for (unsigned j=0; j < numImplementations_; ++j)
{ {
ofs << setprecision(12) << getMflops(j,i) << " "; ofs << setprecision(12) << getMflops(j,i) << " ";
} }
if (i != numParameters_ - 1) if (i != numParameters_ - 1)
ofs << ";" << endl; ofs << ";" << endl;
} }
ofs << "] ;" << endl << endl; ofs << "] ;" << endl << endl;
ofs << graphType << "(parm,Mf), title('" << description_ << "'), " << e ndl ofs << graphType << "(parm,Mf), title('" << description_ << "'), " << e ndl
<< " xlabel('" << parameterDescription_ << "'), " << " xlabel('" << parameterDescription_ << "'), "
<< "ylabel('" << rateDescription_ << "')" << endl << "ylabel('" << depvar_ << "')\n"
<< "legend("; << "legend(";
for (unsigned j=0; j < numImplementations_; ++j) for (unsigned j=0; j < numImplementations_; ++j)
{ {
ofs << "'" << implementationDescriptions_(j) << "'"; ofs << "'" << implementationDescriptions_[j] << "'";
if (j != numImplementations_ - 1) if (j != numImplementations_ - 1)
ofs << ", "; ofs << ", ";
} }
ofs << ")" << endl; ofs << ")" << endl;
} }
template<typename P_parameter>
void BenchmarkExt<P_parameter>::savePylabGraph(const char* filename, const
char* graphType) const
{
BZPRECONDITION(state_ == done);
ofstream ofs(filename);
assert(ofs.good());
ofs << "# This python file generated automatically by class Benchmark\n
"
<< "# of the Blitz++ class library.\n"
<< "from pylab import *\nfrom numpy import *\n"
<< "clf()\n";
ofs.setf(ios::scientific);
ofs << "legnames=[";
for (unsigned j=0; j < numImplementations_; ++j)
{
ofs << "'" << implementationDescriptions_[j] << "'";
if (j != numImplementations_ - 1)
ofs << ", ";
}
ofs << "]\n\nparm = array([ ";
unsigned i;
for (i=0; i < numParameters_; ++i)
ofs << setprecision(12) << double(parameters_(i)) << ", ";
ofs << "])\n\n";
ofs << "Mf = array([[ ";
for (i=0; i < numParameters_; ++i)
{
if(i>0) ofs << ", [ ";
for (unsigned j=0; j < numImplementations_; ++j)
{
ofs << setprecision(12) << getMflops(j,i);
if(j<numImplementations_-1) ofs << ", ";
}
ofs << "]";
}
ofs << "])" << endl << endl;
#ifdef BZ_HAVE_LIBPAPI
// add i/c and flops counters
ofs << "ic = array([[ ";
for (i=0; i < numParameters_; ++i)
{
if(i>0) ofs << ", [ ";
for (unsigned j=0; j < numImplementations_; ++j)
{
ofs << setprecision(12) << getinstrperc(j,i);
if(j<numImplementations_-1) ofs << ", ";
}
ofs << "]";
}
ofs << "])" << endl << endl;
ofs << "fc = array([[ ";
for (i=0; i < numParameters_; ++i)
{
if(i>0) ofs << ", [ ";
for (unsigned j=0; j < numImplementations_; ++j)
{
ofs << setprecision(12) << getflopsperc(j,i);
if(j<numImplementations_-1) ofs << ", ";
}
ofs << "]";
}
ofs << "])" << endl << endl;
#endif
ofs << graphType << "(parm,Mf)\ntitle('" << description_ << "')\n"
<< "xlabel('" << parameterDescription_ << "')\n"
<< "ylabel('" << depvar_ << "')\n";
ofs << "legend(legnames)\n";
}
BZ_NAMESPACE_END BZ_NAMESPACE_END
#endif // BZ_BENCHEXT_CC #endif // BZ_BENCHEXT_CC
 End of changes. 35 change blocks. 
49 lines changed or deleted 226 lines changed or added


 benchext.h   benchext.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/benchext.h BenchmarkExt classes (Benchmarks with external * blitz/benchext.h BenchmarkExt classes (Benchmarks with external
* control) * control)
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_BENCHEXT_H #ifndef BZ_BENCHEXT_H
#define BZ_BENCHEXT_H #define BZ_BENCHEXT_H
#ifndef BZ_MATRIX_H //#ifndef BZ_MATRIX_H
#include <blitz/matrix.h> #include <blitz/array.h>
#endif //#endif
#include <vector>
#ifndef BZ_TIMER_H #ifndef BZ_TIMER_H
#include <blitz/timer.h> #include <blitz/timer.h>
#endif #endif
#include <math.h> #include <math.h>
#include <string>
// NEEDS_WORK: replace use of const char* with <string>, once standard // NEEDS_WORK: replace use of const char* with <string>, once standard
// library is widely supported. // library is widely supported.
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
// Declaration of class BenchmarkExt<T> // Declaration of class BenchmarkExt<T>
// The template parameter T is the parameter type which is varied in // The template parameter T is the parameter type which is varied in
// the benchmark. Typically T will be an unsigned, and will represent // the benchmark. Typically T will be an unsigned, and will represent
// the length of a vector, size of an array, etc. // the length of a vector, size of an array, etc.
skipping to change at line 59 skipping to change at line 69
class BenchmarkExt { class BenchmarkExt {
public: public:
typedef P_parameter T_parameter; typedef P_parameter T_parameter;
BenchmarkExt(const char* description, int numImplementations); BenchmarkExt(const char* description, int numImplementations);
~BenchmarkExt(); ~BenchmarkExt();
void setNumParameters(int numParameters); void setNumParameters(int numParameters);
void setParameterVector(Vector<T_parameter> parms); void setParameterVector(Array<T_parameter,1> parms);
void setParameterDescription(const char* string); void setParameterDescription(const char* string);
void setIterations(Vector<long> iters); void setIterations(Array<long,1> iters);
void setFlopsPerIteration(Vector<double> flopsPerIteration); void setOpsPerIteration(Array<double,1> flopsPerIteration);
void setRateDescription(const char* string); void setDependentVariable(const char* string);
void beginBenchmarking(); void beginBenchmarking();
void beginImplementation(const char* description); void beginImplementation(const char* description);
bool doneImplementationBenchmark() const; bool doneImplementationBenchmark() const;
const string& currentImplementation() const;
T_parameter getParameter() const; T_parameter getParameter() const;
long getIterations() const; long getIterations() const;
inline void start(); inline void start();
inline void stop(); inline void stop();
void startOverhead(); void startOverhead();
void stopOverhead(); void stopOverhead();
void skip();
void endImplementation(); void endImplementation();
void endBenchmarking(); void endBenchmarking();
double getMflops(unsigned implementation, unsigned parameterNum) const; double getMflops(unsigned implementation, unsigned parameterNum) const;
double getinstrperc(int implementation, int parameterNum) const;
double getflopsperc(int implementation, int parameterNum) const;
void saveMatlabGraph(const char* filename, const char* graphType="semil ogx") const; void saveMatlabGraph(const char* filename, const char* graphType="semil ogx") const;
void savePylabGraph(const char* filename, const char* graphType="semilo gx") const;
protected: protected:
BenchmarkExt(const BenchmarkExt<P_parameter>&) { } BenchmarkExt(const BenchmarkExt<P_parameter>&) { }
void operator=(const BenchmarkExt<P_parameter>&) { } void operator=(const BenchmarkExt<P_parameter>&) { }
enum { initializing, benchmarking, benchmarkingImplementation, enum { initializing, benchmarking, benchmarkingImplementation,
running, runningOverhead, done } state_; running, runningOverhead, done } state_;
unsigned numImplementations_; unsigned numImplementations_;
unsigned implementationNumber_; unsigned implementationNumber_;
const char* description_; std::string description_;
Vector<const char*> implementationDescriptions_; std::vector<std::string> implementationDescriptions_;
Matrix<double,RowMajor> times_; // Elapsed time Array<double,2> times_; // Elapsed time
Array<long long,2> instr_; // instructions according to timer
Array<long long,2> flops_; // flops according to timer
Vector<T_parameter> parameters_; Array<T_parameter,1> parameters_;
Vector<long> iterations_; Array<long,1> iterations_;
Vector<double> flopsPerIteration_; Array<double,1> flopsPerIteration_;
Timer timer_; Timer timer_;
Timer overheadTimer_;
const char* parameterDescription_; std::string parameterDescription_;
const char* rateDescription_; std::string depvar_;
double timerconversion_;
unsigned numParameters_; unsigned numParameters_;
unsigned parameterNumber_; unsigned parameterNumber_;
}; };
BZ_NAMESPACE_END BZ_NAMESPACE_END
#include <blitz/benchext.cc> #include <blitz/benchext.cc>
#endif // BZ_BENCHEXT_H #endif // BZ_BENCHEXT_H
 End of changes. 22 change blocks. 
27 lines changed or deleted 42 lines changed or added


 beta.h   beta.h 
// -*- C++ -*-
// $Id$
/* /*
* Generate Beta random deviate * Generate Beta random deviate
* *
* Returns a single random deviate from the beta distribution with * Returns a single random deviate from the beta distribution with
* parameters A and B. The density of the beta is * parameters A and B. The density of the beta is
* x^(a-1) * (1-x)^(b-1) / B(a,b) for 0 < x < 1 * x^(a-1) * (1-x)^(b-1) / B(a,b) for 0 < x < 1
* *
* The mean is a/(a+b). * The mean is a/(a+b).
* The variance is ab/((a+b)^2(a+b+1)) * The variance is ab/((a+b)^2(a+b+1))
* The rth moment is (a+r-1)^(r)/(a+b+r-1)^(r) * The rth moment is (a+r-1)^(r)/(a+b+r-1)^(r)
skipping to change at line 58 skipping to change at line 61
template<typename T = double, typename IRNG = defaultIRNG, template<typename T = double, typename IRNG = defaultIRNG,
typename stateTag = defaultState> typename stateTag = defaultState>
class Beta : public UniformOpen<T,IRNG,stateTag> class Beta : public UniformOpen<T,IRNG,stateTag>
{ {
public: public:
typedef T T_numtype; typedef T T_numtype;
Beta(T a, T b) Beta(T a, T b)
{ {
aa = a; setParameters(a, b);
bb = b; }
infnty = 0.3 * huge(T());
minlog = 0.085 * tiny(T()); Beta(T a, T b, unsigned int i) : UniformOpen<T, IRNG, stateTag>(i)
expmax = log(infnty); {
setParameters(a, b);
} }
T random(); T random();
void setParameters(T a, T b) void setParameters(T a, T b)
{ {
aa = a; aa = a;
bb = b; bb = b;
infnty = 0.3 * blitz::huge(T());
minlog = 0.085 * blitz::tiny(T());
expmax = log(infnty);
} }
protected: protected:
T ranf() T ranf()
{ {
return UniformOpen<T,IRNG,stateTag>::random(); return UniformOpen<T,IRNG,stateTag>::random();
} }
T aa, bb; T aa, bb;
T infnty, minlog, expmax; T infnty, minlog, expmax;
 End of changes. 3 change blocks. 
5 lines changed or deleted 12 lines changed or added


 blitz.h   blitz.h 
// -*- C++ -*- // -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/blitz.h Includes all the important header files * blitz/blitz.h Includes all the important header files
* *
* $Id: blitz.h,v 1.14 2005/05/18 23:35:55 julianc Exp $ * $Id$
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* *
* This program is free software; you can redistribute it and/or * This file is a part of Blitz.
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_BLITZ_H #ifndef BZ_BLITZ_H
#define BZ_BLITZ_H #define BZ_BLITZ_H
/* /*
* These symbols allow use of the IEEE and System V math libraries * These symbols allow use of the IEEE and System V math libraries
* (libm.a and libmsaa.a) on some platforms. * (libm.a and libmsaa.a) on some platforms.
*/ */
skipping to change at line 47 skipping to change at line 52
#define _ALL_SOURCE #define _ALL_SOURCE
#endif #endif
#ifndef _XOPEN_SOURCE #ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE #define _XOPEN_SOURCE
#endif #endif
#ifndef _XOPEN_SOURCE_EXTENDED #ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1 #define _XOPEN_SOURCE_EXTENDED 1
#endif #endif
#endif #endif
#include <blitz/bzconfig.h>
#include <blitz/compiler.h> // Compiler-specific directives #include <blitz/compiler.h> // Compiler-specific directives
#include <blitz/tuning.h> // Performance tuning #include <blitz/tuning.h> // Performance tuning
#include <blitz/tau.h> // Profiling #include <blitz/tau.h> // Profiling
#include <string> #ifdef BZ_HAVE_STL
#include <stdio.h> // sprintf, etc. #include <string>
#endif
#ifdef BZ_HAVE_STD #ifdef BZ_HAVE_STD
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <cstdio> // sprintf, etc.
#include <cmath>
#else #else
#include <iostream.h> #include <iostream.h>
#include <iomanip.h> #include <iomanip.h>
#endif #include <stdio.h> // sprintf, etc.
#ifdef BZ_MATH_FN_IN_NAMESPACE_STD
#include <cmath>
#else
#include <math.h> #include <math.h>
#endif #endif
#ifdef BZ_HAVE_COMPLEX #ifdef BZ_HAVE_COMPLEX
#include <complex> #include <complex>
#endif #endif
#define BZ_THROW // Needed in <blitz/numinquire.h> #define BZ_THROW // Needed in <blitz/numinquire.h>
// This macro is needed to pass template types to macros, since macros
// don't recognize <> as parentheses.
#define bzCC(...) __VA_ARGS__
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
#ifdef BZ_HAVE_STD #ifdef BZ_HAVE_STD
BZ_USING_NAMESPACE(std) BZ_USING_NAMESPACE(std)
#endif #endif
#ifdef BZ_GENERATE_GLOBAL_INSTANCES #ifdef BZ_GENERATE_GLOBAL_INSTANCES
#define _bz_global #define _bz_global
#define BZ_GLOBAL_INIT(X) =X #define BZ_GLOBAL_INIT(X) =X
#else #else
#define _bz_global extern #define _bz_global extern
#define BZ_GLOBAL_INIT(X) #define BZ_GLOBAL_INIT(X)
#endif #endif
/* Define types for indexing, depending on whether 64- or 32-bit
indices are desired. There are separate typedefs for sizeType and
indexType, because it might be useful to have possibility of arrays
with 64-bit numbers of elements without paying the size overhead of
making all dimensional indexes 64-bit.
*/
// Used for dimensional indexes (not implemented yet).
#ifdef BZ_FULLY64BIT
#warning 64-bit array dimensions not yet implemented
typedef ptrdiff_t indexType;
#else
typedef int indexType;
#endif
typedef size_t sizeType; // Used for memory indexing
typedef ptrdiff_t diffType; // Used for memory index differences, ie stride
s
// set the default padding policy
#ifdef BZ_PAD_ARRAYS
#define BZ_PADDING_DEFAULT paddedData
#else
#define BZ_PADDING_DEFAULT contiguousData
#endif
BZ_NAMESPACE_END BZ_NAMESPACE_END
/* /*
* Thread safety issues. * Thread safety issues. Compiling with -pthread under gcc, or -mt
* Compiling with -pthread under gcc, or -mt under solaris, * under solaris, should automatically define _REENTRANT. Also have
* should automatically turn on BZ_THREADSAFE. * support for OpenMP (which defines _OPENMP) or Windows thread
* implementation. The --enable-threadsafe configure option now
* defines BZ_THREADSAFE. If this is defined but no thread support is
* detected when compiling, we call #error below.
*/ */
#ifdef _REENTRANT
#ifndef BZ_THREADSAFE
#define BZ_THREADSAFE
#endif
#endif
/* /*
* Which mutex implementation should be used for synchronizing * Which mutex implementation should be used for synchronizing
* reference counts. Currently only one option -- pthreads. * reference counts. Options are Thread Building Block Atomics (which
* is preferred over the others), pthreads, OpenMP, or Windows
* threads. If we use TBB, the mutex macros are empty since it
* requires no locking.
*/ */
#ifdef BZ_THREADSAFE #ifdef BZ_THREADSAFE
#define BZ_THREADSAFE_USE_PTHREADS #ifdef BZ_THREADSAFE_USE_TBB
#include "tbb/atomic.h"
#define BZ_THREADSAFE_USE_ATOMIC
#define BZ_REFCOUNT_DECLARE(name) tbb::atomic<int> name;
#else
#define BZ_REFCOUNT_DECLARE(name) volatile int name;
#if defined(_REENTRANT)
#define BZ_THREADSAFE_USE_PTHREADS
#elif defined (_OPENMP)
#define BZ_THREADSAFE_USE_OPENMP
#elif defined(_WIN32)
#define BZ_THREADSAFE_USE_WINDOWS
#else
#error Blitz is configured with --enable-threadsafe, but no compiler thr
ead support is found. Did you forget, e.g., "--pthread"?
#endif
#endif
#else
#define BZ_REFCOUNT_DECLARE(name) int name;
#endif #endif
#ifdef BZ_THREADSAFE_USE_PTHREADS #ifdef BZ_THREADSAFE_USE_PTHREADS
#include <pthread.h> #include <pthread.h>
#define BZ_MUTEX_DECLARE(name) mutable pthread_mutex_t name; #define BZ_MUTEX_DECLARE(name) mutable pthread_mutex_t name;
#define BZ_MUTEX_INIT(name) pthread_mutex_init(&name,NULL); #define BZ_MUTEX_INIT(name) pthread_mutex_init(&name,NULL); mutexLock
#define BZ_MUTEX_LOCK(name) pthread_mutex_lock(&name); ing_ = true;
#define BZ_MUTEX_UNLOCK(name) pthread_mutex_unlock(&name);
#define BZ_MUTEX_LOCK(name) if (mutexLocking_) pthread_mutex_lock(&na
me);
#define BZ_MUTEX_UNLOCK(name) if (mutexLocking_) pthread_mutex_unlock(&
name);
#define BZ_MUTEX_DESTROY(name) pthread_mutex_destroy(&name); #define BZ_MUTEX_DESTROY(name) pthread_mutex_destroy(&name);
#elif defined (BZ_THREADSAFE_USE_WINDOWS)
// Include Windows.h header in case user has not already done so.
// Disable Windows min/max macro definitions
#define NOMINMAX
#include <Windows.h>
#define BZ_MUTEX_DECLARE(name) mutable CRITICAL_SECTION name;
#define BZ_MUTEX_INIT(name) ::InitializeCriticalSection(&name); mute
xLocking_ = true;
#define BZ_MUTEX_LOCK(name) if (mutexLocking_) ::EnterCriticalSection
(&name);
#define BZ_MUTEX_UNLOCK(name) if (mutexLocking_) ::LeaveCriticalSection
(&name);
#define BZ_MUTEX_DESTROY(name) ::DeleteCriticalSection(&name);
#elif defined (BZ_THREADSAFE_USE_OPENMP)
#include <omp.h>
#define BZ_MUTEX_DECLARE(name) mutable omp_lock_t name;
#define BZ_MUTEX_INIT(name) omp_init_lock(&name); mutexLocking_ = tru
e;
#define BZ_MUTEX_LOCK(name) if (mutexLocking_) omp_set_lock(&name);
#define BZ_MUTEX_UNLOCK(name) if (mutexLocking_) omp_unset_lock(&name);
#define BZ_MUTEX_DESTROY(name) omp_destroy_lock(&name);
#else #else
#define BZ_MUTEX_DECLARE(name) #define BZ_MUTEX_DECLARE(name)
#define BZ_MUTEX_INIT(name) #define BZ_MUTEX_INIT(name)
#define BZ_MUTEX_LOCK(name) #define BZ_MUTEX_LOCK(name)
#define BZ_MUTEX_UNLOCK(name) #define BZ_MUTEX_UNLOCK(name)
#define BZ_MUTEX_DESTROY(name) #define BZ_MUTEX_DESTROY(name)
#endif #endif
#include <blitz/bzdebug.h> // Debugging macros #include <blitz/bzdebug.h> // Debugging macros
 End of changes. 19 change blocks. 
30 lines changed or deleted 109 lines changed or added


 bzconfig.h   bzconfig.h 
// -*- C++ -*-
/**************************************************************************
*
* blitz/bzconfig.h Select compiler-specific config file
*
* $Id$
*
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
*
* This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
*
* For more information, please see the Blitz++ Home Page:
* https://sourceforge.net/projects/blitz/
*
**************************************************************************
*/
/* Select the compiler-specific config.h header file */ /* Select the compiler-specific config.h header file */
#ifndef BZCONFIG_H #ifndef BZCONFIG_H
#define BZCONFIG_H #define BZCONFIG_H
#if defined(__APPLE) #if defined(__APPLE__)
#if defined(__GNUC__)
/* GNU gcc compiler for newer Mac OS X Darwin */
#include <blitz/gnu/bzconfig.h>
#else
/* IBM xlc compiler for Darwin */ /* IBM xlc compiler for Darwin */
#include <blitz/apple/bzconfig.h> #include <blitz/apple/bzconfig.h>
#endif
#elif defined(__ICC) #elif defined(__INTEL_COMPILER)
/* Intel icc compiler */ /* Intel icc compiler */
#include <blitz/intel/bzconfig.h> #include <blitz/intel/bzconfig.h>
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
/* Microsoft VS.NET compiler */ /* Microsoft VS.NET compiler */
#include <blitz/ms/bzconfig.h> #include <blitz/ms/bzconfig.h>
#elif defined(__IBM) #elif defined(__xlC__)
/* IBM xlC compiler */ /* IBM xlC compiler */
#include <blitz/ibm/bzconfig.h> #include <blitz/ibm/bzconfig.h>
#elif defined(__DECCXX) #elif defined(__DECCXX)
/* Compaq cxx compiler */ /* Compaq cxx compiler */
#include <blitz/compaq/bzconfig.h> #include <blitz/compaq/bzconfig.h>
#elif defined(__HP_aCC) #elif defined(__HP_aCC)
/* HP aCC compiler */ /* HP aCC compiler */
#include <blitz/hp/bzconfig.h> #include <blitz/hp/bzconfig.h>
#elif defined(_SGI_COMPILER_VERSION) #elif defined(_SGI_COMPILER_VERSION)
/* SGI CC compiler */ /* SGI CC compiler */
#include <blitz/sgi/bzconfig.h> #include <blitz/sgi/bzconfig.h>
#elif defined(__SUNPRO_CC) #elif defined(__SUNPRO_CC)
/* SunPRO CC compiler */ /* SunPRO CC compiler */
#include <blitz/sun/bzconfig.h> #include <blitz/sun/bzconfig.h>
#elif defined(__PATHCC__)
/* Pathscale pathCC compiler */
#include <blitz/pathscale/bzconfig.h>
#elif defined(__GNUC__) #elif defined(__GNUC__)
/* GNU gcc compiler */ /* GNU gcc compiler */
#include <blitz/gnu/bzconfig.h> #include <blitz/gnu/bzconfig.h>
#elif defined(__PGI) #elif defined(__PGI)
/* PGI pgCC compiler */ /* PGI pgCC compiler */
#include <blitz/pgi/bzconfig.h> #include <blitz/pgi/bzconfig.h>
#elif defined(__KCC) #elif defined(__KCC)
/* KAI KCC compiler */ /* KAI KCC compiler */
#include <blitz/kai/bzconfig.h> #include <blitz/kai/bzconfig.h>
#elif defined(__FUJITSU) #elif defined(__FUJITSU)
/* Fujitsu FCC compiler */ /* Fujitsu FCC compiler */
#include <blitz/fujitsu/bzconfig.h> #include <blitz/fujitsu/bzconfig.h>
#elif defined(__PATHSCALE)
/* Pathscale pathCC compiler */
#include <blitz/pathscale/bzconfig.h>
/* Add other compilers here */ /* Add other compilers here */
#else #else
#error Unknown compiler #error Unknown compiler
#endif #endif
#endif /* BZCONFIG_H */ #endif /* BZCONFIG_H */
 End of changes. 7 change blocks. 
7 lines changed or deleted 45 lines changed or added


 bzdebug.h   bzdebug.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/bzdebug.h Debugging macros * blitz/bzdebug.h Debugging macros
* *
* $Id: bzdebug.h,v 1.6 2004/10/06 21:58:33 julianc Exp $ * $Id$
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* *
* This program is free software; you can redistribute it and/or * This file is a part of Blitz.
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_DEBUG_H #ifndef BZ_DEBUG_H
#define BZ_DEBUG_H #define BZ_DEBUG_H
#ifdef BZ_HAVE_STDLIB_H #ifdef BZ_HAVE_STD
#include <stdlib.h> #include <cstdlib>
#include <cassert>
#else
#include <stdlib.h>
#include <assert.h>
#endif #endif
#include <assert.h>
#ifdef BZ_HAVE_RTTI #ifdef BZ_HAVE_RTTI
#include <typeinfo> #include <typeinfo>
#endif #endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
/* /*
* These globals are used by the Blitz++ testsuite. The _bz_global * These globals are used by the Blitz++ testsuite. The _bz_global
* modifier ensures that they will reside in libblitz.a, but appear * modifier ensures that they will reside in libblitz.a, but appear
skipping to change at line 83 skipping to change at line 92
if (assertFailMode == true) if (assertFailMode == true)
{ {
if (condition == true) if (condition == true)
++assertSuccessCount; ++assertSuccessCount;
else else
++assertFailCount; ++assertFailCount;
} }
else { else {
if (!condition) if (!condition)
{ {
cerr << "Unexpected assert failure!" << endl; BZ_STD_SCOPE(cerr) << "Unexpected assert failure!" << BZ_STD_SCOPE( endl);
if (where) if (where)
cerr << where << ":" << line << endl; BZ_STD_SCOPE(cerr) << where << ":" << line << BZ_STD_SCOPE(endl
cerr.flush(); );
BZ_STD_SCOPE(cerr).flush();
assert(0); assert(0);
} }
} }
} }
inline void beginCheckAssert() inline void beginCheckAssert()
{ {
assertFailMode = true; assertFailMode = true;
assertSuccessCount = 0; assertSuccessCount = 0;
assertFailCount = 0; assertFailCount = 0;
} }
inline void endCheckAssert() inline void endCheckAssert()
{ {
assert(assertFailMode == true); assert(assertFailMode == true);
assertFailMode = false; assertFailMode = false;
if (assertFailCount == 0) if (assertFailCount == 0)
{ {
cerr << "Assert check failed!" << endl; BZ_STD_SCOPE(cerr) << "Assert check failed!" << BZ_STD_SCOPE(endl);
assert(0); assert(0);
} }
} }
#define BZASSERT(X) checkAssert(X, __FILE__, __LINE__) #define BZASSERT(X) checkAssert(X, __FILE__, __LINE__)
#define BZPRECONDITION(X) checkAssert(X, __FILE__, __LINE__) #define BZPRECONDITION(X) checkAssert(X, __FILE__, __LINE__)
#define BZPOSTCONDITION(X) checkAssert(X, __FILE__, __LINE__) #define BZPOSTCONDITION(X) checkAssert(X, __FILE__, __LINE__)
#define BZSTATECHECK(X,Y) checkAssert(X == Y, __FILE__, __LINE__) #define BZSTATECHECK(X,Y) checkAssert(X == Y, __FILE__, __LINE__)
#define BZPRECHECK(X,Y) \ #define BZPRECHECK(X,Y) \
{ \ { \
if ((assertFailMode == false) && (!(X))) \ if ((assertFailMode == false) && (!(X))) \
cerr << Y << endl; \ BZ_STD_SCOPE(cerr) << Y << BZ_STD_SCOPE(endl); \
checkAssert(X, __FILE__, __LINE__); \ checkAssert(X, __FILE__, __LINE__); \
} }
#define BZ_DEBUG_MESSAGE(X) \ #define BZ_DEBUG_MESSAGE(X) \
{ \ { \
if (assertFailMode == false) \ if (assertFailMode == false) \
{ \ { \
cout << __FILE__ << ":" << __LINE__ << " " << X << endl; \ BZ_STD_SCOPE(cout) << __FILE__ << ":" << __LINE__ << " " \
<< X << BZ_STD_SCOPE(endl); \
} \ } \
} }
#define BZ_DEBUG_PARAM(X) X #define BZ_DEBUG_PARAM(X) X
#define BZ_PRE_FAIL checkAssert(0) #define BZ_PRE_FAIL checkAssert(0)
#define BZ_ASM_DEBUG_MARKER #define BZ_ASM_DEBUG_MARKER
#elif defined(BZ_DEBUG) #elif defined(BZ_DEBUG)
#define BZASSERT(X) assert(X) #define BZASSERT(X) assert(X)
#define BZPRECONDITION(X) assert(X) #define BZPRECONDITION(X) assert(X)
#define BZPOSTCONDITION(X) assert(X) #define BZPOSTCONDITION(X) assert(X)
#define BZSTATECHECK(X,Y) assert(X == Y) #define BZSTATECHECK(X,Y) assert(X == Y)
#define BZPRECHECK(X,Y) \ #define BZPRECHECK(X,Y) \
{ if (!(X)) \ { if (!(X)) \
{ cerr << "[Blitz++] Precondition failure: Module " << __FILE__ { BZ_STD_SCOPE(cerr) << "[Blitz++] Precondition failure: Module "
\ \
<< " line " << __LINE__ << endl << __FILE__
\ \
<< Y << endl; << " line " << __LINE__ << BZ_STD_SCOPE(endl)
\ \
cerr.flush(); << Y << BZ_STD_SCOPE(endl);
\ \
BZ_STD_SCOPE(cerr).flush();
\
assert(0); \ assert(0); \
} \ } \
} }
#define BZ_DEBUG_MESSAGE(X) \ #define BZ_DEBUG_MESSAGE(X) \
{ cout << __FILE__ << ":" << __LINE__ << " " << X << endl; } { BZ_STD_SCOPE(cout) << __FILE__ << ":" << __LINE__ << " " \
<< X << BZ_STD_SCOPE(endl); }
#define BZ_DEBUG_PARAM(X) X #define BZ_DEBUG_PARAM(X) X
#define BZ_PRE_FAIL assert(0) #define BZ_PRE_FAIL assert(0)
// This routine doesn't exist anywhere; it's used to mark a // This routine doesn't exist anywhere; it's used to mark a
// position of interest in assembler (.s) files // position of interest in assembler (.s) files
void _bz_debug_marker(); void _bz_debug_marker();
#define BZ_ASM_DEBUG_MARKER _bz_debug_marker(); #define BZ_ASM_DEBUG_MARKER _bz_debug_marker();
#else // !BZ_TESTSUITE && !BZ_DEBUG #else // !BZ_TESTSUITE && !BZ_DEBUG
skipping to change at line 174 skipping to change at line 186
#define BZPOSTCONDITION(X) #define BZPOSTCONDITION(X)
#define BZSTATECHECK(X,Y) #define BZSTATECHECK(X,Y)
#define BZPRECHECK(X,Y) #define BZPRECHECK(X,Y)
#define BZ_DEBUG_MESSAGE(X) #define BZ_DEBUG_MESSAGE(X)
#define BZ_DEBUG_PARAM(X) #define BZ_DEBUG_PARAM(X)
#define BZ_PRE_FAIL #define BZ_PRE_FAIL
#define BZ_ASM_DEBUG_MARKER #define BZ_ASM_DEBUG_MARKER
#endif // !BZ_TESTSUITE && !BZ_DEBUG #endif // !BZ_TESTSUITE && !BZ_DEBUG
#define BZ_NOT_IMPLEMENTED() { cerr << "[Blitz++] Not implemented: module #define BZ_NOT_IMPLEMENTED() \
" \ { BZ_STD_SCOPE(cerr) << "[Blitz++] Not implemented: module " \
<< __FILE__ << " line " << __LINE__ << endl; \ << __FILE__ << " line " << __LINE__ << BZ_STD_SCOPE(endl); \
exit(1); } BZ_STD_SCOPE(exit)(1); }
#ifdef BZ_HAVE_RTTI #ifdef BZ_HAVE_RTTI
#define BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(X) typeid(X).name() #define BZ_DEBUG_TEMPLATE_AS_STRING_LITERAL(X) typeid(X).name()
#else #else
template<typename T> template<typename T>
class _bz_stringLiteralForNumericType { class _bz_stringLiteralForNumericType {
public: public:
static const char* string() static const char* string()
{ return "unknown"; } { return "unknown"; }
}; };
#define BZ_DECL_SLFNT(X,Y) \ #define BZ_DECL_SLFNT(X,Y) \
 End of changes. 20 change blocks. 
36 lines changed or deleted 50 lines changed or added


 cartesian.h   cartesian.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array/cartesian.h Cartesian product of indirection containers * blitz/array/cartesian.h Cartesian product of indirection containers
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_ARRAY_CARTESIAN_H #ifndef BZ_ARRAY_CARTESIAN_H
#define BZ_ARRAY_CARTESIAN_H #define BZ_ARRAY_CARTESIAN_H
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
/* /*
* CartesianProduct<T_tuple,T_container> is an adaptor which represents * CartesianProduct<T_tuple,T_container> is an adaptor which represents
* the cartesian product of several containers. * the cartesian product of several containers.
skipping to change at line 46 skipping to change at line 54
struct _cp_end_tag { }; struct _cp_end_tag { };
template<typename T_tuple, typename T_container, int N_containers> template<typename T_tuple, typename T_container, int N_containers>
class CartesianProduct { class CartesianProduct {
public: public:
typedef T_tuple value_type; typedef T_tuple value_type;
typedef T_tuple& reference; typedef T_tuple& reference;
typedef const T_tuple& const_reference; typedef const T_tuple& const_reference;
typedef CartesianProductIterator<T_tuple,T_container,N_containers> iter ator; typedef CartesianProductIterator<T_tuple,T_container,N_containers> iter ator;
typedef int difference_type;
typedef int size_type;
iterator begin() iterator begin()
{ return iterator(*this); } { return iterator(*this); }
iterator end() iterator end()
{ return iterator(_cp_end_tag()); } { return iterator(_cp_end_tag()); }
CartesianProduct(const T_container& container0, CartesianProduct(const T_container& container0,
const T_container& container1) const T_container& container1)
{ {
 End of changes. 8 change blocks. 
11 lines changed or deleted 17 lines changed or added


 cgsolve.h   cgsolve.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array/cgsolve.h Basic conjugate gradient solver for linear system s * blitz/array/cgsolve.h Basic conjugate gradient solver for linear system s
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_CGSOLVE_H #ifndef BZ_CGSOLVE_H
#define BZ_CGSOLVE_H #define BZ_CGSOLVE_H
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
template<typename T_numtype> template<typename T_numtype>
void dump(const char* name, Array<T_numtype,3>& A) void dump(const char* name, Array<T_numtype,3>& A)
{ {
T_numtype normA = 0; T_numtype normA = 0;
for (int i=A.lbound(0); i <= A.ubound(0); ++i) for (int i=A.lbound(0); i <= A.ubound(0); ++i)
{ {
for (int j=A.lbound(1); j <= A.ubound(1); ++j) for (int j=A.lbound(1); j <= A.ubound(1); ++j)
{ {
for (int k=A.lbound(2); k <= A.ubound(2); ++k) for (int k=A.lbound(2); k <= A.ubound(2); ++k)
{ {
T_numtype tmp = A(i,j,k); T_numtype tmp = A(i,j,k);
normA += ::fabs(tmp); normA += BZ_MATHFN_SCOPE(fabs)(tmp);
} }
} }
} }
normA /= A.numElements(); normA /= A.numElements();
cout << "Average magnitude of " << name << " is " << normA << endl; cout << "Average magnitude of " << name << " is " << normA << endl;
} }
template<typename T_stencil, typename T_numtype, int N_rank, typename T_BCs > template<typename T_stencil, typename T_numtype, int N_rank, typename T_BCs >
int conjugateGradientSolver(T_stencil stencil, int conjugateGradientSolver(T_stencil stencil,
 End of changes. 8 change blocks. 
10 lines changed or deleted 18 lines changed or added


 chisquare.h   chisquare.h 
// -*- C++ -*-
// $Id$
/* /*
* Chi^2 distribution * Chi^2 distribution
* *
* This code has been adapted from RANDLIB.C 1.3, by * This code has been adapted from RANDLIB.C 1.3, by
* Barry W. Brown, James Lovato, Kathy Russell, and John Venier. * Barry W. Brown, James Lovato, Kathy Russell, and John Venier.
* Code was originally by Ahrens and Dieter (see above). * Code was originally by Ahrens and Dieter (see above).
* *
* Adapter's notes: * Adapter's notes:
*/ */
skipping to change at line 28 skipping to change at line 31
BZ_NAMESPACE(ranlib) BZ_NAMESPACE(ranlib)
template<typename T = double, typename IRNG = defaultIRNG, template<typename T = double, typename IRNG = defaultIRNG,
typename stateTag = defaultState> typename stateTag = defaultState>
class ChiSquare : public Gamma<T,IRNG,stateTag> class ChiSquare : public Gamma<T,IRNG,stateTag>
{ {
public: public:
typedef T T_numtype; typedef T T_numtype;
ChiSquare(T df) ChiSquare(T df)
: Gamma<T,IRNG,stateTag>(df/2.0) : Gamma<T,IRNG,stateTag>(df/2.0) // isn't this redundant with setDF c
all?
{
setDF(df);
}
ChiSquare(T df, unsigned int i)
: Gamma<T,IRNG,stateTag>(df/2.0, i)
{ {
setDF(df); setDF(df);
} }
void setDF(T _df) void setDF(T _df)
{ {
BZPRECONDITION(_df > 0.0); BZPRECONDITION(_df > 0.0);
df = _df; df = _df;
Gamma<T,IRNG,stateTag>::setMean(df/2.0); Gamma<T,IRNG,stateTag>::setMean(df/2.0);
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 11 lines changed or added


 compiler.h   compiler.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/compiler.h Compiler specific directives and kludges * blitz/compiler.h Compiler specific directives and kludges
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* *
* This program is free software; you can redistribute it and/or * This file is a part of Blitz.
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_COMPILER_H #ifndef BZ_COMPILER_H
#define BZ_COMPILER_H #define BZ_COMPILER_H
// The file <blitz/bzconfig.h> is used to select a compiler-specific // The file <blitz/bzconfig.h> is used to select a compiler-specific
// config.h file that is generated automatically by configure. // config.h file that is generated automatically by configure.
#include <blitz/bzconfig.h> #include <blitz/bzconfig.h>
skipping to change at line 73 skipping to change at line 79
#define BZ_USING_NAMESPACE(X) #define BZ_USING_NAMESPACE(X)
#endif #endif
#ifdef BZ_HAVE_TEMPLATE_QUALIFIED_RETURN_TYPE #ifdef BZ_HAVE_TEMPLATE_QUALIFIED_RETURN_TYPE
#define BZ_USE_NUMTRAIT #define BZ_USE_NUMTRAIT
#endif #endif
#ifdef BZ_HAVE_DEFAULT_TEMPLATE_PARAMETERS #ifdef BZ_HAVE_DEFAULT_TEMPLATE_PARAMETERS
#define BZ_TEMPLATE_DEFAULT(X) = X #define BZ_TEMPLATE_DEFAULT(X) = X
#else #else
#define BZ_TEMPLATE_DEFAULT #define BZ_TEMPLATE_DEFAULT(X)
#endif #endif
#ifndef BZ_HAVE_EXPLICIT #ifndef BZ_HAVE_EXPLICIT
#define explicit #define explicit
#endif #endif
#ifdef BZ_HAVE_TYPENAME #ifdef BZ_HAVE_TYPENAME
#define _bz_typename typename #define _bz_typename typename
#else #else
#define _bz_typename #define _bz_typename
skipping to change at line 124 skipping to change at line 130
#endif #endif
#if defined(BZ_MATH_FN_IN_NAMESPACE_STD) #if defined(BZ_MATH_FN_IN_NAMESPACE_STD)
#define BZ_MATHFN_SCOPE(x) std::x #define BZ_MATHFN_SCOPE(x) std::x
#elif defined(BZ_HAVE_NAMESPACES) #elif defined(BZ_HAVE_NAMESPACES)
#define BZ_MATHFN_SCOPE(x) ::x #define BZ_MATHFN_SCOPE(x) ::x
#else #else
#define BZ_MATHFN_SCOPE(x) x #define BZ_MATHFN_SCOPE(x) x
#endif #endif
#if defined(BZ_MATH_ABSINT_IN_NAMESPACE_STD)
#include <cstdlib>
#else
#include <stdlib.h>
#endif
#if defined(BZ_MATH_ABSINT_IN_NAMESPACE_STD)
#define BZ_MATHABSINT_SCOPE(x) std::x
#elif defined(BZ_HAVE_NAMESPACES)
#define BZ_MATHABSINT_SCOPE(x) ::x
#else
#define BZ_MATHABSINT_SCOPE(x) x
#endif
#if defined(BZ_HAVE_COMPLEX_MATH_IN_NAMESPACE_STD) #if defined(BZ_HAVE_COMPLEX_MATH_IN_NAMESPACE_STD)
#define BZ_CMATHFN_SCOPE(x) std::x #define BZ_CMATHFN_SCOPE(x) std::x
#elif defined(BZ_HAVE_NAMESPACES) #elif defined(BZ_HAVE_NAMESPACES)
#define BZ_CMATHFN_SCOPE(x) ::x #define BZ_CMATHFN_SCOPE(x) ::x
#else #else
#define BZ_CMATHFN_SCOPE(x) x #define BZ_CMATHFN_SCOPE(x) x
#endif #endif
#if defined(BZ_HAVE_NAMESPACES) #if defined(BZ_HAVE_NAMESPACES)
#define BZ_IEEEMATHFN_SCOPE(x) ::x #define BZ_IEEEMATHFN_SCOPE(x) ::x
skipping to change at line 150 skipping to change at line 170
#else #else
#define BZ_BLITZ_SCOPE(x) ::x #define BZ_BLITZ_SCOPE(x) ::x
#endif #endif
#if defined(BZ_HAVE_NAMESPACES) && defined(BZ_HAVE_STD) #if defined(BZ_HAVE_NAMESPACES) && defined(BZ_HAVE_STD)
#define BZ_STD_SCOPE(x) std::x #define BZ_STD_SCOPE(x) std::x
#else #else
#define BZ_STD_SCOPE(x) ::x #define BZ_STD_SCOPE(x) ::x
#endif #endif
// These macros are just markers to document the code in the places
// where playing with the processor branch prediction scheme might
// help. For now these are just nops.
#define BZ_LIKELY(x) (x)
#define BZ_UNLIKELY(x) (x)
#endif // BZ_COMPILER_H #endif // BZ_COMPILER_H
 End of changes. 10 change blocks. 
10 lines changed or deleted 37 lines changed or added


 complex.cc   complex.cc 
/************************************************************************** * /************************************************************************** *
* blitz/array/complex.cc Special functions for complex arrays * blitz/array/complex.cc Special functions for complex arrays
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_ARRAYCOMPLEX_CC #ifndef BZ_ARRAYCOMPLEX_CC
#define BZ_ARRAYCOMPLEX_CC #define BZ_ARRAYCOMPLEX_CC
// Special functions for complex arrays // Special functions for complex arrays
#ifndef BZ_ARRAY_H #ifndef BZ_ARRAY_H
#error <blitz/array/complex.cc> must be included via <blitz/array/array.h> #error <blitz/array/complex.cc> must be included via <blitz/array/array.h>
#endif #endif
 End of changes. 6 change blocks. 
9 lines changed or deleted 16 lines changed or added


 convolve.cc   convolve.cc 
/************************************************************************** * /************************************************************************** *
* blitz/array/convolve.cc One-dimensional convolution * blitz/array/convolve.cc One-dimensional convolution
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_ARRAY_CONVOLVE_CC #ifndef BZ_ARRAY_CONVOLVE_CC
#define BZ_ARRAY_CONVOLVE_CC #define BZ_ARRAY_CONVOLVE_CC
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
template<typename T> template<typename T>
Array<T,1> convolve(const Array<T,1>& B, const Array<T,1>& C) Array<T,1> convolve(const Array<T,1>& B, const Array<T,1>& C)
{ {
int Bl = B.lbound(0), Bh = B.ubound(0); int Bl = B.lbound(0), Bh = B.ubound(0);
int Cl = C.lbound(0), Ch = C.ubound(0); int Cl = C.lbound(0), Ch = C.ubound(0);
int lbound = Bl + Cl; int lbound = Bl + Cl;
int ubound = Bh + Ch; int ubound = Bh + Ch;
Array<T,1> A(Range(lbound,ubound)); Array<T,1> A(Range(lbound,ubound));
T result;
for (int i=lbound; i <= ubound; ++i) for (int i=lbound; i <= ubound; ++i)
{ {
int jl = i - Ch; int jl = i - Ch;
if (jl < Bl) if (jl < Bl)
jl = Bl; jl = Bl;
int jh = i - Cl; int jh = i - Cl;
if (jh > Bh) if (jh > Bh)
jh = Bh; jh = Bh;
T result = 0; result = 0;
for (int j=jl; j <= jh; ++j) for (int j=jl; j <= jh; ++j)
result += B(j) * C(i-j); result += B(j) * C(i-j);
A(i) = result; A(i) = result;
} }
return A; return A;
} }
BZ_NAMESPACE_END BZ_NAMESPACE_END
 End of changes. 8 change blocks. 
10 lines changed or deleted 18 lines changed or added


 convolve.h   convolve.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array/convolve.h One-dimensional convolution * blitz/array/convolve.h One-dimensional convolution
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_ARRAY_CONVOLVE_H #ifndef BZ_ARRAY_CONVOLVE_H
#define BZ_ARRAY_CONVOLVE_H #define BZ_ARRAY_CONVOLVE_H
#ifndef BZ_ARRAY_H #ifndef BZ_ARRAY_H
#error <blitz/array/convolve.h> must be included after <blitz/array.h> #error <blitz/array/convolve.h> must be included after <blitz/array.h>
#endif #endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
 End of changes. 7 change blocks. 
9 lines changed or deleted 17 lines changed or added


 cycle.cc   cycle.cc 
/************************************************************************** * /************************************************************************** *
* blitz/array/cycle.cc Cycle arrays for time-stepping of PDEs. * blitz/array/cycle.cc Cycle arrays for time-stepping of PDEs.
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_ARRAYCYCLE_CC #ifndef BZ_ARRAYCYCLE_CC
#define BZ_ARRAYCYCLE_CC #define BZ_ARRAYCYCLE_CC
#ifndef BZ_ARRAY_H #ifndef BZ_ARRAY_H
#error <blitz/array/cycle.cc> must be included via <blitz/array.h> #error <blitz/array/cycle.cc> must be included via <blitz/array.h>
#endif #endif
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
 End of changes. 6 change blocks. 
9 lines changed or deleted 16 lines changed or added


 default.h   default.h 
// -*- C++ -*-
/**************************************************************************
*
* random/default.h Default IRNG wrapper class
*
* $Id$
*
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
*
* This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
*
* For more information, please see the Blitz++ Home Page:
* https://sourceforge.net/projects/blitz/
*
**************************************************************************
*/
#ifndef BZ_RANDOM_DEFAULT_H #ifndef BZ_RANDOM_DEFAULT_H
#define BZ_RANDOM_DEFAULT_H #define BZ_RANDOM_DEFAULT_H
#include <random/mt.h> #include <random/mt.h>
BZ_NAMESPACE(ranlib) BZ_NAMESPACE(ranlib)
// Some terminology: // Some terminology:
// IRNG = Integer Random Number Generator. IRNGs generate random // IRNG = Integer Random Number Generator. IRNGs generate random
// integers, which are used to create floating-point random // integers, which are used to create floating-point random
skipping to change at line 46 skipping to change at line 77
class IRNGWrapper { class IRNGWrapper {
}; };
template<typename IRNG> template<typename IRNG>
class IRNGWrapper<IRNG,sharedState> { class IRNGWrapper<IRNG,sharedState> {
public: public:
void seed(IRNG_int x) void seed(IRNG_int x)
{ irng_.seed(x); } { irng_.seed(x); }
void seed(std::vector<IRNG_int> x)
{ irng_.seed(x); }
typedef typename IRNG::T_state T_state; typedef typename IRNG::T_state T_state;
T_state getState() const { return irng_.getState(); } T_state getState() const { return irng_.getState(); }
std::string getStateString() const { return irng_.getStateString(); } std::string getStateString() const { return irng_.getStateString(); }
void setState(const T_state& s) { irng_.setState(s); } void setState(const T_state& s) { irng_.setState(s); }
void setState(const std::string& s) { irng_.setState(s); } void setState(const std::string& s) { irng_.setState(s); }
protected: protected:
static IRNG irng_; static IRNG irng_;
}; };
template<typename IRNG> template<typename IRNG>
IRNG IRNGWrapper<IRNG,sharedState>::irng_; IRNG IRNGWrapper<IRNG,sharedState>::irng_;
template<typename IRNG> template<typename IRNG>
class IRNGWrapper<IRNG,independentState> { class IRNGWrapper<IRNG,independentState> {
public: public:
IRNGWrapper() {};
IRNGWrapper(unsigned int i) : irng_(MersenneTwisterCreator::create(i)) {}
;
void seed(IRNG_int x) void seed(IRNG_int x)
{ irng_.seed(x); } { irng_.seed(x); }
void seed(std::vector<IRNG_int> x)
{ irng_.seed(x); }
typedef typename IRNG::T_state T_state; typedef typename IRNG::T_state T_state;
T_state getState() const { return irng_.getState(); } T_state getState() const { return irng_.getState(); }
std::string getStateString() const { return irng_.getStateString(); } std::string getStateString() const { return irng_.getStateString(); }
void setState(const T_state& s) { irng_.setState(s); } void setState(const T_state& s) { irng_.setState(s); }
void setState(const std::string& s) { irng_.setState(s); } void setState(const std::string& s) { irng_.setState(s); }
protected: protected:
IRNG irng_; IRNG irng_;
}; };
 End of changes. 4 change blocks. 
0 lines changed or deleted 43 lines changed or added


 discrete-uniform.h   discrete-uniform.h 
// -*- C++ -*-
/**************************************************************************
*
* random/discrete-uniform.h Discrete uniform IRNG wrapper class
*
* $Id$
*
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
*
* This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
*
* For more information, please see the Blitz++ Home Page:
* https://sourceforge.net/projects/blitz/
*
**************************************************************************
*/
#ifndef BZ_RANDOM_DISCRETE_UNIFORM_H #ifndef BZ_RANDOM_DISCRETE_UNIFORM_H
#define BZ_RANDOM_DISCRETE_UNIFORM_H #define BZ_RANDOM_DISCRETE_UNIFORM_H
#include <random/default.h> #include <random/default.h>
BZ_NAMESPACE(ranlib) BZ_NAMESPACE(ranlib)
template<typename T = unsigned int, typename IRNG = defaultIRNG, template<typename T = unsigned int, typename IRNG = defaultIRNG,
typename stateTag = defaultState> typename stateTag = defaultState>
class DiscreteUniform : public IRNGWrapper<IRNG,stateTag> class DiscreteUniform : public IRNGWrapper<IRNG,stateTag>
{ {
public: public:
typedef T T_numtype; typedef T T_numtype;
DiscreteUniform(T n) DiscreteUniform(T n)
{ {
BZPRECONDITION(n < 4294967295U); BZPRECONDITION(n < 4294967295U);
n_ = n; n_ = n;
} }
DiscreteUniform(T n, unsigned int i) :
IRNGWrapper<IRNG,stateTag>::IRNGWrapper(i)
{
BZPRECONDITION(n < 4294967295U);
n_ = n;
}
T random() T random()
{ {
return this->irng_.random() % n_; return this->irng_.random() % n_;
} }
private: private:
T n_; T n_;
}; };
BZ_NAMESPACE_END BZ_NAMESPACE_END
 End of changes. 2 change blocks. 
0 lines changed or deleted 40 lines changed or added


 domain.h   domain.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array/domain.h Declaration of the RectDomain class * blitz/array/domain.h Declaration of the RectDomain class
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_DOMAIN_H #ifndef BZ_DOMAIN_H
#define BZ_DOMAIN_H #define BZ_DOMAIN_H
#include <blitz/tinyvec.h> #include <blitz/blitz.h>
#include <blitz/et-forward.h>
#include <blitz/range.h> #include <blitz/range.h>
/* /*
* Portions of this class were inspired by the "RectDomain" class * Portions of this class were inspired by the "RectDomain" class
* provided by the Titanium language (UC Berkeley). * provided by the Titanium language (UC Berkeley).
*/ */
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
template<int N_rank> template<int N_rank>
class RectDomain { class RectDomain {
typedef TinyVector<int,N_rank> Bounds; typedef TinyVector<int,N_rank> Bounds;
public: public:
RectDomain() { } RectDomain() { }
RectDomain(const Bounds& lbound,const Bounds& ubound): lbound_(lbound), ubound_(ubound) { } RectDomain(const Bounds& lbound,const Bounds& ubound): lbound_(lbound), ubound_(ubound) { }
RectDomain(const TinyVector<Range,N_rank>& bounds): lbound_(),ubound_() { RectDomain(const TinyVector<Range,N_rank>& bndrange): lbound_(),ubound_ () {
for (int i=0;i<N_rank;++i) { for (int i=0;i<N_rank;++i) {
lbound_(i) = bounds(i).first(); lbound_(i) = bndrange(i).first();
ubound_(i) = bounds(i).last(); ubound_(i) = bndrange(i).last();
} }
} }
// NEEDS_WORK: better constructors // NEEDS_WORK: better constructors
// RectDomain(Range, Range, ...) // RectDomain(Range, Range, ...)
// RectDomain with any combination of Range and int // RectDomain with any combination of Range and int
Bounds& lbound() { return lbound_; } Bounds& lbound() { return lbound_; }
Bounds& ubound() { return ubound_; } Bounds& ubound() { return ubound_; }
const Bounds& lbound() const { return lbound_; } const Bounds& lbound() const { return lbound_; }
skipping to change at line 102 skipping to change at line 111
}; };
/* /*
* StridedDomain added by Julian Cummings * StridedDomain added by Julian Cummings
*/ */
template<int N_rank> template<int N_rank>
class StridedDomain { class StridedDomain {
typedef TinyVector<int,N_rank> Bounds; typedef TinyVector<int,N_rank> Bounds;
typedef TinyVector<int,N_rank> Strides; typedef TinyVector<diffType,N_rank> Strides;
public: public:
StridedDomain(const Bounds& lbound,const Bounds& ubound,const Strides& stride): StridedDomain(const Bounds& lbound,const Bounds& ubound,const Strides& stride):
lbound_(lbound),ubound_(ubound),stride_(stride) { } lbound_(lbound),ubound_(ubound),stride_(stride) { }
// NEEDS_WORK: better constructors // NEEDS_WORK: better constructors
// StridedDomain(Range, Range, ...) // StridedDomain(Range, Range, ...)
// StridedDomain with any combination of Range and int // StridedDomain with any combination of Range and int
const Bounds& lbound() const { return lbound_; } const Bounds& lbound() const { return lbound_; }
const Bounds& ubound() const { return ubound_; } const Bounds& ubound() const { return ubound_; }
const Strides& stride() const { return stride_; } const Strides& stride() const { return stride_; }
int lbound(const int i) const { return lbound_(i); } int lbound(const int i) const { return lbound_(i); }
int ubound(const int i) const { return ubound_(i); } int ubound(const int i) const { return ubound_(i); }
int stride(const int i) const { return stride_(i); } diffType stride(const int i) const { return stride_(i); }
Range operator[](const int rank) const { return Range(lbound_(rank),ubo und_(rank),stride_(rank)); } Range operator[](const int rank) const { return Range(lbound_(rank),ubo und_(rank),stride_(rank)); }
void shrink(const int amount) { void shrink(const int amount) {
lbound_ += amount*stride_; lbound_ += amount*stride_;
ubound_ -= amount*stride_; ubound_ -= amount*stride_;
} }
void shrink(const int dim,const int amount) { void shrink(const int dim,const int amount) {
lbound_(dim) += amount*stride_(dim); lbound_(dim) += amount*stride_(dim);
 End of changes. 12 change blocks. 
15 lines changed or deleted 24 lines changed or added


 dot.h   dot.h 
// -*- C++ -*- // -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/meta/dot.h Tiny vector dot product metaprogram * blitz/meta/dot.h Tiny vector dot product metaprogram
* *
* $Id: dot.h,v 1.5 2005/05/07 04:17:57 julianc Exp $ * $Id$
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* *
* This program is free software; you can redistribute it and/or * This file is a part of Blitz.
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_META_DOT_H #ifndef BZ_META_DOT_H
#define BZ_META_DOT_H #define BZ_META_DOT_H
#ifndef BZ_PROMOTE_H #ifndef BZ_PROMOTE_H
#include <blitz/promote.h> #include <blitz/promote.h>
#endif #endif
skipping to change at line 97 skipping to change at line 102
public: public:
template<typename T_expr1, typename T_expr2> template<typename T_expr1, typename T_expr2>
static inline _bz_meta_nullOperand f(const T_expr1&, const T_expr2&) static inline _bz_meta_nullOperand f(const T_expr1&, const T_expr2&)
{ return _bz_meta_nullOperand(); } { return _bz_meta_nullOperand(); }
template<typename T_expr1, typename P_numtype2> template<typename T_expr1, typename P_numtype2>
static inline _bz_meta_nullOperand static inline _bz_meta_nullOperand
dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0, dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0,
P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0, P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0,
P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0 ) P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0 )
{
return _bz_meta_nullOperand();
}
};
template<int N, int I, typename T_ret>
class _bz_meta_vectorDotRet {
public:
static const int loopFlag = (I < N-1) ? 1 : 0;
template<typename T_expr1, typename T_expr2>
static inline T_ret
f(const T_expr1& a, const T_expr2& b)
{
return static_cast<T_ret>(a[I]) * static_cast<T_ret>(b[I])
+ _bz_meta_vectorDotRet<loopFlag * N, loopFlag * (I+1), T_ret>::f(a,
b);
}
template<typename T_expr1, typename T_expr2>
static inline T_ret
f_value_ref(T_expr1 a, const T_expr2& b)
{
return static_cast<T_ret>(a[I]) * static_cast<T_ret>(b[I])
+ _bz_meta_vectorDotRet<loopFlag * N, loopFlag * (I+1), T_ret>::f(a,
b);
}
template<typename T_expr1, typename T_expr2>
static inline T_ret
f_ref_value(const T_expr1& a, T_expr2 b)
{
return static_cast<T_ret>(a[I]) * static_cast<T_ret>(b[I])
+ _bz_meta_vectorDotRet<loopFlag * N, loopFlag * (I+1), T_ret>::f(a,
b);
}
template<typename T_expr1, typename P_numtype2>
static inline T_ret
dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0,
P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0,
P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0
)
{
return static_cast<T_ret>(a[I]) * static_cast<T_ret>(i1)
+ _bz_meta_vectorDotRet<loopFlag * N, loopFlag * (I+1), T_ret>::dotW
ithArgs
(a, i2, i3, i4, i5, i6, i7, i8, i9);
}
};
template<typename T_ret>
class _bz_meta_vectorDotRet<0,0, T_ret> {
public:
template<typename T_expr1, typename T_expr2>
static inline _bz_meta_nullOperand f(const T_expr1&, const T_expr2&)
{ return _bz_meta_nullOperand(); }
template<typename T_expr1, typename P_numtype2>
static inline _bz_meta_nullOperand
dotWithArgs(const T_expr1& a, P_numtype2 i1, P_numtype2 i2=0,
P_numtype2 i3=0, P_numtype2 i4=0, P_numtype2 i5=0, P_numtype2 i6=0,
P_numtype2 i7=0, P_numtype2 i8=0, P_numtype2 i9=0, P_numtype2 i10=0
)
{ {
return _bz_meta_nullOperand(); return _bz_meta_nullOperand();
} }
}; };
BZ_NAMESPACE_END BZ_NAMESPACE_END
#endif // BZ_META_DOT_H #endif // BZ_META_DOT_H
 End of changes. 8 change blocks. 
10 lines changed or deleted 80 lines changed or added


 et.h   et.h 
// -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array/et.h Include expression templates implementation for arrays * blitz/array/et.h Include expression templates implementation for arrays
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** **/ ************************************************************************** **/
#ifndef BZ_ARRAY_ET_H #ifndef BZ_ARRAY_ET_H
#define BZ_ARRAY_ET_H #define BZ_ARRAY_ET_H
#ifdef BZ_NEW_EXPRESSION_TEMPLATES #ifdef BZ_NEW_EXPRESSION_TEMPLATES
#include <blitz/array/newet.h> // Expression templates #include <blitz/array/newet.h> // Expression templates
#else #else
#include <blitz/array/bops.cc> // Expression templates, two operands #include <blitz/array/bops.cc> // Expression templates, two operands
#include <blitz/array/uops.cc> // Expression templates, math functions #include <blitz/array/uops.cc> // Expression templates, math functions
 End of changes. 7 change blocks. 
9 lines changed or deleted 17 lines changed or added


 etbase.h   etbase.h 
// -*- C++ -*- // -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/etbase.h Declaration of the ETBase<T> class * blitz/etbase.h Declaration of the ETBase<T> class
* *
* $Id: etbase.h,v 1.5 2003/12/30 23:03:29 julianc Exp $ * $Id$
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* *
* This program is free software; you can redistribute it and/or * This file is a part of Blitz.
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU Lesser General Public License for more details.
* *
* Suggestions: blitz-dev@oonumerics.org * You should have received a copy of the GNU Lesser General Public
* Bugs: blitz-bugs@oonumerics.org * License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
* *
* For more information, please see the Blitz++ Home Page: * For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/ * https://sourceforge.net/projects/blitz/
* *
************************************************************************** */ ************************************************************************** */
#ifndef BZ_ETBASE_H #ifndef BZ_ETBASE_H
#define BZ_ETBASE_H #define BZ_ETBASE_H
BZ_NAMESPACE(blitz) BZ_NAMESPACE(blitz)
template<typename T> template<typename T>
class ETBase { class ETBase {
public: public:
typedef T T_unwrapped;
ETBase() ETBase()
{ } { }
ETBase(const ETBase<T>&) ETBase(const ETBase<T>&)
{ } { }
T& unwrap() { return static_cast<T&>(*this); } T& unwrap() { return static_cast<T&>(*this); }
const T& unwrap() const { return static_cast<const T&>(*this); } const T& unwrap() const { return static_cast<const T&>(*this); }
ETBase<T>& wrap() { return static_cast<ETBase<T>&>(*this); }
const ETBase<T>& wrap() const { return static_cast<const ETBase<T>&>(*t
his); }
}; };
BZ_NAMESPACE_END BZ_NAMESPACE_END
#endif // BZ_ETBASE_H #endif // BZ_ETBASE_H
 End of changes. 9 change blocks. 
10 lines changed or deleted 22 lines changed or added


 exponential.h   exponential.h 
// -*- C++ -*-
// $Id$
/* /*
* This generator uses the straightforward transformation * This generator uses the straightforward transformation
* x = - log(y) * m * x = - log(y) * m
* *
* to turn a uniform (0,1) y into an exponentially distributed * to turn a uniform (0,1) y into an exponentially distributed
* variable x. x has density function * variable x. x has density function
* *
* f(x) = (1/m) exp(-(1/m)x) (x > 0) * f(x) = (1/m) exp(-(1/m)x) (x > 0)
* *
* and mean m. * and mean m.
skipping to change at line 35 skipping to change at line 38
BZ_NAMESPACE(ranlib) BZ_NAMESPACE(ranlib)
template<typename T = double, typename IRNG = defaultIRNG, template<typename T = double, typename IRNG = defaultIRNG,
typename stateTag = defaultState> typename stateTag = defaultState>
class ExponentialUnit : public UniformOpen<T,IRNG,stateTag> class ExponentialUnit : public UniformOpen<T,IRNG,stateTag>
{ {
public: public:
typedef T T_numtype; typedef T T_numtype;
ExponentialUnit() {}
explicit ExponentialUnit(unsigned int i) :
UniformOpen<T,IRNG,stateTag>(i) {};
T random() T random()
{ {
return - log(UniformOpen<T,IRNG,stateTag>::random()); return - log(UniformOpen<T,IRNG,stateTag>::random());
} }
}; };
template<typename T = double, typename IRNG = defaultIRNG, template<typename T = double, typename IRNG = defaultIRNG,
typename stateTag = defaultState> typename stateTag = defaultState>
class Exponential : public ExponentialUnit<T,IRNG,stateTag> { class Exponential : public ExponentialUnit<T,IRNG,stateTag> {
public: public:
typedef T T_numtype; typedef T T_numtype;
Exponential(T mean) Exponential(T mean)
{ {
mean_ = mean; mean_ = mean;
} }
Exponential(T mean, unsigned int i) :
UniformOpen<T,IRNG,stateTag>(i)
{
mean_ = mean;
};
T random() T random()
{ {
return mean_ * ExponentialUnit<T,IRNG,stateTag>::random(); return mean_ * ExponentialUnit<T,IRNG,stateTag>::random();
} }
private: private:
T mean_; T mean_;
}; };
BZ_NAMESPACE_END BZ_NAMESPACE_END
 End of changes. 3 change blocks. 
0 lines changed or deleted 14 lines changed or added


 expr.h   expr.h 
// -*- C++ -*- // -*- C++ -*-
/************************************************************************** * /************************************************************************** *
* blitz/array/expr.h Array<T,N> expression templates * blitz/array/expr.h Array<T,N> expression templates
* *
* Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> * $Id$
* *
* This program is free software; you can redistribute it and/or * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
* modify it under the